[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r102171: * lisp/emacs-lisp/bytecomp.e
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r102171: * lisp/emacs-lisp/bytecomp.el (byte-recompile-file): New fun. |
Date: |
Sun, 31 Oct 2010 15:25:39 -0400 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 102171
author: Julien Danjou <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sun 2010-10-31 15:25:39 -0400
message:
* lisp/emacs-lisp/bytecomp.el (byte-recompile-file): New fun.
(byte-recompile-directory):
* lisp/emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load):
* cedet/ede/proj-elisp.el (project-compile-target):
* cedet/semantic/ede-grammar.el (project-compile-target):
Use `byte-recompile-file'.
modified:
lisp/ChangeLog
lisp/cedet/ede/proj-elisp.el
lisp/cedet/semantic/ede-grammar.el
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/lisp-mode.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2010-10-31 18:38:16 +0000
+++ b/lisp/ChangeLog 2010-10-31 19:25:39 +0000
@@ -1,3 +1,12 @@
+2010-10-31 Julien Danjou <address@hidden>
+
+ * emacs-lisp/bytecomp.el (byte-recompile-file): New fun (bug#7297).
+ (byte-recompile-directory):
+ * emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load):
+ * cedet/ede/proj-elisp.el (project-compile-target):
+ * cedet/semantic/ede-grammar.el (project-compile-target):
+ Use `byte-recompile-file'.
+
2010-10-31 Glenn Morris <address@hidden>
* cus-start.el: Handle standard values via a keyword.
=== modified file 'lisp/cedet/ede/proj-elisp.el'
--- a/lisp/cedet/ede/proj-elisp.el 2010-09-21 02:42:53 +0000
+++ b/lisp/cedet/ede/proj-elisp.el 2010-10-31 19:25:39 +0000
@@ -131,11 +131,8 @@
(let* ((fsrc (expand-file-name src dir))
(elc (concat (file-name-sans-extension fsrc) ".elc"))
)
- (if (or (not (file-exists-p elc))
- (file-newer-than-file-p fsrc elc))
- (progn
- (setq comp (1+ comp))
- (byte-compile-file fsrc))
+ (if (eq (byte-recompile-file fsrc nil 0)) t)
+ (setq comp (1+ comp))
(setq utd (1+ utd)))))
(oref obj source))
(message "All Emacs Lisp sources are up to date in %s" (object-name obj))
=== modified file 'lisp/cedet/semantic/ede-grammar.el'
--- a/lisp/cedet/semantic/ede-grammar.el 2010-01-13 08:35:10 +0000
+++ b/lisp/cedet/semantic/ede-grammar.el 2010-10-31 19:25:39 +0000
@@ -133,10 +133,7 @@
(save-excursion
(semantic-grammar-create-package))
(save-buffer)
- (let ((cf (concat (semantic-grammar-package) ".el")))
- (if (or (not (file-exists-p cf))
- (file-newer-than-file-p src cf))
- (byte-compile-file cf)))))
+ (byte-recompile-file (concat (semantic-grammar-package) ".el")
nil 0))
(oref obj source)))
(message "All Semantic Grammar sources are up to date in %s" (object-name
obj)))
=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- a/lisp/emacs-lisp/bytecomp.el 2010-10-03 04:31:59 +0000
+++ b/lisp/emacs-lisp/bytecomp.el 2010-10-31 19:25:39 +0000
@@ -37,6 +37,7 @@
;; ========================================================================
;; Entry points:
;; byte-recompile-directory, byte-compile-file,
+;; byte-recompile-file,
;; batch-byte-compile, batch-byte-recompile-directory,
;; byte-compile, compile-defun,
;; display-call-tree
@@ -1551,23 +1552,10 @@
(not (auto-save-file-name-p bytecomp-source))
(not (string-equal dir-locals-file
(file-name-nondirectory
- bytecomp-source)))
- (setq bytecomp-dest
- (byte-compile-dest-file bytecomp-source))
- (if (file-exists-p bytecomp-dest)
- ;; File was already compiled.
- (or bytecomp-force
- (file-newer-than-file-p bytecomp-source
- bytecomp-dest))
- ;; No compiled file exists yet.
- (and bytecomp-arg
- (or (eq 0 bytecomp-arg)
- (y-or-n-p (concat "Compile "
- bytecomp-source "? "))))))
- (progn (if (and noninteractive (not byte-compile-verbose))
- (message "Compiling %s..." bytecomp-source))
- (let ((bytecomp-res (byte-compile-file
- bytecomp-source)))
+ bytecomp-source))))
+ (progn (let ((bytecomp-res (byte-recompile-file
+ bytecomp-source
+ bytecomp-force bytecomp-arg)))
(cond ((eq bytecomp-res 'no-byte-compile)
(setq skip-count (1+ skip-count)))
((eq bytecomp-res t)
@@ -1595,6 +1583,59 @@
;; Local Variables:\n;; no-byte-compile: t\n;; End: ")
;;;###autoload(put 'no-byte-compile 'safe-local-variable 'booleanp)
+(defun byte-recompile-file (bytecomp-filename &optional bytecomp-force
bytecomp-arg load)
+ "Recompile BYTECOMP-FILENAME file if it needs recompilation.
+This happens when its `.elc' file is older than itself.
+
+If the `.elc' file exists and is up-to-date, normally this
+function *does not* compile BYTECOMP-FILENAME. However, if the
+prefix argument BYTECOMP-FORCE is set, that means do compile
+BYTECOMP-FILENAME even if the destination already exists and is
+up-to-date.
+
+If the `.elc' file does not exist, normally this function *does
+not* compile BYTECOMP-FILENAME. If BYTECOMP-ARG is 0, that means
+compile the file even if it has never been compiled before.
+A nonzero BYTECOMP-ARG means ask the user.
+
+If LOAD is set, `load' the file after compiling.
+
+The value returned is the value returned by `byte-compile-file',
+or 'no-byte-compile if the file did not need recompilation."
+ (interactive
+ (let ((bytecomp-file buffer-file-name)
+ (bytecomp-file-name nil)
+ (bytecomp-file-dir nil))
+ (and bytecomp-file
+ (eq (cdr (assq 'major-mode (buffer-local-variables)))
+ 'emacs-lisp-mode)
+ (setq bytecomp-file-name (file-name-nondirectory bytecomp-file)
+ bytecomp-file-dir (file-name-directory bytecomp-file)))
+ (list (read-file-name (if current-prefix-arg
+ "Byte compile file: "
+ "Byte recompile file: ")
+ bytecomp-file-dir bytecomp-file-name nil)
+ current-prefix-arg)))
+ (let ((bytecomp-dest
+ (byte-compile-dest-file bytecomp-filename))
+ ;; Expand now so we get the current buffer's defaults
+ (bytecomp-filename (expand-file-name bytecomp-filename)))
+ (if (if (file-exists-p bytecomp-dest)
+ ;; File was already compiled
+ ;; Compile if forced to, or filename newer
+ (or bytecomp-force
+ (file-newer-than-file-p bytecomp-filename
+ bytecomp-dest))
+ (or (eq 0 bytecomp-arg)
+ (y-or-n-p (concat "Compile "
+ bytecomp-filename "? "))))
+ (progn
+ (if (and noninteractive (not byte-compile-verbose))
+ (message "Compiling %s..." bytecomp-source))
+ (byte-compile-file bytecomp-filename load))
+ (when load (load bytecomp-filename))
+ 'no-byte-compile)))
+
;;;###autoload
(defun byte-compile-file (bytecomp-filename &optional load)
"Compile a file of Lisp code named BYTECOMP-FILENAME into a file of byte
code.
=== modified file 'lisp/emacs-lisp/lisp-mode.el'
--- a/lisp/emacs-lisp/lisp-mode.el 2010-08-30 13:03:05 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el 2010-10-31 19:25:39 +0000
@@ -407,10 +407,7 @@
(if (and (buffer-modified-p)
(y-or-n-p (format "Save buffer %s first? " (buffer-name))))
(save-buffer))
- (let ((compiled-file-name (byte-compile-dest-file buffer-file-name)))
- (if (file-newer-than-file-p compiled-file-name buffer-file-name)
- (load-file compiled-file-name)
- (byte-compile-file buffer-file-name t))))
+ (byte-recompile-file buffer-file-name nil 0 t))
(defcustom emacs-lisp-mode-hook nil
"Hook run when entering Emacs Lisp mode."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r102171: * lisp/emacs-lisp/bytecomp.el (byte-recompile-file): New fun.,
Stefan Monnier <=