As a novice Emacs user (I'm about 3 months into what's probably a lifelong journey), I make changes to my .emacs
file pretty regularly. It would be handy to have a global key binding to reload .emacs
rather than go through the incredibly laborious process of Mx load-file
(delete a long string if I'm deep into some directory) ~/.emacs <RET>
. I've attempted a solution, but
;; reload .emacs when C-c <f12> is pressed
(defun reload-dotemacs ()
(load-file "~/.emacs"))
(global-set-key (kbd "C-c <f12>")
(lambda() (interactive) 'reload-dotemacs))
doesn't seem to work. Basically, when I enter the key combination, nothing happens, whereas trying Mx load-file ~/.emacs
makes things happen (eg I see my yasnippet
files reload).
For the record, Cc <f12>
doesn't seem to be bound to anything else.
(defun reload-dotemacs ()
(interactive)
(load-file "~/.emacs"))
(global-set-key (kbd "C-c <f12>") 'reload-dotemacs)
You do not need to remove the default string when you do Mx load-file RET - just type ~/.emacs.el RET and it will work.
Do not reload the init file, just evaluate the new code.
Type Ch m and Ch b in the .emacs.el
buffer and you will see the useful keybindings (after searching for eval
):
C-c C-b eval-current-buffer
C-c C-r eval-region
C-M-x eval-defun
C-j eval-print-last-sexp
C-x C-e eval-last-sexp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.