Emacs: Define a function which loads the file where the function itself is defined

Posted by damd on Stack Overflow See other posts from Stack Overflow or by damd
Published on 2012-03-30T16:37:20Z Indexed on 2012/03/30 17:30 UTC
Read the original article Hit count: 219

Filed under:

I'm refactoring a bit in my Emacs set up and have come to the conclusion that I want to use a different init file than the default one. So basically, in my ~/.emacs file, I have this:

(load "/some/directory/init.el")

Up until now, that's been working just fine. However, now I want to redefine an old command that I've used for ages, which opens my init file:

(defun conf ()
  "Open a buffer with the user init file."
  (interactive)
  (find-file user-init-file))

As you can see, this will open ~/.emacs no matter what I do. I want it to open /some/directory/init.el, or wherever the conf command itself is defined.

How would I do that?

© Stack Overflow or respective owner

Related posts about emacs