Skip to content

Instantly share code, notes, and snippets.

@LesleyLai
LesleyLai / recompile-on-save.el
Last active September 9, 2022 22:28
Recompile the emacs lisp file on save if the byte-compiled file exist
(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
)