Category Archives: lisp

quick .emacs access

when one talks about emacs customization, most of it is going to be editing the .emacs, which is the init file of emacs. emacs loads the init file, by default, stored at the $HOME or the ~/. location in your system. Some times one never knows which is the .emacs that our emacs is using typically when one has been updating his emacs through different versions. the easiest way to find out where your .emacs is to do a C-x C-f ~/.emacs RET   for frequent .emacs users, typing C-x C-f ~/.emacs is also tiring, or basically you might say its redundant.  once a .emacs is edited, one has to load it again to see the change effects. to make it a quick access, you could just create a function which opens a .emacs if not open and loads it if its already open. a keybinding proves very convenient and here is what you add in your .emacs.

(defun open-load-init-emacs ()
“function to open the .emacs in lisp mode and load it”
(interactive);; function be called interactively
(if (equal (buffer-name) “.emacs”)
(eval-buffer) ;; if open, evaluate buffer or load it
(progn (find-file “~/.emacs”) (eval-buffer)))
;; the progn creates a body of commandsfind .emacs, load it
(lisp-mode) ;; enable lisp mode

;; set the key binding to C-x.
(global-set-key “\C-x.” ‘open-load-init-emacs)