]> code.delx.au - gnu-emacs/commitdiff
(emacs-lisp-byte-compile): Fix error message.
authorKarl Heuer <kwzh@gnu.org>
Tue, 9 Jan 1996 23:19:05 +0000 (23:19 +0000)
committerKarl Heuer <kwzh@gnu.org>
Tue, 9 Jan 1996 23:19:05 +0000 (23:19 +0000)
(emacs-lisp-compile-and-load): New function.
(emacs-lisp-mode-map): Add emacs-lisp-compile-and-load to menu bar.

lisp/emacs-lisp/lisp-mode.el

index 29ca7ecc4c36092e4b54552f8cb195aa42924c96..453ccfcb264156cfb4ec3092a65303843f0b70bb 100644 (file)
@@ -148,6 +148,8 @@ All commands in `shared-lisp-mode-map' are inherited by this map.")
       '("Instrument Function for Debugging" . edebug-defun))
     (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] '("--"))
@@ -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.