0

I'm facing a weird issue in my init.el. Installing packages such as json-mode or puppet-mode (from MELPA Stable) with use-package unsets common functions like forward-word or backward-kill-word. The key bindings are unaffected, the function is simply missing (I get Symbol’s function definition is void: nil). This behavior does not happen with all packages (I have dozens of other packages in my init.el which work just fine).

Here is a minimal init.el:

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
(when (< emacs-major-version 24)
    (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package)
  )

(eval-when-compile (require 'use-package))
(setq use-package-always-ensure t)                                                                                                                                                                       

(use-package json-mode
  :mode ("\\.json"))


(use-package puppet-mode                                                                                                                                                                                                                                                     
  :mode ("\\.pp"))

Running Emacs with a complete clean .emacs.d (apart from the init file) first installs use-package along with diminish and bind-key and then downloads the two modes json-mode and puppet-mode and adds them to the load-path (as expected).

However, opening a text file test.txt and then running M-f or M-x forward-word returns the error: Symbol’s function definition is void: nil

I'm running Emacs 25.1.1

Is this an issue with these packages, or am I doing something wrong?

Can anyone reproduce this problem?

  • 1
    Unrelated to your problem, but one would usually want to end their :mode regexps with \\', which means "end of string", e.g. :mode "\\.json\\'". – Basil May 15 '17 at 19:43
  • @Basil Thanks for the hint, I'll implement it where necessary! – JacksGT May 18 '17 at 14:00
0

I still don't understand what's going on internally here (if this is a bug or just my faulty syntax). Nevertheless, I was able to workaround the problem.

Apparently, one cannot use parentheses when having only one argument for :mode (e.g. :mode ("\\.pp")), but has to omit these (i.e. :mode "\\.pp")).

Fix:

-(use-package puppet-mode
-  :mode ("\\.pp"))
+(use-package puppet-mode
+  :mode "\\.pp")


-(use-package json-mode
-  :mode ("\\.json"))
+(use-package json-mode
+  :mode "\\.json")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.