emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp a214882 5/8: * Add to elisp-mode `emacs-lisp-native-


From: Andrea Corallo
Subject: feature/native-comp a214882 5/8: * Add to elisp-mode `emacs-lisp-native-compile-and-load'
Date: Wed, 11 Nov 2020 19:03:07 -0500 (EST)

branch: feature/native-comp
commit a214882354c7b0f4842698b5a1a65db6806853a2
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    * Add to elisp-mode `emacs-lisp-native-compile-and-load'
    
        * lisp/progmodes/elisp-mode.el
        (emacs-lisp--before-compile-buffer): New function.
        (emacs-lisp-byte-compile-and-load): Use the previous.
        (emacs-lisp-native-compile-and-load): New function.
---
 lisp/progmodes/elisp-mode.el | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 12788ea..dac3aaf 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -186,19 +186,34 @@ All commands in `lisp-mode-shared-map' are inherited by 
this map.")
       (byte-compile-file buffer-file-name)
     (error "The buffer must be saved in a file first")))
 
-(defun emacs-lisp-byte-compile-and-load ()
-  "Byte-compile the current file (if it has changed), then load compiled code."
-  (interactive)
+(defun emacs-lisp--before-compile-buffer ()
+  "Make sure the buffer is saved before compiling."
   (or buffer-file-name
       (error "The buffer must be saved in a file first"))
-  (require 'bytecomp)
   ;; Recompile if file or buffer has changed since last compilation.
   (if (and (buffer-modified-p)
           (y-or-n-p (format "Save buffer %s first? " (buffer-name))))
-      (save-buffer))
+      (save-buffer)))
+
+(defun emacs-lisp-byte-compile-and-load ()
+  "Byte-compile the current file (if it has changed), then load compiled code."
+  (interactive)
+  (emacs-lisp--before-compile-buffer)
+  (require 'bytecomp)
   (byte-recompile-file buffer-file-name nil 0)
   (load buffer-file-name))
 
+(defun emacs-lisp-native-compile-and-load ()
+  "Native-compile synchronously the current file (if it has changed).
+Load the compiled code when finished.
+
+Use `emacs-lisp-byte-compile-and-load' in combination with
+`comp-deferred-compilation' set to `t' to achieve asynchronous
+native compilation."
+  (interactive)
+  (emacs-lisp--before-compile-buffer)
+  (load (native-compile buffer-file-name)))
+
 (defun emacs-lisp-macroexpand ()
   "Macroexpand the form after point.
 Comments in the form will be lost."



reply via email to

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