problem about elisp-Collection of common programming errors


  • Sean M
    emacs elisp
    I’m trying to create a function that will revert buffers from emacs’ *Buffer List* buffer. As far as I can tell from the documentation, there’s no way to do this quickly (in the manner of the save/mark/visit functions built in to buff-menu.el). So I’m writing some elisp. Here’s my current attempt:(defun frobnitz ()”Call in buffer list to revert buffer at point to file.”(interactive)(let ((buf (buffer-menu-buffer t)))(if (y-or-n-p (concat “Revert ” (buffer-name (buf)) ” ?”))(with-current-buffer buf(let (())(revert-buffer t t t)(message(concat “Reverted ” (buffer-name (buf)) “to last saved state.”)))))))Unfortunately, the above defun doesn’t seem to work, and I’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–Lisp error: (void-function buffer-menu-buffer)(buffer-menu-buffer t)(let ((buf (buffer-menu-buffer t))) (if (y-or-n-p (concat “Revert ” (buffer-name (buf)) ” ?”)) (with-current-buffer buf (let (nil) (revert-buffer t t t) (message (concat “Reve

  • mbork
    emacs elisp keymapping
    I 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’m doing something like this:(defvar my-mode-map(let ((map (make-sparse-keymap)))(define-key map “\s” ‘my-command)(define-key map “\t” ‘another-one)(define-key map “\r” ‘yet-another)map))(Of course, I did put my keymap into minor-mode-map-al

  • Nutritioustim
    emacs clojure elisp text-editor
    This is a re-post. I tried asking this on the Emacs-live and Clojure mailing lists, but guess it wasn’t relevant enough. My problem is: I open emacs ( using emacs-live – initialization code in my “~/.live-packs/-pack/init.el” file ) I execute M-x nrepl-jack-in In a repl, I create a varuser> (def thing (+ 1 1)) u

  • jokerdino
    emacs configuration key-binding elisp
    I’m currently in the process of changing my emacs configuration quite extensively. I’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

  • Æ –
    emacs lisp elisp common-lisp slime
    I’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 “M-x slime-close-all-parens-in-sexp”, it works. The commands for this are documented here: Slime docsI searched and found that SLIME doesn’t load contrib module

  • tkf
    emacs elisp file-locking
    I 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 –socket-name server-2 –eval ‘(kill-emacs)’ to s

  • Fred Concklin
    emacs autocomplete elisp homebrew emacs24
    I 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’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

  • Brad Wright
    osx emacs elisp
    Background information:I’m on a Mac, and I’ve just upgraded to Emacs 23.1 via http://emacsformacosx.com/. There are a few issues, notably the lack of full screen ability.I’ve attempted to get around this last issue by installing Mega

  • Gilles
    emacs keyboard-shortcuts elisp minor-mode
    Question:How do I create custom keybindings for minor modes? Something like this.Here is what I have so far. I’m trying to get just one custom keybinding to work:(define-minor-mode num-mode”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

  • rottweiler
    emacs elisp
    I am trying to set [Ctrl]-[;] as a keybinding in my .emacs like this(global-set-key “\C-;” ‘comment-or-uncomment-region)however it doesn’t work when I try (i don’t get any error messages,

  • Wilfred Hughes
    emacs elisp
    I use flymake in Emacs to check code written in several languages. However, I can’t see any way to use flymake on elisp itself.I’m aware of elint-current-buffer,

  • Nikana Reklawyks
    emacs elisp
    What 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

  • gary
    macros lambda elisp sbcl
    During 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 “undefined variable” and “unbound variable” 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

  • MrBones
    emacs elisp
    I’ve installed some things from ELPA, namely evil and rainbow-delimiters.In order to have them run whenever emacs loads, I wou

  • Richard Hansen
    emacs elisp
    If I put the following in foo.el:(defun whitespace-redraw ()(eval-when-compile (require ‘whitespace nil t))(when (require ‘whitespace nil t)(if whitespace-mode(whitespace-mo

  • Shannon Severance
    emacs keyboard elisp
    In GNU Emacs, what is [C-tab]? Consider:(version) “GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600)of 2010-05-08 on G41R2F1″(defun key-binding-test ()(interactive)(insert ” key-binding-test called “))For a single letter control character,

  • snowape
    emacs keyboard-shortcuts elisp
    I want to bind C-x-insert to a comma

  • John Bellone
    emacs elisp key-bindings
    I’ve checked my elisp files to make sure that I do not have any bindings that contain Shift+R (and I have

  • Gabe
    emacs elisp
    I’d like to reduce the default font size for a buffer using Emacs lisp.At the moment I am running a process

  • kdb
    elisp runtime-error compiler-warnings higher-order-functions top-down
    When you perform a function call (myfunction …) in emacs lisp, the byte compiler will warn if the function isn’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’t yet defined or misspelled the two foo- funct

  • sawa
    elisp emacs23
    I updated to GNU emacs 23.3.1, and my configur

  • Justin Valentini
    emacs elisp
    I somehow managed to define the ‘M’ (capit

  • J Spen
    emacs elisp emacs23 auctex
    I keep trying to get rid of this keybinding but setting it to nil or ‘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’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 “\C-x C-z” nil) (global-set-key “\C-z” nil);;Abbreviation mode and settings (add-hook ‘text-mode-hook (lambda () (abbrev-mode 1))) (setq save-abbrevs t) (quietly-read-abbrev-file);;Reftex and then turn on for Auctex (require ‘reftex) (add-hook ‘LaTeX-mode-hook ‘turn-on-reftex);;Enable preview latex (load “preview-latex.el” nil t t);; For line numbers loading(require ‘linum) (setq linum-format “%d “) (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 “TAB”) ‘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 ‘cm-map nil “Outline-“); HIDE(define-key cm-map “q” ‘hide-sublevels) ; Hide everything but the top-level headings(define-key cm-map “t” ‘hide-body) ; Hide everything but headings (all body lines)(define-key cm-map “o” ‘hide-other) ; Hide other branches(define-key cm-map “c” ‘hide-entry) ; Hide this entry’s body(define-key cm-map “l” ‘hide-leaves) ; Hide body lines in this entry and sub-entries(define-key cm-map “d” ‘hide-subtree) ; Hide everything in this entry and sub-entries; SHOW(define-key cm-map “a” ‘show-all) ; Show (expand) everything(define-key cm-map “e” ‘show-entry) ; Show this heading’s body(define-key cm-map “i” ‘show-children) ; Show this heading’s immediate child sub-headings(define-key cm-map “k” ‘show-branches) ; Show all sub-headings under this heading(define-key cm-map “s” ‘show-subtree) ; Show (expand) everything in this heading & below; MOVE(define-key c

  • Sean M
    regex emacs elisp backslash
    I’m trying to use emacs’ customize-group packages to tweak some parts of my setup, and I’m stymied. I see things like this in my .emacs file after I make changes with customize:'(tramp-backup-directory-alist (quote ((“\\\\`.*\\\\'” . “~/.emacs.d/autobackups”))))This was the result of putting the following into the customize text field: Regexp matching filename: \\`.*\\’This is a representative sample: I’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’t seem to find the magic number of backslashes to get the gosh-dang thing to do what I’m asking it to, even for the simplest regular expressions like .*. Right now, the given customization produces – nothing. It makes no change from emacs’ default behavior. Better yet, where on earth is this documented? It’s a little difficult to Google for, but I’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 – 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

  • BobuSumisu
    string emacs lisp elisp yasnippet
    I 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

  • phils
    shell emacs command-line elisp options
    Inspired 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 –script I put some Emacs Lisp code in it,

  • desudesudesu
    emacs elisp
    How can I pass arguments -q -d -Q -t -L -fg -bg —

  • Håkon Hægland
    emacs lua elisp
    I get the following error File mode specification error: (error “Unknown rx form `group-n'”)when I try to edit a .lua file in emacs. I use GNU Emacs 23.3.1, and I

Originally posted 2013-11-09 21:39:50.