Automatically byte compilation on save

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

+4
source share
1 answer

I found the answer here . The following does everything. This 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))))) 
+6
source

All Articles