comparison lisp/emacs-lisp/lisp-mode.el @ 14719:d477c6f756df

Save if reqd in emacs-lisp-byte-compile-and-load.
author Simon Marshall <simon@gnu.org>
date Thu, 29 Feb 1996 08:19:46 +0000
parents c932ad13ccd9
children 20f4c4a078b2
comparison
equal deleted inserted replaced
14718:cb80e4399021 14719:d477c6f756df
153 (define-key map [edebug-defun] 153 (define-key map [edebug-defun]
154 '("Instrument Function for Debugging" . edebug-defun)) 154 '("Instrument Function for Debugging" . edebug-defun))
155 (define-key map [byte-recompile] 155 (define-key map [byte-recompile]
156 '("Byte-recompile Directory..." . byte-recompile-directory)) 156 '("Byte-recompile Directory..." . byte-recompile-directory))
157 (define-key map [emacs-byte-compile-and-load] 157 (define-key map [emacs-byte-compile-and-load]
158 '("Byte-compile And Load" . emacs-lisp-compile-and-load)) 158 '("Byte-compile And Load" . emacs-lisp-byte-compile-and-load))
159 (define-key map [byte-compile] 159 (define-key map [byte-compile]
160 '("Byte-compile This File" . emacs-lisp-byte-compile)) 160 '("Byte-compile This File" . emacs-lisp-byte-compile))
161 (define-key map [separator-eval] '("--")) 161 (define-key map [separator-eval] '("--"))
162 (define-key map [eval-buffer] '("Evaluate Buffer" . eval-current-buffer)) 162 (define-key map [eval-buffer] '("Evaluate Buffer" . eval-current-buffer))
163 (define-key map [eval-region] '("Evaluate Region" . eval-region)) 163 (define-key map [eval-region] '("Evaluate Region" . eval-region))
175 (interactive) 175 (interactive)
176 (if buffer-file-name 176 (if buffer-file-name
177 (byte-compile-file buffer-file-name) 177 (byte-compile-file buffer-file-name)
178 (error "The buffer must be saved in a file first"))) 178 (error "The buffer must be saved in a file first")))
179 179
180 (defun emacs-lisp-compile-and-load () 180 (defun emacs-lisp-byte-compile-and-load ()
181 "Byte-compile the current file (if it has changed), then load compiled code." 181 "Byte-compile the current file (if it has changed), then load compiled code."
182 (interactive) 182 (interactive)
183 (or buffer-file-name 183 (or buffer-file-name
184 (error "The buffer must be saved in a file first")) 184 (error "The buffer must be saved in a file first"))
185 (require 'bytecomp) 185 (require 'bytecomp)
186 ;; Recompile if file or buffer has changed since last compilation. 186 ;; Recompile if file or buffer has changed since last compilation.
187 (or (buffer-modified-p) 187 (if (and (buffer-modified-p)
188 (file-newer-than-file-p (byte-compile-dest-file buffer-file-name) 188 (y-or-n-p (format "save buffer %s first? " (buffer-name))))
189 buffer-file-name) 189 (save-buffer))
190 (byte-compile-file buffer-file-name)) 190 (let ((compiled-file-name (byte-compile-dest-file buffer-file-name)))
191 (load-file (byte-compile-dest-file buffer-file-name))) 191 (if (file-newer-than-file-p compiled-file-name buffer-file-name)
192 (load-file compiled-file-name)
193 (byte-compile-file buffer-file-name t))))
192 194
193 (defun emacs-lisp-mode () 195 (defun emacs-lisp-mode ()
194 "Major mode for editing Lisp code to run in Emacs. 196 "Major mode for editing Lisp code to run in Emacs.
195 Commands: 197 Commands:
196 Delete converts tabs to spaces as it moves back. 198 Delete converts tabs to spaces as it moves back.