* [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file
@ 2010-09-21 15:26 Julien Danjou
2010-09-21 15:26 ` [PATCH 2/4] Use byte-recompile-file in emacs-lisp-byte-compile-and-load Julien Danjou
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Julien Danjou @ 2010-09-21 15:26 UTC (permalink / raw)
To: emacs-devel; +Cc: Julien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lisp/ChangeLog | 5 +++
lisp/emacs-lisp/bytecomp.el | 75 +++++++++++++++++++++++++++++++++----------
2 files changed, 63 insertions(+), 17 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3111ade..34a1dfd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-21 Julien Danjou <julien@danjou.info>
+
+ * emacs-lisp/bytecomp.el (byte-recompile-file): Add this function.
+ (byte-recompile-directory): Use `byte-recompile-file'.
+
2010-09-21 Michael Albinus <michael.albinus@gmx.de>
* net/ange-ftp.el (ange-ftp-skip-msgs): Add "^504 ..." message.
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index aca3a54..e6f55e1 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -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 @@ that already has a `.elc' file."
(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 @@ This is normally set in local file variables at the end of the elisp file:
;; 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.
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] Use byte-recompile-file in emacs-lisp-byte-compile-and-load
2010-09-21 15:26 [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Julien Danjou
@ 2010-09-21 15:26 ` Julien Danjou
2010-09-21 15:26 ` [PATCH 3/4] Use byte-recompile-file in cedet/project-compile-target Julien Danjou
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Julien Danjou @ 2010-09-21 15:26 UTC (permalink / raw)
To: emacs-devel; +Cc: Julien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lisp/ChangeLog | 3 +++
lisp/emacs-lisp/lisp-mode.el | 5 +----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 34a1dfd..175286b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
2010-09-21 Julien Danjou <julien@danjou.info>
+ * emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load): Use
+ `byte-recompile-file'.
+
* emacs-lisp/bytecomp.el (byte-recompile-file): Add this function.
(byte-recompile-directory): Use `byte-recompile-file'.
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index e4330e4..ef639d6 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.")
(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."
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] Use byte-recompile-file in cedet/project-compile-target
2010-09-21 15:26 [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Julien Danjou
2010-09-21 15:26 ` [PATCH 2/4] Use byte-recompile-file in emacs-lisp-byte-compile-and-load Julien Danjou
@ 2010-09-21 15:26 ` Julien Danjou
2010-09-21 15:26 ` [PATCH 4/4] (project-compile-target) use byte-recompile-file Julien Danjou
2010-09-25 21:35 ` [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Stefan Monnier
3 siblings, 0 replies; 9+ messages in thread
From: Julien Danjou @ 2010-09-21 15:26 UTC (permalink / raw)
To: emacs-devel; +Cc: Julien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lisp/ChangeLog | 2 ++
lisp/cedet/semantic/ede-grammar.el | 5 +----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 175286b..4f0aaac 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
2010-09-21 Julien Danjou <julien@danjou.info>
+ * cedet/semantic/ede-grammar.el: Use `byte-recompile-file'.
+
* emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load): Use
`byte-recompile-file'.
diff --git a/lisp/cedet/semantic/ede-grammar.el b/lisp/cedet/semantic/ede-grammar.el
index 184e23c..ac99588 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."
(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)))
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] (project-compile-target) use byte-recompile-file
2010-09-21 15:26 [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Julien Danjou
2010-09-21 15:26 ` [PATCH 2/4] Use byte-recompile-file in emacs-lisp-byte-compile-and-load Julien Danjou
2010-09-21 15:26 ` [PATCH 3/4] Use byte-recompile-file in cedet/project-compile-target Julien Danjou
@ 2010-09-21 15:26 ` Julien Danjou
2010-09-25 21:35 ` [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Stefan Monnier
3 siblings, 0 replies; 9+ messages in thread
From: Julien Danjou @ 2010-09-21 15:26 UTC (permalink / raw)
To: emacs-devel; +Cc: Julien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lisp/ChangeLog | 3 +++
lisp/cedet/ede/proj-elisp.el | 7 ++-----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4f0aaac..d96fafc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
2010-09-21 Julien Danjou <julien@danjou.info>
+ * cedet/ede/proj-elisp.el (project-compile-target): Use
+ `byte-recompile-file'.
+
* cedet/semantic/ede-grammar.el: Use `byte-recompile-file'.
* emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load): Use
diff --git a/lisp/cedet/ede/proj-elisp.el b/lisp/cedet/ede/proj-elisp.el
index ecdefb2..21322df 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)."
(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))
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file
2010-09-21 15:26 [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Julien Danjou
` (2 preceding siblings ...)
2010-09-21 15:26 ` [PATCH 4/4] (project-compile-target) use byte-recompile-file Julien Danjou
@ 2010-09-25 21:35 ` Stefan Monnier
2010-09-26 8:03 ` [PATCH] " Julien Danjou
3 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2010-09-25 21:35 UTC (permalink / raw)
To: Julien Danjou; +Cc: emacs-devel
Introducing byte-recompile-file doesn't sound like a bad idea, but I'm
not sure that function needs to be nearly as complex.
How 'bout changing the code you sent so that the new byte-compile-file
is not interactive any more and provides barely more than the code you
extract from byte-recompile-directory?
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Split byte-recompile-directory into byte-recompile-file
2010-09-25 21:35 ` [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Stefan Monnier
@ 2010-09-26 8:03 ` Julien Danjou
2010-10-02 13:48 ` Julien Danjou
0 siblings, 1 reply; 9+ messages in thread
From: Julien Danjou @ 2010-09-26 8:03 UTC (permalink / raw)
To: emacs-devel; +Cc: Julien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lisp/ChangeLog | 5 +++
lisp/emacs-lisp/bytecomp.el | 63 ++++++++++++++++++++++++++++++------------
2 files changed, 50 insertions(+), 18 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bfbb0de..69330aa 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-26 Julien Danjou <julien@danjou.info>
+
+ * emacs-lisp/bytecomp.el (byte-recompile-file): Add this function.
+ (byte-recompile-directory): Use `byte-recompile-file'.
+
2010-09-25 Julien Danjou <julien@danjou.info>
* notifications.el: Call dbus-register-signal only if the function
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e6ca7f6..3117214 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -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
@@ -1531,7 +1532,7 @@ that already has a `.elc' file."
(setq bytecomp-directory (car bytecomp-directories))
(message "Checking %s..." bytecomp-directory)
(let ((bytecomp-files (directory-files bytecomp-directory))
- bytecomp-source bytecomp-dest)
+ bytecomp-source)
(dolist (bytecomp-file bytecomp-files)
(setq bytecomp-source
(expand-file-name bytecomp-file bytecomp-directory))
@@ -1551,23 +1552,10 @@ that already has a `.elc' file."
(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,45 @@ This is normally set in local file variables at the end of the elisp file:
;; 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."
+ (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 if
+ ;; `bytecomp-filename' is newer than `bytecomp-dest'.
+ (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.
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Split byte-recompile-directory into byte-recompile-file
2010-09-26 8:03 ` [PATCH] " Julien Danjou
@ 2010-10-02 13:48 ` Julien Danjou
2010-10-08 9:16 ` Julien Danjou
0 siblings, 1 reply; 9+ messages in thread
From: Julien Danjou @ 2010-10-02 13:48 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 110 bytes --]
Stefan, any update on this?
--
Julien Danjou
// ᐰ <julien@danjou.info> http://julien.danjou.info
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Split byte-recompile-directory into byte-recompile-file
2010-10-02 13:48 ` Julien Danjou
@ 2010-10-08 9:16 ` Julien Danjou
2010-10-21 10:31 ` Julien Danjou
0 siblings, 1 reply; 9+ messages in thread
From: Julien Danjou @ 2010-10-08 9:16 UTC (permalink / raw)
To: emacs-devel; +Cc: Stefan Monnier
[-- Attachment #1: Type: text/plain, Size: 187 bytes --]
On Sat, Oct 02 2010, Julien Danjou wrote:
> Stefan, any update on this?
May I dare ask once more? :)
--
Julien Danjou
// ᐰ <julien@danjou.info> http://julien.danjou.info
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Split byte-recompile-directory into byte-recompile-file
2010-10-08 9:16 ` Julien Danjou
@ 2010-10-21 10:31 ` Julien Danjou
0 siblings, 0 replies; 9+ messages in thread
From: Julien Danjou @ 2010-10-21 10:31 UTC (permalink / raw)
To: emacs-devel
On Fri, Oct 08 2010, Julien Danjou wrote:
> May I dare ask once more? :)
A last one. :-)
--
Julien Danjou
// ᐰ <julien@danjou.info> http://julien.danjou.info
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-10-21 10:31 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-21 15:26 [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Julien Danjou
2010-09-21 15:26 ` [PATCH 2/4] Use byte-recompile-file in emacs-lisp-byte-compile-and-load Julien Danjou
2010-09-21 15:26 ` [PATCH 3/4] Use byte-recompile-file in cedet/project-compile-target Julien Danjou
2010-09-21 15:26 ` [PATCH 4/4] (project-compile-target) use byte-recompile-file Julien Danjou
2010-09-25 21:35 ` [PATCH 1/4] Split byte-recompile-directory into byte-recompile-file Stefan Monnier
2010-09-26 8:03 ` [PATCH] " Julien Danjou
2010-10-02 13:48 ` Julien Danjou
2010-10-08 9:16 ` Julien Danjou
2010-10-21 10:31 ` Julien Danjou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).