changeset 14116:5f985037b64f

(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.
author Karl Heuer <kwzh@gnu.org>
date Tue, 09 Jan 1996 23:19:05 +0000
parents bc30354daf1f
children 50df7ee940e8
files lisp/emacs-lisp/lisp-mode.el
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp-mode.el	Tue Jan 09 23:18:40 1996 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Tue Jan 09 23:19:05 1996 +0000
@@ -149,6 +149,8 @@
     (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 @@
   (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.