about summary refs log tree commit diff stats
path: root/.emacs.d
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2021-09-06 20:59:40 +0100
committerDavid Morgan <djm_uk@protonmail.com>2021-09-06 20:59:40 +0100
commitfa5235f24286041496dc81379ff9b19d0994a65f (patch)
tree26ccab546fa36dcf6e687a6a4e81a8a5d1b77a90 /.emacs.d
parentab2f5baad75e110f8628823dc725296f33d1582c (diff)
downloaddotfiles-fa5235f24286041496dc81379ff9b19d0994a65f.tar.gz
Fix recompile elisp hook
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/init-emacs-lisp.el21
1 files changed, 9 insertions, 12 deletions
diff --git a/.emacs.d/lisp/init-emacs-lisp.el b/.emacs.d/lisp/init-emacs-lisp.el
index ed608c3..7bc2ac5 100644
--- a/.emacs.d/lisp/init-emacs-lisp.el
+++ b/.emacs.d/lisp/init-emacs-lisp.el
@@ -13,19 +13,16 @@
   :diminish)
 
 (use-package emacs
-  :ensure nil
   :config
-  ;; From prelude-emacs-lisp.el
-  (defun recompile-elc-on-save ()
+  ;; Based on prelude-emacs-lisp.el
+  (defun recompile-init-lisp ()
+    (when (and
+           (string-prefix-p (expand-file-name "lisp" user-emacs-directory) (file-truename buffer-file-name))
+           (file-exists-p (byte-compile-dest-file buffer-file-name)))
+      (emacs-lisp-byte-compile)))
+  (defun recompile-init-lisp-on-save ()
     "Recompile your elc when saving an elisp file. (Adds buffer-local hook)"
-    (add-hook 'after-save-hook
-              (lambda ()
-                (when (and
-                       (string-prefix-p user-emacs-directory (file-truename buffer-file-name))
-                       (file-exists-p (byte-compile-dest-file buffer-file-name)))
-                  (emacs-lisp-byte-compile)))
-              nil
-              t))
+    (add-hook 'after-save-hook 'recompile-init-lisp nil t))
   ;; From prelude-emacs-lisp.el
   (defun visit-ielm ()
     "Switch to default `ielm' buffer.
@@ -41,7 +38,7 @@ Start `ielm' if it's not already running."
                        (rainbow-mode +1)
                        (rainbow-delimiters-mode +1)
                        (setq mode-name "EL")
-                       (recompile-elc-on-save)))
+                       (recompile-init-lisp-on-save)))
   :bind
   (:map emacs-lisp-mode-map
         (("C-c C-z" . visit-ielm)