0

Emacs fail to exit (save-buffers-kill-emacs, C-c C-x) with the following error:

KEY must be an integer, cons, symbol, or string

My Emacs config:

https://github.com/AttilaVM/.emacs.d/blob/master/init.el

  • Try it without your init file first (emacs -Q). Then recursively bisect your init file (comment out half, then half of the half, and so on). It's not plausible to expect people to go through your init file for you. – Dan Feb 6 '16 at 11:42
  • See if kill-emacs-hook set to something that would give you this warning. If that's not the case, M-x toggle-debug-on-error and look at what function is causing the problem. – wvxvw Feb 6 '16 at 12:45
  • 1
    It's too broad to just say "failed to exit". Throw out a 500+ lines of init file for debugging isn't what SE is for, I think. – Yasushi Shoji Feb 7 '16 at 3:34
1

Well the source of the problem was this line:

(setq help-char (kbd "<f1>"))

I changed it to

(setq help-char nil)

Well it was a kinda intuitive solution, so if another answer explains it, I will accept that.

Update with explanation:

Well I found the error, the kbd function returns with different datatypes, according to the given keys, an example:

(kbd "C-h")  ;; "^H" string
(kbd "C-x")  ;; "^X"
(consp (kbd "M-g"))  ;; [67108910]
(kbd "C-.")  ;; [67108910]
(kbd "C-<f1>") ;; [C-f1]

Returned value for Ctrl or any given functional key is nor integer, nor cons, nor symbol, nor string.

(integerp (kbd "C-<f1>")) ;; nil
(consp (kbd "C-<f1>")) ;; nil
(symbolp (kbd "C-<f1>")) ;; nil
(char-or-string-p (kbd "C-<f1>")) ;; nil

It pretty much explains the given error. So check the kbd return type before assigning it to help-char or similar internal variables representing special characters.

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.