I am an emacs novice. I am familiarizing myself with making basic changes to the init.el file.

Currently, when I want to load init.el, I first C-h v user-init-file RET, this opens a *Help* screen which gives me its definition, and therefore the location of the file.

I then highlight and M-w its value, then C-x f to a file requester, then delete the default, then C-y the copied file address then RET.

This looks incredibly convoluted.

What I want to know is, can I cut out all of that and instead simply C-x f to a file requester and then pass the user-init-file definition straight to it, with whatever the emacs notation is for expanding variables (which I don't know)? The help files I have read discuss only examining and setting variables, not using them in the minibuffer.

In short, is there a notation for using variable definitions in a minibuffer command?

2 Answers 2


One way is to type M-: which will prompt you for an expression to evaluate, and then in the mini-buffer type (find-file user-init-file) RET. You can press TAB while typing that to complete both the function and variable name.

While that init file is open, you might consider bookmarking it (C-x r m or Edit->Bookmarks->Set bookmark). Then later, you can just jump to it with (C-x r b or Edit->Bookmarks->Jump to bookmark).

I am not aware of an easy way to insert the value of a variable in the minibuffer with vanilla Emacs.

  • "I am not aware of an easy way to insert the value of a variable in the minibuffer with vanilla emacs". Me neither so this answer provides a suitable solution. Should anybody find a way to do it I will welcome it as an additional answer, until then though, this is perfectly workable. I was also not previously aware of being able to use a bookmark, thank you. Commented Feb 20, 2021 at 16:46

As a technically correct answer to your question, you can programmatically insert arbitrary text into the minibuffer if you set the variable enable-recursive-minibuffers to a true value in your init file:

(setq enable-recursive-minibuffers t)

With this option enabled, you could start the find-file operation with C-x C-f, then insert the value of a variable by calling the eval-expression command with M-: and providing (insert user-init-file) to it. This will append the value of the variable to the original contents of the minibuffer. There's no need to delete the original contents; when Emacs sees two slashes, it treats the second slash as starting a brand new absolute file path. (This behavior would also let you shorten your original process of yanking the path from the Help buffer.)

With more work it would be possible to add a new key binding when finding a file, for a command which prompts for a variable and then inserts the value of that variable. But really, I feel that the bookmark approach is the way to go, since that's what I do. My Emacs init file bookmark is named simply e, so to visit the file, I type C-x r b e RET. It's a not insignificant number of keystrokes, but to me it's appropriate considering how often I visit the file.

Another alternative would be to write a very short command that just visits your init file:

(defun visit-init-file ()
  (find-file user-init-file))

You could bind this command to a convenient key:

(global-set-key (kbd "C-c i") 'visit-init-file)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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