Created
July 18, 2012 15:17
-
-
Save PhilHudson/3136807 to your computer and use it in GitHub Desktop.
Auto-compile elisp
This file contains hidden or 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 ph/is-elisp-file (filename) | |
"Returns non-nil if FILENAME ends in either '.el' or '.el.gz'" | |
(string-match-p "\\.el\\(\\.gz\\)?\\'" filename) | |
) | |
(defun ph/autocompile-elisp () | |
"Compiles and tags my custom elisp code files on save: | |
<`dot-emacs'>, and files under the <`ph/elisp-root'> directory. | |
References: `dot-emacs-file'" | |
(interactive) | |
(when | |
(and | |
(ph/is-elisp-file (buffer-file-name)) | |
(or | |
(string= (buffer-file-name) dot-emacs-file) | |
(string-match-p (concat "^" ph/elisp-root) (buffer-file-name)) | |
) | |
) | |
(byte-compile-file (buffer-file-name)) | |
(call-process "rebuild_tags" nil "*Messages*") | |
) | |
) | |
(add-hook 'after-save-hook 'ph/autocompile-elisp) |
'ph/elisp-root' is the directory where you keep your own elisp code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'dot-emacs-file' is the pathname of your init.el or .emacs