Subject: bug#25964: 26.0.50; byte-recompile-directory saving unrelated buffer

From: Andreas Politz <[email-masked]>
Date: Sat, 04 Mar 2017 05:58:34 +0100

I think it is somewhat annoying when I install a Lisp package and it
asks me whether I want to save a completely unrelated buffer in some
other project.  This is especially true, if this unrelated buffer has a
function like check-parens on its after-save-hook, which may signal an
error, and in turn will abort the whole package installation.

The buffer saving happens in byte-recompile-directory via
save-some-buffer. So I wonder, if this can be made more selective, like
so:

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 25513bd024..86b1617fd7 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1661,7 +1661,12 @@ byte-recompile-directory
   (if arg (setq arg (prefix-numeric-value arg)))
   (if noninteractive
       nil
-    (save-some-buffers)
+    (save-some-buffers
+     nil (lambda ()
+           (let ((file (buffer-file-name)))
+             (and file
+                  (string-match-p emacs-lisp-file-regexp file)
+                  (file-in-directory-p file directory)))))
     (force-mode-line-update))
   (with-current-buffer (get-buffer-create byte-compile-log-buffer)
     (setq default-directory (expand-file-name directory))

Thanks,
-ap