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
.
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)))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With