4

I have (set-register ?E '(file . user-init-file)), so that I can easily jump to my config file. Previously I used a string to specify the path to my init file, but I figured I'd tidy it up a bit.

However, it doesn't work, and emacs complains about (wrong-type-argument stringp user-init-file), giving the following stack trace with debug-on-error enabled.

Debugger entered--Lisp error: (wrong-type-argument stringp user-init-file)
  expand-file-name(user-init-file)
  find-file-noselect(user-init-file nil nil nil)
  find-file(user-init-file)
  ad-Orig-jump-to-register(69 nil)
  jump-to-register(69 nil)
  call-interactively(jump-to-register nil nil)

For reference, this happens if I load emacs with -Q, and then eval the set-register... and then attempt to jump to the register.

What's going on here? Things like (find-file user-init-file) don't throw this error.

7

In your code user-init-file is not evaluated (it is quoted), so expand-file-name gets a symbol (and not a string), and complains about that.

Try this:

(set-register ?E (cons 'file user-init-file))

PS: You can also use the backquote:

(set-register ?E `(file . ,user-init-file))

PPS: A side note: as far as I can tell this case is hard to debug by running emacs with -Q: user-init-file evaluates to nil under emacs -Q, so

(set-register ?E `(file . ,user-init-file))
(jump-to-register ?E)

fails for a different reason.

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.