4

When I run M-x package-install to install a package, I get asked whether I want to save files, that have been modified since the last save (Save file /a/b/c.txt? (y, n, !, ., q, C-r, d or C-h) in the minibuffer). I get this prompt for each modified file, and, if installing multiple packages from the *Packages* buffer, I get asked multiple times! This is incredibly frustrating, especially as the files that I am asked about have nothing to do with compilation, and could, in fact, be any files at all, including ordinary text files.

I did a bit of sleuthing, and found that, at the end of the day, package.el runs package-unpack to install a package, which runs package--compile, which runs byte-recompile-directory. I have therefore set the following in my init.el (even though I don't think I should have to do that(!)):

(setq compilation-ask-about-save nil)

No improvement.

Frankly, I thought this must be a side-effect of some customization of mine, since in no way would I consider this to be desirable behavior...until I ran emacs -Q to reproduce this without my config, and, to my surprise, ran into the very same thing. While this seems baffling, it also offers me some hope that perhaps someone has figured out a way to disable this super-annoying prompt?

  • Ask Emacs. At the prompt, use ? or C-h (as the prompt suggests), to learn what each of your options are. You will see that you can provide the same response for all modified files in the package at once. Do that and you will not be prompted for each modified file. (This does not respond to the part of your question that deals with prompts for multiple packages, however.) – Drew Jan 11 '15 at 18:15
  • 1
    I suggested filing this as a bug report. – Stefan Jan 15 '15 at 15:53
3

As the help text tells you when you type C-h (as prompted by save-some-buffers, which is the function responsible for the query), you can skip all remaining queries with a simple RET or q.

I certainly don't find myself in this situation so frequently that doing that is an onerous task, so this might be sufficient for you.

p.s. compilation-ask-about-save is related to running external compiler processes, and not to elisp byte-compilation.

Edit:

One option would be binding noninteractive ("Non-nil means Emacs is running without interactive terminal.") around package--compile with advice, as byte-recompile-directory won't trigger save-some-buffers in that case; but I think that's going to have some undesirable consequences further down.

Redefining save-some-buffers for the duration seems like a safer option:

(defadvice package--compile (around no-byte-recompile-saves)
  "Inhibit `save-some-buffers' when byte-compiling packages."
  (require 'cl-lib)
  (cl-letf (((symbol-function 'save-some-buffers) 'ignore))
    ad-do-it))
(ad-activate 'package--compile)
  • Alas, this might help when installing a single package, but, if installing multiple packages (or a package with dependencies), I still get this prompt for each package being installed. – Felix Jan 11 '15 at 10:20
  • To explain why the above is a problem - I have a lot of packages installed. From time to time, I run an across-the-board upgrade with U in the *Packages* buffer. As you can imagine, this will have me pressing q like a maniac, as tens, if not hundreds of packages are being compiled. This also means that I cannot run the upgrade unattended and switch to some other task while it's going on, since I have to q away the prompts! – Felix Jan 11 '15 at 10:23
  • Excellent - the defadvice from your edit solves this issue. Thank you! – Felix Jan 11 '15 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.