Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically byte-compiling on save

Everytime I save a file in emacs lisp mode, I want it to be automatically byte-compiled. Can someone come up with a function that does byte-compile-file on the current file if the current major mode is emacs lisp mode? I want to add-hook that function to after-save-hook.

like image 534
sawa Avatar asked May 26 '11 21:05

sawa


1 Answers

I found an answer here. The following does it all. It is a copy from the linked site.

(add-hook 'after-save-hook 
          (lambda ()
            (if (eq major-mode 'emacs-lisp-mode)
                (save-excursion (byte-compile-file buffer-file-name)))))
like image 122
sawa Avatar answered Sep 28 '22 08:09

sawa