0

I've recently been trying to convert my startup files to using use-package, so I've been editing my .emacs file a lot. I seem to have myself in a state where some common self-insert-command operations are failing. For instance, I'm editing a buffer in PHP mode, I try to enter a space in a comment line, and I get the error shown in the title, with the following stack trace:

Debugger entered--Lisp error: (void-function nil)
  nil(370 1)
  abbrev--before-point()
  #[0 "\304 \211@^AA\211@^AA\211@^AA\211@^AA^A^D^F^G^F\n\211\205O^@\305`\306\"\305^E\306\"^H\2040^@\307 \2040^@\310 \210^C^Q^B^R^D^S\311^C^E^F^G^F      $^B^BV\203M^@`^BU\203M\
^@^Bb\210\266\202\266\204\207" [noninteractive last-abbrev-text last-abbrev last-abbrev-location abbrev--before-point copy-marker t window-minibuffer-p undo-boundary abbrev-i\
nsert] 20 "\n\n(fn)"]()
  apply(#[0 "\304 \211@^AA\211@^AA\211@^AA\211@^AA^A^D^F^G^F\n\211\205O^@\305`\306\"\305^E\306\"^H\2040^@\307 \2040^@\310 \210^C^Q^B^R^D^S\311^C^E^F^G^F        $^B^BV\203M^@`\
^BU\203M^@^Bb\210\266\202\266\204\207" [noninteractive last-abbrev-text last-abbrev last-abbrev-location abbrev--before-point copy-marker t window-minibuffer-p undo-boundary \
abbrev-insert] 20 "\n\n(fn)"] nil)
  #[771 "^B:\2030^@^B@\301=\203^W^@\300\242\302^C^EA\"\303^C#\207\304^C@\305\306\307\310\311\312\300!\313\"\314\315%^F^FA^F^F#^C#\207\304\316^B\"\207" [(#0) t append nil appl\
y apply-partially make-byte-code 642 "\300\242^C^C^C#\207" vconcat vector [] 7 "\n\n(fn FUNS GLOBAL &rest ARGS)" #[0 "\304 \211@^AA\211@^AA\211@^AA\211@^AA^A^D^F^G^F\n\211\20\
5O^@\305`\306\"\305^E\306\"^H\2040^@\307 \2040^@\310 \210^C^Q^B^R^D^S\311^C^E^F^G^F $^B^BV\203M^@`^BU\203M^@^Bb\210\266\202\266\204\207" [noninteractive last-abbrev-text last\
-abbrev last-abbrev-location abbrev--before-point copy-marker t window-minibuffer-p undo-boundary abbrev-insert] 20 "\n\n(fn)"]] 12 "\n\n(fn FUNS GLOBAL ARGS)"](nil nil nil)
  abbrev--default-expand()
  expand-abbrev()
  self-insert-command(1)
  call-interactively(self-insert-command nil nil)
  command-execute(self-insert-command)

I had a similar problem in cperl-mode, trying to type a colon (:) inside a double-quoted string.

What might be the problem? I'm using GNU Emacs 24.5.1 on OS X, and my .emacs file is pasted here.

Ken Williams
  • 390
  • 2
  • 12
  • 1
    `abbrev--before-point` uses `funcall` to invoke the function returned by `(abbrev-table-get table :enable-function)` or `(abbrev-get abbrev :enable-function)`. One of those is probably returning `nil` instead of a function. Load `abbrev.el` (not `.elc`), then `M-x debug-on-entry abbrev--before-point`, and use `d` to walk through the debugger to see just what is causing the problem. – Drew Dec 09 '15 at 14:50
  • Okay - as I step through, I get to an error on `command-error-default-function((void-function nil) "" backward-word)`. Indeed, if I just do `M-x backward-word`, I get the same `Symbol's function definition is void: nil` error. – Ken Williams Dec 10 '15 at 04:14
  • I can't seem to step through `backward-word` though, if I do `M-x debug-on-entry backward-word` and then invoke the function, I just get the error and no debugger entered. – Ken Williams Dec 10 '15 at 04:15
  • If you just do `M-x backward-word`, without anything else, you get an error? Can you reproduce this starting with `emacs -Q` (no init file)? If not, recursively bisect your init file to find the culprit code: Comment out 1/2 of it, then 3/4, 7/8, etc. until you narrow it down. You can use command `comment-region` to comment-out a region of text. And with a prefix arg (`C-u`) it uncomments the region. – Drew Dec 10 '15 at 04:29
  • 1
    I took a different approach - I kept commenting out sections of my `.emacs` file, and discovered that this chunk is the culprit: `(use-package apache-mode :mode ("^\\.htaccess$") :ensure t)` . I have no idea why this wreaks such havoc, but if I remove the parentheses around the regex, all the problems seem to vanish. – Ken Williams Dec 10 '15 at 04:29
  • Great. Now do `C-h f use-package` and find out how you really should call it. You found your problem, in any case. – Drew Dec 10 '15 at 04:31
  • Yes, thanks for the help - really improved my debugging skills. And by "different approach" I meant different from what I'd been doing. In fact you were simultaneously writing a comment to recommend that approach. =) – Ken Williams Dec 10 '15 at 04:32
  • Yup. Great minds think alike. ;-) – Drew Dec 10 '15 at 04:32

1 Answers1

2

I had the same problem with use-package, when I switched my config to it.

I'll open an issue right now suggesting an improvement in the documentation. Basically, it tells you that :mode accepts a list, but it's a macro, so it's not entirely clear what the desired input is.

GOOD: (use-package enh-ruby-mode :mode "\\.rb" "Guardfile")

BAD: (use-package enh-ruby-mode :mode ("\\.rb" "Guardfile"))

Trevoke
  • 2,375
  • 21
  • 34