Last active
September 9, 2022 22:28
-
-
Save LesleyLai/627085e275d2cf46429c0f44c27a92d7 to your computer and use it in GitHub Desktop.
Recompile the emacs lisp file on save if the byte-compiled file exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun recompile-elc-on-save () | |
"If you're saving an elisp file, likely the .elc is no longer valid." | |
(make-local-variable 'after-save-hook) | |
(add-hook 'after-save-hook | |
(lambda () | |
(if (file-exists-p (byte-compile-dest-file buffer-file-name)) | |
(byte-compile-file buffer-file-name))))) | |
(add-hook 'emacs-lisp-mode-hook 'recompile-elc-on-save | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very helpful. Thanks!