From: Andrea Corallo Date: Tue, 10 Nov 2020 17:58:56 +0000 (+0100) Subject: * Add to elisp-mode `emacs-lisp-native-compile-and-load' X-Git-Tag: emacs-28.0.90~2727^2~334 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a214882354c7b0f4842698b5a1a65db6806853a2;p=emacs.git * 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. --- diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 12788eacf1b..dac3aaf2a53 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."