From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Julien Danjou Newsgroups: gmane.emacs.devel Subject: [PATCH] Split byte-recompile-directory into byte-recompile-file Date: Sun, 26 Sep 2010 10:03:53 +0200 Message-ID: <1285488233-9954-1-git-send-email-julien@danjou.info> References: NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1285488283 17654 80.91.229.12 (26 Sep 2010 08:04:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 26 Sep 2010 08:04:43 +0000 (UTC) Cc: Julien Danjou To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 26 10:04:41 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OzmDx-0002rP-3I for ged-emacs-devel@m.gmane.org; Sun, 26 Sep 2010 10:04:41 +0200 Original-Received: from localhost ([127.0.0.1]:37924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OzmDw-0006Pw-CJ for ged-emacs-devel@m.gmane.org; Sun, 26 Sep 2010 04:04:40 -0400 Original-Received: from [140.186.70.92] (port=60143 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OzmDY-0006Pi-Ok for emacs-devel@gnu.org; Sun, 26 Sep 2010 04:04:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OzmDX-0004Ta-3G for emacs-devel@gnu.org; Sun, 26 Sep 2010 04:04:16 -0400 Original-Received: from prometheus.naquadah.org ([212.85.154.174]:46220 helo=mx1.naquadah.org) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OzmDW-0004TK-Oq for emacs-devel@gnu.org; Sun, 26 Sep 2010 04:04:15 -0400 Original-Received: by mx1.naquadah.org (Postfix, from userid 8) id BA2115C0FA; Sun, 26 Sep 2010 10:04:12 +0200 (CEST) Original-Received: from keller.adm.naquadah.org (unknown [IPv6:2a01:e35:2e39:e900:222:faff:fe9d:ce44]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.naquadah.org (Postfix) with ESMTPSA id 90BE35C06A; Sun, 26 Sep 2010 10:04:10 +0200 (CEST) Original-Received: from jd by keller.adm.naquadah.org with local (Exim 4.72) (envelope-from ) id 1OzmDR-0002cv-Vo; Sun, 26 Sep 2010 10:04:09 +0200 X-Mailer: git-send-email 1.7.1 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130900 Archived-At: Signed-off-by: Julien Danjou --- 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 + + * emacs-lisp/bytecomp.el (byte-recompile-file): Add this function. + (byte-recompile-directory): Use `byte-recompile-file'. + 2010-09-25 Julien Danjou * 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