unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25340: Save-some-buffers gets called when installing packages.
@ 2017-01-02 22:42 Nikolay Kudryavtsev
  2017-01-05  4:35 ` npostavs
  2017-03-04 11:25 ` Andreas Politz
  0 siblings, 2 replies; 16+ messages in thread
From: Nikolay Kudryavtsev @ 2017-01-02 22:42 UTC (permalink / raw)
  To: 25340

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

Every time you install a new package you get called to save your 
modified buffers one by one. So, whenever I update my packages I can get 
like 30 packages and I have to press q at least 30 times. This behavior 
is pointless and somewhat annoying.

I've attached the laziest possible patch for this.

-- 
Best Regards,
Nikolay Kudryavtsev


[-- Attachment #2: 0001-Prevent-package-install-from-asking-to-save-buffers.patch --]
[-- Type: text/plain, Size: 3619 bytes --]

From c5669776b1abec979249ff9218ba8251500fc704 Mon Sep 17 00:00:00 2001
From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Date: Tue, 3 Jan 2017 01:21:19 +0300
Subject: [PATCH] Prevent package-install from asking to save buffers

 * lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): New argument
 `ignore-modified-buffers' that prevents `save-some-buffers' from getting
 called.
 * doc/lispref/compile.texi: Documented `ignore-modified-buffers' argument
 of `byte-recompile-directory'.
 * lisp/emacs-lisp/package.el (package--compile): Use
 `ignore-modified-buffers' when calling `byte-recompile-directory'.
---
 doc/lispref/compile.texi    |  6 +++++-
 lisp/emacs-lisp/bytecomp.el | 10 +++++++---
 lisp/emacs-lisp/package.el  |  2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi
index b1cc04b..239d7ee 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 ignore-modified-buffers
 @cindex library compilation
 This command recompiles every @samp{.el} file in @var{directory} (or
 its subdirectories) that needs recompilation.  A file needs
@@ -217,6 +217,10 @@ Compilation Functions
 If @var{force} is non-@code{nil}, this command recompiles every
 @samp{.el} file that has a @samp{.elc} file.

+If @var{ignore-modified-buffers} is non-@code{nil}, this command avoids
+saving modified buffers before compilation. Otherwise
+@code{save-some-buffers} is called.
+
 The returned value is unpredictable.
 @end deffn

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 63be7e2..fda25ae 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 ignore-modified-buffers)
   "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,16 @@ 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 IGNORE-MODIFIED-BUFFERS is non-nil, do not try to save
+modified buffers before compilation."
   (interactive "DByte recompile directory: \nP")
   (if arg (setq arg (prefix-numeric-value arg)))
   (if noninteractive
       nil
-    (save-some-buffers)
+    (when (not ignore-modified-buffers)
+        (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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-02 22:42 bug#25340: Save-some-buffers gets called when installing packages Nikolay Kudryavtsev
@ 2017-01-05  4:35 ` npostavs
  2017-01-05  6:26   ` Nikolay Kudryavtsev
  2017-03-04 11:25 ` Andreas Politz
  1 sibling, 1 reply; 16+ messages in thread
From: npostavs @ 2017-01-05  4:35 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 25340

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

> Every time you install a new package you get called to save your
> modified buffers one by one. So, whenever I update my packages I can
> get like 30 packages and I have to press q at least 30 times. This
> behavior is pointless and somewhat annoying.
>
> I've attached the laziest possible patch for this.

> * lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): New argument
> `ignore-modified-buffers' that prevents `save-some-buffers' from getting
> called.

Instead of a boolean, what do you think about passing a directory, such
that only buffers visiting files in that directory or below would get
prompted for saving?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-05  4:35 ` npostavs
@ 2017-01-05  6:26   ` Nikolay Kudryavtsev
  2017-01-06  2:31     ` npostavs
  0 siblings, 1 reply; 16+ messages in thread
From: Nikolay Kudryavtsev @ 2017-01-05  6:26 UTC (permalink / raw)
  To: npostavs; +Cc: 25340

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

Oh, that's a better idea. Fixed the patch.

The question now is whether there's even a need to add a new arg to 
byte-recompile-directory?

-- 
Best Regards,
Nikolay Kudryavtsev


[-- Attachment #2: 0001-Prevent-package-install-from-asking-to-save-buffers.patch --]
[-- Type: text/plain, Size: 1159 bytes --]

From ed64fe20726df039ad0a9bede2d1f4167ea607f9 Mon Sep 17 00:00:00 2001
From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Date: Thu, 5 Jan 2017 09:10:01 +0300
Subject: [PATCH] Prevent package-install from asking to save buffers

* lisp/emacs-lisp/bytecomp.el (byte-recompile-directory):
`save-some-buffers' is called only for files within that directory.
---
 lisp/emacs-lisp/bytecomp.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 63be7e2..db84973 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1639,7 +1639,10 @@ byte-recompile-directory
   (if arg (setq arg (prefix-numeric-value arg)))
   (if noninteractive
       nil
-    (save-some-buffers)
+    (save-some-buffers nil
+                       (lambda ()
+                         (member (expand-file-name buffer-file-name)
+                                 (directory-files directory t))))
     (force-mode-line-update))
   (with-current-buffer (get-buffer-create byte-compile-log-buffer)
     (setq default-directory (expand-file-name directory))
-- 
2.10.2.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-05  6:26   ` Nikolay Kudryavtsev
@ 2017-01-06  2:31     ` npostavs
  2017-01-07 18:06       ` Nikolay Kudryavtsev
  2017-03-04 10:18       ` Andreas Politz
  0 siblings, 2 replies; 16+ messages in thread
From: npostavs @ 2017-01-06  2:31 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 25340

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

> The question now is whether there's even a need to add a new arg to
> byte-recompile-directory?

Possibly yes, since files can require others outside the directory being
compiled.  So we might not want to have this directory restriction
applied always.

> +                         (member (expand-file-name buffer-file-name)
> +                                 (directory-files directory t))))

I was thinking more along the lines of

    (string-prefix-p (expand-file-name directory)
                     (expand-file-name buffer-file-name))

(Or does that break in some weird file systems?)





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-06  2:31     ` npostavs
@ 2017-01-07 18:06       ` Nikolay Kudryavtsev
  2017-01-07 18:47         ` npostavs
  2017-01-08  5:33         ` npostavs
  2017-03-04 10:18       ` Andreas Politz
  1 sibling, 2 replies; 16+ messages in thread
From: Nikolay Kudryavtsev @ 2017-01-07 18:06 UTC (permalink / raw)
  To: npostavs; +Cc: 25340

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

I had the idea of doing this:

(defun byte-recompile-directory (directory &optional arg force 
limit-buffer-saving)

...

If forth argument LIMIT-BUFFER-SAVING is 'directory, only files within
DIRECTORY would be saved.  When LIMIT-BUFFER-SAVING is t no existing buffers
would be checked for modification.


But I found out out that having LIMIT-BUFFER-SAVING with value t like 
this would not work without an accompanying change to 
byte-recompile-file - since byte-recompile-file already checks whether 
there's a buffer for that file and that buffer is modified. So, since I 
don't think that doing changes to byte-recompile-file is the best idea, 
here's my current version.

Also, note that the check in byte-recompile-file actually makes calling 
save-some-buffers somewhat redundant.

-- 
Best Regards,
Nikolay Kudryavtsev


[-- Attachment #2: 0001-Prevent-package-install-from-asking-to-save-buffers.patch --]
[-- Type: text/plain, Size: 3776 bytes --]

From d0cc713b2150ccf7d5c31756438a42a3f106e7bd Mon Sep 17 00:00:00 2001
From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-07 18:06       ` Nikolay Kudryavtsev
@ 2017-01-07 18:47         ` npostavs
  2017-01-08  4:56           ` Nikolay Kudryavtsev
  2017-01-08  5:33         ` npostavs
  1 sibling, 1 reply; 16+ messages in thread
From: npostavs @ 2017-01-07 18:47 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 25340

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

> I had the idea of doing this:
>
> (defun byte-recompile-directory (directory &optional arg force
> limit-buffer-saving)
>
> ...
>
> If forth argument LIMIT-BUFFER-SAVING is 'directory, only files within
> DIRECTORY would be saved.  When LIMIT-BUFFER-SAVING is t no existing buffers
> would be checked for modification.
>
>
> But I found out out that having LIMIT-BUFFER-SAVING with value t like
> this would not work without an accompanying change to
> byte-recompile-file - since byte-recompile-file already checks whether
> there's a buffer for that file and that buffer is modified.
>

I don't see where byte-recompile-file is checking that?

> So, since I don't think that doing changes to byte-recompile-file is
> the best idea, here's my current version.
>
> Also, note that the check in byte-recompile-file actually makes
> calling save-some-buffers somewhat redundant.







^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-07 18:47         ` npostavs
@ 2017-01-08  4:56           ` Nikolay Kudryavtsev
  0 siblings, 0 replies; 16+ messages in thread
From: Nikolay Kudryavtsev @ 2017-01-08  4:56 UTC (permalink / raw)
  To: npostavs; +Cc: 25340

Search for "Save buffer %s first? ".

-- 
Best Regards,
Nikolay Kudryavtsev






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-07 18:06       ` Nikolay Kudryavtsev
  2017-01-07 18:47         ` npostavs
@ 2017-01-08  5:33         ` npostavs
  2017-01-08  8:06           ` Nikolay Kudryavtsev
  1 sibling, 1 reply; 16+ messages in thread
From: npostavs @ 2017-01-08  5:33 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 25340

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

> I had the idea of doing this:
>
> (defun byte-recompile-directory (directory &optional arg force
> limit-buffer-saving)
>
> ...
>
> If forth argument LIMIT-BUFFER-SAVING is 'directory, only files within
> DIRECTORY would be saved.  When LIMIT-BUFFER-SAVING is t no existing buffers
> would be checked for modification.
>
>
> But I found out out that having LIMIT-BUFFER-SAVING with value t like
> this would not work without an accompanying change to
> byte-recompile-file - since byte-recompile-file already checks whether
> there's a buffer for that file and that buffer is modified. So, since
> I don't think that doing changes to byte-recompile-file is the best
> idea, here's my current version.

Ah, it's in byte-compile-file, not byte-REcompile-file.  Since with the
current code, if there is a buffer you don't want to save before
compiling, you have to answer "no" twice, I think changing
byte-compile-file would be a good thing to do.  But we could leave it
for later.

>
> Also, note that the check in byte-recompile-file actually makes
> calling save-some-buffers somewhat redundant.

I would say the redundancy is in the other direction, but yes, agreed.

Patch looks okay, just a few minor comments, below.

> * doc/lispref/compile.texi: Documented `limit-buffer-saving' argument
                              ^^^^^^^^^^
Use present tense ("Document `foo' argument...").

> 
> +By default, user is prompted before recompilation to save modified
> +buffers one by one. Setting @var{limit-buffer-saving} to @code{t} checks
                     ^^^
End sentences with double space.

> +If forth argument LIMIT-BUFFER-SAVING is t only buffers within
      ^^^^^                                  ^
      fourth                                comma here, I think

> +DIRECTORY would be checked for modification."
             ^^^^^^^^^^^^^^^^
I think that should be "are checked".

> +    (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))

I would rather avoid doubling the call to save-some-buffers, so use
something like

    (save-some-buffers
     nil
     (if limit-buffer-saving
         (lambda () ...)))





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-08  5:33         ` npostavs
@ 2017-01-08  8:06           ` Nikolay Kudryavtsev
  2017-01-08 17:03             ` npostavs
  0 siblings, 1 reply; 16+ messages in thread
From: Nikolay Kudryavtsev @ 2017-01-08  8:06 UTC (permalink / raw)
  To: npostavs; +Cc: 25340

[-- Attachment #1: Type: text/plain, Size: 140 bytes --]

Ok, fixed.

P. S. Don't really like the name limit-buffer-saving, but can't think of 
a better one.

-- 
Best Regards,
Nikolay Kudryavtsev


[-- Attachment #2: 0001-Prevent-package-install-from-asking-to-save-buffers.patch --]
[-- Type: text/plain, Size: 3756 bytes --]

From ef16f5bc9c4c9fc3aec3ce7173328b5c6ba1af94 Mon Sep 17 00:00:00 2001
From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Date: Sun, 8 Jan 2017 11:04:22 +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: Document `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 | 14 +++++++++++---
 lisp/emacs-lisp/package.el  |  2 +-
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi
index b1cc04b..974d313 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,6 +217,10 @@ Compilation Functions
 If @var{force} is non-@code{nil}, this command recompiles every
 @samp{.el} file that has a @samp{.elc} file.

+By default, before the recompilation, the user is prompted 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..2e0fc79 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,20 @@ 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 fourth argument LIMIT-BUFFER-SAVING is t only buffers within
+DIRECTORY are checked for modification."
   (interactive "DByte recompile directory: \nP")
   (if arg (setq arg (prefix-numeric-value arg)))
   (if noninteractive
       nil
-    (save-some-buffers)
+    (save-some-buffers
+     nil
+     (if limit-buffer-saving
+         (lambda ()
+           (string-prefix-p (expand-file-name directory)
+                            (expand-file-name buffer-file-name)))))
     (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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-08  8:06           ` Nikolay Kudryavtsev
@ 2017-01-08 17:03             ` npostavs
       [not found]               ` <aa6168cc-d8eb-2c1c-70af-a63aed862b75@gmail.com>
  0 siblings, 1 reply; 16+ messages in thread
From: npostavs @ 2017-01-08 17:03 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 25340

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

> Ok, fixed.

> +If fourth argument LIMIT-BUFFER-SAVING is t only buffers within
                                             ^^^ 
> +DIRECTORY are checked for modification."

I think there should be a comma there, do you agree?  Also, we should
say non-nil instead of t.

>
> P. S. Don't really like the name limit-buffer-saving, but can't think
> of a better one.

Maybe save-only-in-directory-p (that's even longer though).





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Fwd: bug#25340: Save-some-buffers gets called when installing packages.
       [not found]               ` <aa6168cc-d8eb-2c1c-70af-a63aed862b75@gmail.com>
@ 2017-01-09 15:33                 ` Noam Postavsky
  2017-01-16  1:09                   ` npostavs
  2017-03-18  6:55                   ` Tino Calancha
  0 siblings, 2 replies; 16+ messages in thread
From: Noam Postavsky @ 2017-01-09 15:33 UTC (permalink / raw)
  To: Nikolay Kudryavtsev, 25340

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

---------- Forwarded message ----------
From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Date: Mon, Jan 9, 2017 at 2:42 AM
Subject: Re: bug#25340: Save-some-buffers gets called when installing packages.
To: npostavs@users.sourceforge.net


Fixed the comma. I'll leave choosing the name up to maintainers.


--
Best Regards,
Nikolay Kudryavtsev

[-- Attachment #2: 0001-Prevent-package-install-from-asking-to-save-buffers.patch --]
[-- Type: text/plain, Size: 3757 bytes --]

From ef16f5bc9c4c9fc3aec3ce7173328b5c6ba1af94 Mon Sep 17 00:00:00 2001
From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Date: Sun, 8 Jan 2017 11:04:22 +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: Document `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 | 14 +++++++++++---
 lisp/emacs-lisp/package.el  |  2 +-
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi
index b1cc04b..974d313 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,6 +217,10 @@ Compilation Functions
 If @var{force} is non-@code{nil}, this command recompiles every
 @samp{.el} file that has a @samp{.elc} file.

+By default, before the recompilation, the user is prompted 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..2e0fc79 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,20 @@ 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 fourth argument LIMIT-BUFFER-SAVING is t, only buffers within
+DIRECTORY are checked for modification."
   (interactive "DByte recompile directory: \nP")
   (if arg (setq arg (prefix-numeric-value arg)))
   (if noninteractive
       nil
-    (save-some-buffers)
+    (save-some-buffers
+     nil
+     (if limit-buffer-saving
+         (lambda ()
+           (string-prefix-p (expand-file-name directory)
+                            (expand-file-name buffer-file-name)))))
     (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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#25340: Fwd: bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-09 15:33                 ` bug#25340: Fwd: " Noam Postavsky
@ 2017-01-16  1:09                   ` npostavs
  2017-03-18  6:55                   ` Tino Calancha
  1 sibling, 0 replies; 16+ messages in thread
From: npostavs @ 2017-01-16  1:09 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 25340

>
> Fixed the comma. I'll leave choosing the name up to maintainers.

Let's not get stuck on a choice of local variable name, your original
name is fine.  I think there should be a NEWS entry though.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-06  2:31     ` npostavs
  2017-01-07 18:06       ` Nikolay Kudryavtsev
@ 2017-03-04 10:18       ` Andreas Politz
  2017-03-04 14:47         ` npostavs
  1 sibling, 1 reply; 16+ messages in thread
From: Andreas Politz @ 2017-03-04 10:18 UTC (permalink / raw)
  To: npostavs; +Cc: 25340, Nikolay Kudryavtsev

npostavs@users.sourceforge.net writes:

> I was thinking more along the lines of
>
>     (string-prefix-p (expand-file-name directory)
>                      (expand-file-name buffer-file-name))
>

Why not use `file-in-directory-p', which is a function created for this
problem.

-ap





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-02 22:42 bug#25340: Save-some-buffers gets called when installing packages Nikolay Kudryavtsev
  2017-01-05  4:35 ` npostavs
@ 2017-03-04 11:25 ` Andreas Politz
  1 sibling, 0 replies; 16+ messages in thread
From: Andreas Politz @ 2017-03-04 11:25 UTC (permalink / raw)
  To: npostavs; +Cc: 25340, Nikolay Kudryavtsev


Also, what about excluding non-Lisp files.

#+BEGIN_SRC emacs-lisp
  (lambda ()
    ;; Assuming (buffer-file-name) is always non-nil.
    (string-match-p emacs-lisp-file-regexp (buffer-file-name))
    (file-in-directory-p (buffer-file-name) directory))
#+END_SRC

I thing, the string-match-p part could also be used unconditionally.

-ap





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Save-some-buffers gets called when installing packages.
  2017-03-04 10:18       ` Andreas Politz
@ 2017-03-04 14:47         ` npostavs
  0 siblings, 0 replies; 16+ messages in thread
From: npostavs @ 2017-03-04 14:47 UTC (permalink / raw)
  To: Andreas Politz; +Cc: 25340, Nikolay Kudryavtsev

Andreas Politz <politza@hochschule-trier.de> writes:

> npostavs@users.sourceforge.net writes:
>
>> I was thinking more along the lines of
>>
>>     (string-prefix-p (expand-file-name directory)
>>                      (expand-file-name buffer-file-name))
>>
>
> Why not use `file-in-directory-p', which is a function created for this
> problem.

Yeah, that makes sense, if I had known about that function I would have
suggested it.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#25340: Fwd: bug#25340: Save-some-buffers gets called when installing packages.
  2017-01-09 15:33                 ` bug#25340: Fwd: " Noam Postavsky
  2017-01-16  1:09                   ` npostavs
@ 2017-03-18  6:55                   ` Tino Calancha
  1 sibling, 0 replies; 16+ messages in thread
From: Tino Calancha @ 2017-03-18  6:55 UTC (permalink / raw)
  To: Noam Postavsky
  Cc: 25340, Andreas Politz, Nikolay Kudryavtsev, 26056, tino.calancha

Noam Postavsky <npostavs@users.sourceforge.net> writes:

> ---------- Forwarded message ----------
> From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
> Date: Mon, Jan 9, 2017 at 2:42 AM
> Subject: Re: bug#25340: Save-some-buffers gets called when installing packages.
> To: npostavs@users.sourceforge.net
>
>
> Fixed the comma. I'll leave choosing the name up to maintainers.
>
>
> --
> Best Regards,
> Nikolay Kudryavtsev
Hi,

today i upgraded 5 packages using this patch.  It was nice not being
prompted to save modified buffers.
I am looking forward to see this feature added into the master branch.





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-03-18  6:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-02 22:42 bug#25340: Save-some-buffers gets called when installing packages Nikolay Kudryavtsev
2017-01-05  4:35 ` npostavs
2017-01-05  6:26   ` Nikolay Kudryavtsev
2017-01-06  2:31     ` npostavs
2017-01-07 18:06       ` Nikolay Kudryavtsev
2017-01-07 18:47         ` npostavs
2017-01-08  4:56           ` Nikolay Kudryavtsev
2017-01-08  5:33         ` npostavs
2017-01-08  8:06           ` Nikolay Kudryavtsev
2017-01-08 17:03             ` npostavs
     [not found]               ` <aa6168cc-d8eb-2c1c-70af-a63aed862b75@gmail.com>
2017-01-09 15:33                 ` bug#25340: Fwd: " Noam Postavsky
2017-01-16  1:09                   ` npostavs
2017-03-18  6:55                   ` Tino Calancha
2017-03-04 10:18       ` Andreas Politz
2017-03-04 14:47         ` npostavs
2017-03-04 11:25 ` Andreas Politz

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).