Fix `emacs-lisp-native-compile-and-load' for C-h f (bug#58314)
* lisp/emacs-lisp/comp.el (comp-write-bytecode-file): New function spilling code from `batch-byte+native-compile'. (batch-byte+native-compile): Make use of. * lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile-and-load): Produce the elc file and ask to have it loaded.
This commit is contained in:
parent
07c8211ca3
commit
bcc222251e
2 changed files with 27 additions and 12 deletions
|
@ -4318,6 +4318,26 @@ last directory in `native-comp-eln-load-path')."
|
||||||
else
|
else
|
||||||
collect (byte-compile-file file))))
|
collect (byte-compile-file file))))
|
||||||
|
|
||||||
|
(defun comp-write-bytecode-file (eln-file)
|
||||||
|
"After native compilation write the bytecode file for ELN-FILE.
|
||||||
|
Make sure that eln file is younger than byte-compiled one and
|
||||||
|
return the filename of this last.
|
||||||
|
|
||||||
|
This function can be used only in conjuntion with
|
||||||
|
`byte+native-compile' `byte-to-native-output-buffer-file' (see
|
||||||
|
`batch-byte+native-compile')."
|
||||||
|
(pcase byte-to-native-output-buffer-file
|
||||||
|
(`(,temp-buffer . ,target-file)
|
||||||
|
(unwind-protect
|
||||||
|
(progn
|
||||||
|
(byte-write-target-file temp-buffer target-file)
|
||||||
|
;; Touch the .eln in order to have it older than the
|
||||||
|
;; corresponding .elc.
|
||||||
|
(when (stringp eln-file)
|
||||||
|
(set-file-times eln-file)))
|
||||||
|
(kill-buffer temp-buffer))
|
||||||
|
target-file)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun batch-byte+native-compile ()
|
(defun batch-byte+native-compile ()
|
||||||
"Like `batch-native-compile', but used for bootstrap.
|
"Like `batch-native-compile', but used for bootstrap.
|
||||||
|
@ -4333,16 +4353,7 @@ variable \"NATIVE_DISABLED\" is set, only byte compile."
|
||||||
(let* ((byte+native-compile t)
|
(let* ((byte+native-compile t)
|
||||||
(byte-to-native-output-buffer-file nil)
|
(byte-to-native-output-buffer-file nil)
|
||||||
(eln-file (car (batch-native-compile))))
|
(eln-file (car (batch-native-compile))))
|
||||||
(pcase byte-to-native-output-buffer-file
|
(comp-write-bytecode-file eln-file)
|
||||||
(`(,temp-buffer . ,target-file)
|
|
||||||
(unwind-protect
|
|
||||||
(progn
|
|
||||||
(byte-write-target-file temp-buffer target-file)
|
|
||||||
;; Touch the .eln in order to have it older than the
|
|
||||||
;; corresponding .elc.
|
|
||||||
(when (stringp eln-file)
|
|
||||||
(set-file-times eln-file)))
|
|
||||||
(kill-buffer temp-buffer))))
|
|
||||||
(setq command-line-args-left (cdr command-line-args-left)))))
|
(setq command-line-args-left (cdr command-line-args-left)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
|
@ -215,6 +215,8 @@ All commands in `lisp-mode-shared-map' are inherited by this map."
|
||||||
(load (byte-compile-dest-file buffer-file-name)))
|
(load (byte-compile-dest-file buffer-file-name)))
|
||||||
|
|
||||||
(declare-function native-compile "comp")
|
(declare-function native-compile "comp")
|
||||||
|
(declare-function comp-write-bytecode-file "comp")
|
||||||
|
|
||||||
(defun emacs-lisp-native-compile-and-load ()
|
(defun emacs-lisp-native-compile-and-load ()
|
||||||
"Native-compile synchronously the current file (if it has changed).
|
"Native-compile synchronously the current file (if it has changed).
|
||||||
Load the compiled code when finished.
|
Load the compiled code when finished.
|
||||||
|
@ -224,8 +226,10 @@ Use `emacs-lisp-byte-compile-and-load' in combination with
|
||||||
native compilation."
|
native compilation."
|
||||||
(interactive nil emacs-lisp-mode)
|
(interactive nil emacs-lisp-mode)
|
||||||
(emacs-lisp--before-compile-buffer)
|
(emacs-lisp--before-compile-buffer)
|
||||||
(when-let ((out (native-compile buffer-file-name)))
|
(let ((byte+native-compile t)
|
||||||
(load out)))
|
(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))))))
|
||||||
|
|
||||||
(defun emacs-lisp-macroexpand ()
|
(defun emacs-lisp-macroexpand ()
|
||||||
"Macroexpand the form after point.
|
"Macroexpand the form after point.
|
||||||
|
|
Loading…
Add table
Reference in a new issue