aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2023-08-10 10:18:43 +0200
committerAndrea Corallo2023-08-10 10:32:02 +0200
commit173af0cad514b7fa7b71580caa5e59241098607f (patch)
treec22eff2da1f000595a81aecdc2b264c5da94377c
parent063d7d89d7ae053be611f4de3d1baceddf407c07 (diff)
downloademacs-173af0cad514b7fa7b71580caa5e59241098607f.tar.gz
emacs-173af0cad514b7fa7b71580caa5e59241098607f.zip
* Introduce `emacs-lisp-native-compile'.
* lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile): New command. (emacs-lisp-native-compile-and-load): Make use of.
-rw-r--r--lisp/progmodes/elisp-mode.el17
1 files changed, 12 insertions, 5 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 1b42051ab93..5343be48bb3 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -221,6 +221,16 @@ All commands in `lisp-mode-shared-map' are inherited by this map."
221(declare-function native-compile "comp") 221(declare-function native-compile "comp")
222(declare-function comp-write-bytecode-file "comp") 222(declare-function comp-write-bytecode-file "comp")
223 223
224(defun emacs-lisp-native-compile ()
225 "Native-compile synchronously the current file (if it has changed)."
226 (interactive nil emacs-lisp-mode)
227 (emacs-lisp--before-compile-buffer)
228 (let* ((byte+native-compile t)
229 (byte-to-native-output-buffer-file nil)
230 (eln (native-compile buffer-file-name)))
231 (when eln
232 (comp-write-bytecode-file eln))))
233
224(defun emacs-lisp-native-compile-and-load () 234(defun emacs-lisp-native-compile-and-load ()
225 "Native-compile synchronously the current file (if it has changed). 235 "Native-compile synchronously the current file (if it has changed).
226Load the compiled code when finished. 236Load the compiled code when finished.
@@ -229,11 +239,8 @@ Use `emacs-lisp-byte-compile-and-load' in combination with
229`native-comp-jit-compilation' set to t to achieve asynchronous 239`native-comp-jit-compilation' set to t to achieve asynchronous
230native compilation." 240native compilation."
231 (interactive nil emacs-lisp-mode) 241 (interactive nil emacs-lisp-mode)
232 (emacs-lisp--before-compile-buffer) 242 (when-let ((byte-file (emacs-lisp-native-compile)))
233 (let ((byte+native-compile t) 243 (load (file-name-sans-extension byte-file))))
234 (byte-to-native-output-buffer-file nil))
235 (when-let ((eln (native-compile buffer-file-name)))
236 (load (file-name-sans-extension (comp-write-bytecode-file eln))))))
237 244
238(defun emacs-lisp-macroexpand () 245(defun emacs-lisp-macroexpand ()
239 "Macroexpand the form after point. 246 "Macroexpand the form after point.