emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 173af0cad51 1/3: * Introduce `emacs-lisp-native-compile'.


From: Andrea Corallo
Subject: emacs-29 173af0cad51 1/3: * Introduce `emacs-lisp-native-compile'.
Date: Thu, 10 Aug 2023 04:45:06 -0400 (EDT)

branch: emacs-29
commit 173af0cad514b7fa7b71580caa5e59241098607f
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    * 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.
---
 lisp/progmodes/elisp-mode.el | 17 ++++++++++++-----
 1 file 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."
 (declare-function native-compile "comp")
 (declare-function comp-write-bytecode-file "comp")
 
+(defun emacs-lisp-native-compile ()
+  "Native-compile synchronously the current file (if it has changed)."
+  (interactive nil emacs-lisp-mode)
+  (emacs-lisp--before-compile-buffer)
+  (let* ((byte+native-compile t)
+         (byte-to-native-output-buffer-file nil)
+         (eln (native-compile buffer-file-name)))
+    (when eln
+      (comp-write-bytecode-file eln))))
+
 (defun emacs-lisp-native-compile-and-load ()
   "Native-compile synchronously the current file (if it has changed).
 Load the compiled code when finished.
@@ -229,11 +239,8 @@ Use `emacs-lisp-byte-compile-and-load' in combination with
 `native-comp-jit-compilation' set to t to achieve asynchronous
 native compilation."
   (interactive nil emacs-lisp-mode)
-  (emacs-lisp--before-compile-buffer)
-  (let ((byte+native-compile t)
-        (byte-to-native-output-buffer-file nil))
-    (when-let ((eln (native-compile buffer-file-name)))
-      (load (file-name-sans-extension (comp-write-bytecode-file eln))))))
+  (when-let ((byte-file (emacs-lisp-native-compile)))
+    (load (file-name-sans-extension byte-file))))
 
 (defun emacs-lisp-macroexpand ()
   "Macroexpand the form after point.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]