summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1996-01-09 23:19:05 +0000
committerKarl Heuer <kwzh@gnu.org>1996-01-09 23:19:05 +0000
commit767a11517eddccf7125e1e4a89c1cec187300db8 (patch)
tree0278eeea24d9f0d831af5062c970afe951eb8a83 /lisp/emacs-lisp
parent9a71dcfd6de8329e96fa0c756f0f3a632286f9f1 (diff)
downloademacs-767a11517eddccf7125e1e4a89c1cec187300db8.tar.gz
emacs-767a11517eddccf7125e1e4a89c1cec187300db8.tar.bz2
emacs-767a11517eddccf7125e1e4a89c1cec187300db8.zip
(emacs-lisp-byte-compile): Fix error message.
(emacs-lisp-compile-and-load): New function. (emacs-lisp-mode-map): Add emacs-lisp-compile-and-load to menu bar.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el17
1 files changed, 16 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 29ca7ecc4c3..453ccfcb264 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -149,6 +149,8 @@ All commands in `shared-lisp-mode-map' are inherited by this map.")
(define-key map [byte-recompile]
'("Byte-recompile Directory..." . byte-recompile-directory))
(define-key map [byte-compile]
+ '("Byte-compile And Load" . emacs-lisp-compile-and-load))
+ (define-key map [byte-compile]
'("Byte-compile This File" . emacs-lisp-byte-compile))
(define-key map [separator-eval] '("--"))
(define-key map [eval-buffer] '("Evaluate Buffer" . eval-current-buffer))
@@ -167,7 +169,20 @@ All commands in `shared-lisp-mode-map' are inherited by this map.")
(interactive)
(if buffer-file-name
(byte-compile-file buffer-file-name)
- (error "The buffer must be saved in a file first.")))
+ (error "The buffer must be saved in a file first")))
+
+(defun emacs-lisp-compile-and-load ()
+ "Byte-compile the current file (if it has changed), then load compiled code."
+ (interactive)
+ (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.
+ (or (buffer-modified-p)
+ (file-newer-than-file-p (byte-compile-dest-file buffer-file-name)
+ buffer-file-name)
+ (byte-compile-file buffer-file-name))
+ (load-file (byte-compile-dest-file buffer-file-name)))
(defun emacs-lisp-mode ()
"Major mode for editing Lisp code to run in Emacs.