else
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
(defun batch-byte+native-compile ()
"Like `batch-native-compile', but used for bootstrap.
(let* ((byte+native-compile t)
(byte-to-native-output-buffer-file nil)
(eln-file (car (batch-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))))
+ (comp-write-bytecode-file eln-file)
(setq command-line-args-left (cdr command-line-args-left)))))
;;;###autoload
(load (byte-compile-dest-file buffer-file-name)))
(declare-function native-compile "comp")
+(declare-function comp-write-bytecode-file "comp")
+
(defun emacs-lisp-native-compile-and-load ()
"Native-compile synchronously the current file (if it has changed).
Load the compiled code when finished.
native compilation."
(interactive nil emacs-lisp-mode)
(emacs-lisp--before-compile-buffer)
- (when-let ((out (native-compile buffer-file-name)))
- (load out)))
+ (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))))))
(defun emacs-lisp-macroexpand ()
"Macroexpand the form after point.