diff options
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/cc-bytecomp.el | 11 | ||||
-rw-r--r-- | lisp/progmodes/cc-langs.el | 3 | ||||
-rw-r--r-- | lisp/progmodes/elisp-mode.el | 26 |
3 files changed, 31 insertions, 9 deletions
diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el index 3f7caf3c2e9..89ea1dca3b0 100644 --- a/lisp/progmodes/cc-bytecomp.el +++ b/lisp/progmodes/cc-bytecomp.el @@ -97,6 +97,8 @@ ;; compilation can trigger loading (various `require' type forms) ;; and loading can trigger compilation (the package manager does ;; this). We walk the lisp stack if necessary. + ;; Never native compile to allow cc-defs.el:2345 hack. + (declare (speed -1)) (cond ((and load-in-progress (boundp 'byte-compile-dest-file) @@ -108,14 +110,15 @@ (memq (cadr elt) '(load require byte-compile-file byte-recompile-directory - batch-byte-compile))))) + batch-byte-compile batch-native-compile))))) (setq n (1+ n))) (cond ((memq (cadr elt) '(load require)) 'loading) ((memq (cadr elt) '(byte-compile-file byte-recompile-directory - batch-byte-compile)) + batch-byte-compile + batch-native-compile)) 'compiling) (t ; Can't happen. (message "cc-bytecomp-compiling-or-loading: System flags spuriously set") @@ -284,7 +287,9 @@ perhaps a `cc-bytecomp-restore-environment' is forgotten somewhere")) (cons cc-file cc-bytecomp-loaded-files)) (cc-bytecomp-debug-msg "cc-bytecomp-load: Loading %S" cc-file) - (load cc-file nil t t) + ;; native-comp may async compile also intalled el.gz + ;; files therefore we may have to load here other el.gz. + (load cc-part nil t) (cc-bytecomp-debug-msg "cc-bytecomp-load: Loaded %S" cc-file))) (cc-bytecomp-setup-environment) diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 07479389c62..1938cc8ff1e 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -337,7 +337,8 @@ the evaluated constant value at compile time." This includes setting \\=' and \" as string delimiters, and setting up the comment syntax to handle both line style \"//\" and block style \"/*\" \"*/\" comments." - + ;; Never native compile to allow cc-mode.el:467 hack. + (declare (speed -1)) (modify-syntax-entry ?_ "_" table) (modify-syntax-entry ?\\ "\\" table) (modify-syntax-entry ?+ "." table) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 397eb269a71..2dd2702acb7 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -187,19 +187,35 @@ 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)) +(declare-function native-compile "comp") +(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." |