{"id":693,"date":"2022-08-30T15:05:36","date_gmt":"2022-08-30T15:05:36","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/problem-about-elisp-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:05:36","modified_gmt":"2022-08-30T15:05:36","slug":"problem-about-elisp-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-elisp-collection-of-common-programming-errors\/","title":{"rendered":"problem about elisp-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fd29df2de2d7acf2fe08ebb40a45de36?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSean M<br \/>\nemacs elisp<br \/>\nI&#8217;m trying to create a function that will revert buffers from emacs&#8217; *Buffer List* buffer. As far as I can tell from the documentation, there&#8217;s no way to do this quickly (in the manner of the save\/mark\/visit functions built in to buff-menu.el). So I&#8217;m writing some elisp. Here&#8217;s my current attempt:(defun frobnitz ()&#8221;Call in buffer list to revert buffer at point to file.&#8221;(interactive)(let ((buf (buffer-menu-buffer t)))(if (y-or-n-p (concat &#8220;Revert &#8221; (buffer-name (buf)) &#8221; ?&#8221;))(with-current-buffer buf(let (())(revert-buffer t t t)(message(concat &#8220;Reverted &#8221; (buffer-name (buf)) &#8220;to last saved state.&#8221;)))))))Unfortunately, the above defun doesn&#8217;t seem to work, and I&#8217;m having trouble figuring out why. If I eval the above, switch to the *Buffer List* buffer, and invoke M-: (frobnitz), then it errors out with the following.Debugger entered&#8211;Lisp error: (void-function buffer-menu-buffer)(buffer-menu-buffer t)(let ((buf (buffer-menu-buffer t))) (if (y-or-n-p (concat &#8220;Revert &#8221; (buffer-name (buf)) &#8221; ?&#8221;)) (with-current-buffer buf (let (nil) (revert-buffer t t t) (message (concat &#8220;Reve<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d246baeefae20788d6ea519b777a99c7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmbork<br \/>\nemacs elisp keymapping<br \/>\nI am trying to define my minor mode, mimicking it after isearch-mode (since it is kind of an interactive search-and-replace tool, I thought it might be a good starting point). My commands work well (tested on global keybindings), but I have serious problems with binding them locally (in the minor mode map) to some keys, namely TAB and RET. I&#8217;m doing something like this:(defvar my-mode-map(let ((map (make-sparse-keymap)))(define-key map &#8220;\\s&#8221; &#8216;my-command)(define-key map &#8220;\\t&#8221; &#8216;another-one)(define-key map &#8220;\\r&#8221; &#8216;yet-another)map))(Of course, I did put my keymap into minor-mode-map-al<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0591a4cd81a1803e408e2fd9c1121e9d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNutritioustim<br \/>\nemacs clojure elisp text-editor<br \/>\nThis is a re-post. I tried asking this on the Emacs-live and Clojure mailing lists, but guess it wasn&#8217;t relevant enough. My problem is: I open emacs ( using emacs-live &#8211; initialization code in my &#8220;~\/.live-packs\/-pack\/init.el&#8221; file ) I execute M-x nrepl-jack-in In a repl, I create a varuser&gt; (def thing (+ 1 1)) u<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8bfa3d624cdb4f087d8d8ffcaf786315?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njokerdino<br \/>\nemacs configuration key-binding elisp<br \/>\nI&#8217;m currently in the process of changing my emacs configuration quite extensively. I&#8217;m not comfortable with the default key-bindings for a lot of the major and minor modes and my configuration consists of undefining a lot<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/2rfon.png?s=32&amp;g=1\" \/><br \/>\n\u00c6 &#8211;<br \/>\nemacs lisp elisp common-lisp slime<br \/>\nI&#8217;m using LispBox on OS X. I was trying to use the SLIME command C-c C-] to close all open parentheses in a given S-expression. But the emacs status tells me that C-c C-] is undefined. When I manually type it in using &#8220;M-x slime-close-all-parens-in-sexp&#8221;, it works. The commands for this are documented here: Slime docsI searched and found that SLIME doesn&#8217;t load contrib module<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bcc5cb726add8e1049e49b056ff2dfd9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntkf<br \/>\nemacs elisp file-locking<br \/>\nI want to some Emacs lisp to manipulate same file from different Emacs processes. So I wrote the following script to check how lock-buffer works. However, it stops when trying to lock the file by the second Emacs process (find-and-lock-file $es2 \/tmp\/dummy). I need to go to another terminal and send emacsclient &#8211;socket-name server-2 &#8211;eval &#8216;(kill-emacs)&#8217; to s<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f1c9417141a1ccc6db40c90666f8011d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFred Concklin<br \/>\nemacs autocomplete elisp homebrew emacs24<br \/>\nI am trying to install autocomplete mode on OS X 10.8.4 using emacs 24 installed through brew. I have cloned autocomplete through git git mirror here and I&#8217;m following the build instructions build instructions here. I am getting an error during make install telling me that define-package (presumably some elisp) i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/405eaedde3de68f81af2140fc5794aae?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBrad Wright<br \/>\nosx emacs elisp<br \/>\nBackground information:I&#8217;m on a Mac, and I&#8217;ve just upgraded to Emacs 23.1 via http:\/\/emacsformacosx.com\/. There are a few issues, notably the lack of full screen ability.I&#8217;ve attempted to get around this last issue by installing Mega<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a717291747c76567bb0f086e15ae6e43?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGilles<br \/>\nemacs keyboard-shortcuts elisp minor-mode<br \/>\nQuestion:How do I create custom keybindings for minor modes? Something like this.Here is what I have so far. I&#8217;m trying to get just one custom keybinding to work:(define-minor-mode num-mode&#8221;Toggle the Num pad keys.With no argument, this command toggles the mode.Non-null prefix argument turns on the mode.Null prefix argument turns off the mode.When Num mode is enabled<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/966e47acc1675f6f949625c1e97cb0e0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrottweiler<br \/>\nemacs elisp<br \/>\nI am trying to set [Ctrl]-[;] as a keybinding in my .emacs like this(global-set-key &#8220;\\C-;&#8221; &#8216;comment-or-uncomment-region)however it doesn&#8217;t work when I try (i don&#8217;t get any error messages,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1f86c0bc40235a9edf351a16b859aabd?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nWilfred Hughes<br \/>\nemacs elisp<br \/>\nI use flymake in Emacs to check code written in several languages. However, I can&#8217;t see any way to use flymake on elisp itself.I&#8217;m aware of elint-current-buffer,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ed85d1091accd4e80e46872f5b765f09?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNikana Reklawyks<br \/>\nemacs elisp<br \/>\nWhat do I have to write in my .emacs file in order to associate the command with inserting the character ` (backtick).I run GNU Emacs 23.1.1 on Unix.Background: I run Unix via a shell that runs i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9726e2f7f5c30c4f6d68c69cd6d56b14?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngary<br \/>\nmacros lambda elisp sbcl<br \/>\nDuring the first example (the database example) in Practical Common Lisp, the author uses a macro and a couple support functions in order to replace a larger function, named where. The code works fine when where is a function, but the macro setup returns &#8220;undefined variable&#8221; and &#8220;unbound variable&#8221; errors. (Note that I commented out the original function, restarted Emacs and recompiled my file once adding the where macro.) The caught style-warning in the RE<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/658ca6ac6a34964b80c11cdf9d690e62?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMrBones<br \/>\nemacs elisp<br \/>\nI&#8217;ve installed some things from ELPA, namely evil and rainbow-delimiters.In order to have them run whenever emacs loads, I wou<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1882423f2aa1da4333eab69672b319db?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRichard Hansen<br \/>\nemacs elisp<br \/>\nIf I put the following in foo.el:(defun whitespace-redraw ()(eval-when-compile (require &#8216;whitespace nil t))(when (require &#8216;whitespace nil t)(if whitespace-mode(whitespace-mo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a591cce4ad507600128e99218f7b9c55?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nShannon Severance<br \/>\nemacs keyboard elisp<br \/>\nIn GNU Emacs, what is [C-tab]? Consider:(version) &#8220;GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600)of 2010-05-08 on G41R2F1&#8243;(defun key-binding-test ()(interactive)(insert &#8221; key-binding-test called &#8220;))For a single letter control character,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6967398c463f736f98e73e9026fc57fb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsnowape<br \/>\nemacs keyboard-shortcuts elisp<br \/>\nI want to bind C-x-insert to a comma<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d3713685a96ade919abb6c0990190c32?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJohn Bellone<br \/>\nemacs elisp key-bindings<br \/>\nI&#8217;ve checked my elisp files to make sure that I do not have any bindings that contain Shift+R (and I have<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/97e293cbc474ca83db5ce58289c3f454?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGabe<br \/>\nemacs elisp<br \/>\nI&#8217;d like to reduce the default font size for a buffer using Emacs lisp.At the moment I am running a process<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8e938535dfc85999055798b79dd803dc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkdb<br \/>\nelisp runtime-error compiler-warnings higher-order-functions top-down<br \/>\nWhen you perform a function call (myfunction &#8230;) in emacs lisp, the byte compiler will warn if the function isn&#8217;t known to be defined at compile time. This helps greatly with a top-down programming style, since then I can happily write (defun foo (bar baz)(foo-filter-by-functon (lambda (a b) (equal (upcase a) (upcase b)))(foo-combine-values bar baz)))When I compile the byte compiler tells me that I haven&#8217;t yet defined or misspelled the two foo- funct<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/zL1re.jpg?s=32&amp;g=1\" \/><br \/>\nsawa<br \/>\nelisp emacs23<br \/>\nI updated to GNU emacs 23.3.1, and my configur<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/73895eaa16c526a265eac25dac0612fd?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJustin Valentini<br \/>\nemacs elisp<br \/>\nI somehow managed to define the &#8216;M&#8217; (capit<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/18bbd6d6bb1b1d046a71751baf54aaf7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJ Spen<br \/>\nemacs elisp emacs23 auctex<br \/>\nI keep trying to get rid of this keybinding but setting it to nil or &#8216;undo which would be fine with no luck. I am not sure why it even gets set to C-x C-z in the first place. I wouldn&#8217;t even mind permanently removing the suspend-frame command if that would provide a solution.Here is my .emacs file if it helps:;;Style files and multi-file documents (setq TeX-auto-save t) (setq TeX-parse-self t) (setq-default TeX-master nil)(setq inhibit-splash-screen t);; Use PDF mode by default (setq-default TeX-PDF-mode t) (setq TeX-save-query nil)(global-auto-revert-mode t) (global-set-key &#8220;\\C-x C-z&#8221; nil) (global-set-key &#8220;\\C-z&#8221; nil);;Abbreviation mode and settings (add-hook &#8216;text-mode-hook (lambda () (abbrev-mode 1))) (setq save-abbrevs t) (quietly-read-abbrev-file);;Reftex and then turn on for Auctex (require &#8216;reftex) (add-hook &#8216;LaTeX-mode-hook &#8216;turn-on-reftex);;Enable preview latex (load &#8220;preview-latex.el&#8221; nil t t);; For line numbers loading(require &#8216;linum) (setq linum-format &#8220;%d &#8220;) (global-linum-mode 1) ;; ===== Set the highlight current line minor mode ===== (global-hl-line-mode 1);; ===== Set standard indent to 2 rather that 4 ==== ;;(setq standard-indent 2);; ========== Enable Line and Column Numbering ==========;; Show line-number in the mode line (line-number-mode 1);; Show column-number in the mode line (column-number-mode 1) ;; ========== Force emacs to use tabs ================== ;; Turn on tabs ;;(setq indent-tabs-mode t) ;;(setq-default indent-tabs-mode t);; Bind the TAB key ;;(global-set-key (kbd &#8220;TAB&#8221;) &#8216;self-insert-command);; Set the tab width ;;(setq default-tab-width 4) ;;(setq tab-width 4) ;;(setq c-basic-indent 4) (setq outline-minor-mode 1); Outline-minor-mode key map(define-prefix-command &#8216;cm-map nil &#8220;Outline-&#8220;); HIDE(define-key cm-map &#8220;q&#8221; &#8216;hide-sublevels) ; Hide everything but the top-level headings(define-key cm-map &#8220;t&#8221; &#8216;hide-body) ; Hide everything but headings (all body lines)(define-key cm-map &#8220;o&#8221; &#8216;hide-other) ; Hide other branches(define-key cm-map &#8220;c&#8221; &#8216;hide-entry) ; Hide this entry&#8217;s body(define-key cm-map &#8220;l&#8221; &#8216;hide-leaves) ; Hide body lines in this entry and sub-entries(define-key cm-map &#8220;d&#8221; &#8216;hide-subtree) ; Hide everything in this entry and sub-entries; SHOW(define-key cm-map &#8220;a&#8221; &#8216;show-all) ; Show (expand) everything(define-key cm-map &#8220;e&#8221; &#8216;show-entry) ; Show this heading&#8217;s body(define-key cm-map &#8220;i&#8221; &#8216;show-children) ; Show this heading&#8217;s immediate child sub-headings(define-key cm-map &#8220;k&#8221; &#8216;show-branches) ; Show all sub-headings under this heading(define-key cm-map &#8220;s&#8221; &#8216;show-subtree) ; Show (expand) everything in this heading &amp; below; MOVE(define-key c<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fd29df2de2d7acf2fe08ebb40a45de36?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSean M<br \/>\nregex emacs elisp backslash<br \/>\nI&#8217;m trying to use emacs&#8217; customize-group packages to tweak some parts of my setup, and I&#8217;m stymied. I see things like this in my .emacs file after I make changes with customize:'(tramp-backup-directory-alist (quote ((&#8220;\\\\\\\\`.*\\\\\\\\'&#8221; . &#8220;~\/.emacs.d\/autobackups&#8221;))))This was the result of putting the following into the customize text field: Regexp matching filename: \\\\`.*\\\\&#8217;This is a representative sample: I&#8217;m actually trying to change several things that want a regexp, and they all show this same problem. How many layers of quoting are there, really? I can&#8217;t seem to find the magic number of backslashes to get the gosh-dang thing to do what I&#8217;m asking it to, even for the simplest regular expressions like .*. Right now, the given customization produces &#8211; nothing. It makes no change from emacs&#8217; default behavior. Better yet, where on earth is this documented? It&#8217;s a little difficult to Google for, but I&#8217;ve been trying quite a few things there as well as in the official documentation and the Emacs wiki. Where is an authoritative source for how many dang backslashes one needs to make a regular expression in customize-mode actually work &#8211; or at the very least, to fail with some kind of warning instead of failing silently?EDIT: As so often happens with questions asked in anger, I was asking the wrong question. Fortunately the answers below, led me to the ans<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/be791917e42c1462db4050585993d50b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBobuSumisu<br \/>\nstring emacs lisp elisp yasnippet<br \/>\nI am new to elisp but I am trying to spice up my .emacs a little.I am trying to define some paths, but having problems with creating a list of paths (and setting the list for YaSnippe<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/34852e4d7242b97103c1d7d875bccd69?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nphils<br \/>\nshell emacs command-line elisp options<br \/>\nInspired by Stack Overflow question Idomatic batch processing of text in Emacs? I tried out an Emacs shell script with the following headline:#!\/usr\/bin\/emacs &#8211;script I put some Emacs Lisp code in it,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/db8a4f285e9e0200fec47a181d04043f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndesudesudesu<br \/>\nemacs elisp<br \/>\nHow can I pass arguments -q -d -Q -t -L -fg -bg &#8212;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9d84267888211d0d9946ca48e19ebf5e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nH\u00e5kon H\u00e6gland<br \/>\nemacs lua elisp<br \/>\nI get the following error File mode specification error: (error &#8220;Unknown rx form `group-n'&#8221;)when I try to edit a .lua file in emacs. I use GNU Emacs 23.3.1, and I<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:39:50. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Sean M emacs elisp I&#8217;m trying to create a function that will revert buffers from emacs&#8217; *Buffer List* buffer. As far as I can tell from the documentation, there&#8217;s no way to do this quickly (in the manner of the save\/mark\/visit functions built in to buff-menu.el). So I&#8217;m writing some elisp. Here&#8217;s my current attempt:(defun [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-693","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=693"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/693\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}