aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Danjou2010-10-31 15:25:39 -0400
committerStefan Monnier2010-10-31 15:25:39 -0400
commit430e7297cbfe8c2ef14b5b703fc56c4efce439c0 (patch)
treefcc163bfd3912819412ef0b6c40af444329fc1d5
parentf486841f693606fff8f40a47f9d1a5afcf0a343d (diff)
downloademacs-430e7297cbfe8c2ef14b5b703fc56c4efce439c0.tar.gz
emacs-430e7297cbfe8c2ef14b5b703fc56c4efce439c0.zip
* 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'. Fixes: debbugs:7297
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/cedet/ede/proj-elisp.el7
-rw-r--r--lisp/cedet/semantic/ede-grammar.el5
-rw-r--r--lisp/emacs-lisp/bytecomp.el75
-rw-r--r--lisp/emacs-lisp/lisp-mode.el5
5 files changed, 71 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 018e7da2a83..5c544c7553a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12010-10-31 Julien Danjou <julien@danjou.info>
2
3 * emacs-lisp/bytecomp.el (byte-recompile-file): New fun (bug#7297).
4 (byte-recompile-directory):
5 * emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load):
6 * cedet/ede/proj-elisp.el (project-compile-target):
7 * cedet/semantic/ede-grammar.el (project-compile-target):
8 Use `byte-recompile-file'.
9
12010-10-31 Glenn Morris <rgm@gnu.org> 102010-10-31 Glenn Morris <rgm@gnu.org>
2 11
3 * cus-start.el: Handle standard values via a keyword. 12 * cus-start.el: Handle standard values via a keyword.
diff --git a/lisp/cedet/ede/proj-elisp.el b/lisp/cedet/ede/proj-elisp.el
index 879f36ff4e2..bc5934c7e26 100644
--- a/lisp/cedet/ede/proj-elisp.el
+++ b/lisp/cedet/ede/proj-elisp.el
@@ -131,11 +131,8 @@ Bonus: Return a cons cell: (COMPILED . UPTODATE)."
131 (let* ((fsrc (expand-file-name src dir)) 131 (let* ((fsrc (expand-file-name src dir))
132 (elc (concat (file-name-sans-extension fsrc) ".elc")) 132 (elc (concat (file-name-sans-extension fsrc) ".elc"))
133 ) 133 )
134 (if (or (not (file-exists-p elc)) 134 (if (eq (byte-recompile-file fsrc nil 0)) t)
135 (file-newer-than-file-p fsrc elc)) 135 (setq comp (1+ comp))
136 (progn
137 (setq comp (1+ comp))
138 (byte-compile-file fsrc))
139 (setq utd (1+ utd))))) 136 (setq utd (1+ utd)))))
140 (oref obj source)) 137 (oref obj source))
141 (message "All Emacs Lisp sources are up to date in %s" (object-name obj)) 138 (message "All Emacs Lisp sources are up to date in %s" (object-name obj))
diff --git a/lisp/cedet/semantic/ede-grammar.el b/lisp/cedet/semantic/ede-grammar.el
index 184e23c9505..ac995884d54 100644
--- a/lisp/cedet/semantic/ede-grammar.el
+++ b/lisp/cedet/semantic/ede-grammar.el
@@ -133,10 +133,7 @@ Lays claim to all -by.el, and -wy.el files."
133 (save-excursion 133 (save-excursion
134 (semantic-grammar-create-package)) 134 (semantic-grammar-create-package))
135 (save-buffer) 135 (save-buffer)
136 (let ((cf (concat (semantic-grammar-package) ".el"))) 136 (byte-recompile-file (concat (semantic-grammar-package) ".el") nil 0))
137 (if (or (not (file-exists-p cf))
138 (file-newer-than-file-p src cf))
139 (byte-compile-file cf)))))
140 (oref obj source))) 137 (oref obj source)))
141 (message "All Semantic Grammar sources are up to date in %s" (object-name obj))) 138 (message "All Semantic Grammar sources are up to date in %s" (object-name obj)))
142 139
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index b3ac7b83d79..5afe49346b5 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -37,6 +37,7 @@
37;; ======================================================================== 37;; ========================================================================
38;; Entry points: 38;; Entry points:
39;; byte-recompile-directory, byte-compile-file, 39;; byte-recompile-directory, byte-compile-file,
40;; byte-recompile-file,
40;; batch-byte-compile, batch-byte-recompile-directory, 41;; batch-byte-compile, batch-byte-recompile-directory,
41;; byte-compile, compile-defun, 42;; byte-compile, compile-defun,
42;; display-call-tree 43;; display-call-tree
@@ -1551,23 +1552,10 @@ that already has a `.elc' file."
1551 (not (auto-save-file-name-p bytecomp-source)) 1552 (not (auto-save-file-name-p bytecomp-source))
1552 (not (string-equal dir-locals-file 1553 (not (string-equal dir-locals-file
1553 (file-name-nondirectory 1554 (file-name-nondirectory
1554 bytecomp-source))) 1555 bytecomp-source))))
1555 (setq bytecomp-dest 1556 (progn (let ((bytecomp-res (byte-recompile-file
1556 (byte-compile-dest-file bytecomp-source)) 1557 bytecomp-source
1557 (if (file-exists-p bytecomp-dest) 1558 bytecomp-force bytecomp-arg)))
1558 ;; File was already compiled.
1559 (or bytecomp-force
1560 (file-newer-than-file-p bytecomp-source
1561 bytecomp-dest))
1562 ;; No compiled file exists yet.
1563 (and bytecomp-arg
1564 (or (eq 0 bytecomp-arg)
1565 (y-or-n-p (concat "Compile "
1566 bytecomp-source "? "))))))
1567 (progn (if (and noninteractive (not byte-compile-verbose))
1568 (message "Compiling %s..." bytecomp-source))
1569 (let ((bytecomp-res (byte-compile-file
1570 bytecomp-source)))
1571 (cond ((eq bytecomp-res 'no-byte-compile) 1559 (cond ((eq bytecomp-res 'no-byte-compile)
1572 (setq skip-count (1+ skip-count))) 1560 (setq skip-count (1+ skip-count)))
1573 ((eq bytecomp-res t) 1561 ((eq bytecomp-res t)
@@ -1595,6 +1583,59 @@ This is normally set in local file variables at the end of the elisp file:
1595;; Local Variables:\n;; no-byte-compile: t\n;; End: ") 1583;; Local Variables:\n;; no-byte-compile: t\n;; End: ")
1596;;;###autoload(put 'no-byte-compile 'safe-local-variable 'booleanp) 1584;;;###autoload(put 'no-byte-compile 'safe-local-variable 'booleanp)
1597 1585
1586(defun byte-recompile-file (bytecomp-filename &optional bytecomp-force bytecomp-arg load)
1587 "Recompile BYTECOMP-FILENAME file if it needs recompilation.
1588This happens when its `.elc' file is older than itself.
1589
1590If the `.elc' file exists and is up-to-date, normally this
1591function *does not* compile BYTECOMP-FILENAME. However, if the
1592prefix argument BYTECOMP-FORCE is set, that means do compile
1593BYTECOMP-FILENAME even if the destination already exists and is
1594up-to-date.
1595
1596If the `.elc' file does not exist, normally this function *does
1597not* compile BYTECOMP-FILENAME. If BYTECOMP-ARG is 0, that means
1598compile the file even if it has never been compiled before.
1599A nonzero BYTECOMP-ARG means ask the user.
1600
1601If LOAD is set, `load' the file after compiling.
1602
1603The value returned is the value returned by `byte-compile-file',
1604or 'no-byte-compile if the file did not need recompilation."
1605 (interactive
1606 (let ((bytecomp-file buffer-file-name)
1607 (bytecomp-file-name nil)
1608 (bytecomp-file-dir nil))
1609 (and bytecomp-file
1610 (eq (cdr (assq 'major-mode (buffer-local-variables)))
1611 'emacs-lisp-mode)
1612 (setq bytecomp-file-name (file-name-nondirectory bytecomp-file)
1613 bytecomp-file-dir (file-name-directory bytecomp-file)))
1614 (list (read-file-name (if current-prefix-arg
1615 "Byte compile file: "
1616 "Byte recompile file: ")
1617 bytecomp-file-dir bytecomp-file-name nil)
1618 current-prefix-arg)))
1619 (let ((bytecomp-dest
1620 (byte-compile-dest-file bytecomp-filename))
1621 ;; Expand now so we get the current buffer's defaults
1622 (bytecomp-filename (expand-file-name bytecomp-filename)))
1623 (if (if (file-exists-p bytecomp-dest)
1624 ;; File was already compiled
1625 ;; Compile if forced to, or filename newer
1626 (or bytecomp-force
1627 (file-newer-than-file-p bytecomp-filename
1628 bytecomp-dest))
1629 (or (eq 0 bytecomp-arg)
1630 (y-or-n-p (concat "Compile "
1631 bytecomp-filename "? "))))
1632 (progn
1633 (if (and noninteractive (not byte-compile-verbose))
1634 (message "Compiling %s..." bytecomp-source))
1635 (byte-compile-file bytecomp-filename load))
1636 (when load (load bytecomp-filename))
1637 'no-byte-compile)))
1638
1598;;;###autoload 1639;;;###autoload
1599(defun byte-compile-file (bytecomp-filename &optional load) 1640(defun byte-compile-file (bytecomp-filename &optional load)
1600 "Compile a file of Lisp code named BYTECOMP-FILENAME into a file of byte code. 1641 "Compile a file of Lisp code named BYTECOMP-FILENAME into a file of byte code.
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index e4330e43fc9..ef639d6ec37 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -407,10 +407,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map.")
407 (if (and (buffer-modified-p) 407 (if (and (buffer-modified-p)
408 (y-or-n-p (format "Save buffer %s first? " (buffer-name)))) 408 (y-or-n-p (format "Save buffer %s first? " (buffer-name))))
409 (save-buffer)) 409 (save-buffer))
410 (let ((compiled-file-name (byte-compile-dest-file buffer-file-name))) 410 (byte-recompile-file buffer-file-name nil 0 t))
411 (if (file-newer-than-file-p compiled-file-name buffer-file-name)
412 (load-file compiled-file-name)
413 (byte-compile-file buffer-file-name t))))
414 411
415(defcustom emacs-lisp-mode-hook nil 412(defcustom emacs-lisp-mode-hook nil
416 "Hook run when entering Emacs Lisp mode." 413 "Hook run when entering Emacs Lisp mode."