From d0cc713b2150ccf7d5c31756438a42a3f106e7bd Mon Sep 17 00:00:00 2001 From: Nikolay Kudryavtsev Date: Sat, 7 Jan 2017 13:05:24 +0300 Subject: [PATCH] Prevent package-install from asking to save buffers * lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): New argument `limit-buffer-saving' that limits `save-some-buffers' to the chosen directory. * doc/lispref/compile.texi: Documented `limit-buffer-saving' argument of `byte-recompile-directory'. * lisp/emacs-lisp/package.el (package--compile): Use `limit-buffer-saving' when calling `byte-recompile-directory'. --- doc/lispref/compile.texi | 6 +++++- lisp/emacs-lisp/bytecomp.el | 15 ++++++++++++--- lisp/emacs-lisp/package.el | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index b1cc04b..01c57ff 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -198,7 +198,7 @@ Compilation Functions @end example @end deffn -@deffn Command byte-recompile-directory directory &optional flag force +@deffn Command byte-recompile-directory directory &optional flag force limit-buffer-saving @cindex library compilation This command recompiles every @samp{.el} file in @var{directory} (or its subdirectories) that needs recompilation. A file needs @@ -217,5 +217,9 @@ Compilation Functions If @var{force} is non-@code{nil}, this command recompiles every @samp{.el} file that has a @samp{.elc} file. +By default, user is prompted before recompilation to save modified +buffers one by one. Setting @var{limit-buffer-saving} to @code{t} checks +only buffers within @var{directory}. + The returned value is unpredictable. @end deffn diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 63be7e2..82fb926 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1621,7 +1621,7 @@ byte-force-recompile (byte-recompile-directory directory nil t)) ;;;###autoload -(defun byte-recompile-directory (directory &optional arg force) +(defun byte-recompile-directory (directory &optional arg force limit-buffer-saving) "Recompile every `.el' file in DIRECTORY that needs recompilation. This happens when a `.elc' file exists but is older than the `.el' file. Files in subdirectories of DIRECTORY are processed also. @@ -1634,12 +1634,21 @@ byte-recompile-directory before scanning it. If the third argument FORCE is non-nil, recompile every `.el' file -that already has a `.elc' file." +that already has a `.elc' file. + +If forth argument LIMIT-BUFFER-SAVING is t only buffers within +DIRECTORY would be checked for modification." (interactive "DByte recompile directory: \nP") (if arg (setq arg (prefix-numeric-value arg))) (if noninteractive nil - (save-some-buffers) + (if limit-buffer-saving + (save-some-buffers + nil + (lambda () + (string-prefix-p (expand-file-name directory) + (expand-file-name buffer-file-name)))) + (save-some-buffers)) (force-mode-line-update)) (with-current-buffer (get-buffer-create byte-compile-log-buffer) (setq default-directory (expand-file-name directory)) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 6728f1b..0851c5e 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -946,7 +946,7 @@ package--compile (let ((warning-minimum-level :error) (save-silently inhibit-message) (load-path load-path)) - (byte-recompile-directory (package-desc-dir pkg-desc) 0 t))) + (byte-recompile-directory (package-desc-dir pkg-desc) 0 t t))) ;;;; Inferring package from current buffer (defun package-read-from-string (str) -- 2.10.2.windows.1