rranelli / auto-package-update.el

Automatically update Emacs packages.
153 stars 27 forks source link

Suppress auto-update #18

Closed andyleejordan closed 9 years ago

andyleejordan commented 9 years ago

Is there a way we could suppress the auto-update entirely if, say, shift (or some other customizable modifier) was being held during start-up?

I know if I can just comment out the auto-update code in init.el, but that requires opening a different editor, finding the line, and changing it. (So for now I just have a Git stash that I can apply to comment it out).

Just a feature request, if it were easy enough to implement. No worries if it's not.

rranelli commented 9 years ago

Hmm, I didn't quite understand what you mean by "shift (or some other customizable modifier) was being held during start-up".

Maybe wrapping the call to auto-package-update-maybe in some sort of conditional would solve your issue. The first thing that comes to my mind is to use an environment variable:

(unless (getenv "do_not_update_emacs_packages_or_whathever")
  (auto-package-update-maybe))

But that assumes you're launching Emacs from a terminal emulator, which might not be true.

Have I understood your problem correctly?

andyleejordan commented 9 years ago

Not quite, I want to say, launch emacs, and if I'm holding "shift" when (auto-package-update-maybe) is called, it won't run. So yeah,

(unless (shift-key-is-currently-pressed)
  (auto-package-update-maybe))

But I don't think it's actually possible to check that in Emacs with how it interprets key presses. Oh well. Thanks!

rranelli commented 9 years ago

Ohhh, alright. "Shift" is the keyboard key, haha. I don't really think that's possible.

Would a yes-or-no prompt would be enough for you ??

andyleejordan commented 9 years ago

A yes-or-no prompt would be perfect actually!

rranelli commented 9 years ago

If you add this to your .emacs

(when (and (apu--should-update-packages-p)
                   (y-or-n-p-with-timeout "Update packages?" 5 nil))
  (auto-package-update-now))

You will only be prompted when an update is pending. If you fail to answer in 5 seconds, the update will be skipped.

Not what you wanted originally, but probably enough I guess

andyleejordan commented 9 years ago

Ha! You are brilliant. Thank you so much @rranelli. This is perfect for those (unusually frequent) times that I need Emacs to open ASAP.

rranelli commented 9 years ago

Always happy to help ;)

rranelli commented 9 years ago

Also, if Emacs startup time is an issue, consider using emacs' 24.3+ emacs-server

andyleejordan commented 9 years ago

I do actually use the server in Emacs 24.5.50.1; it's just that shit happens and I end up needing to restart it. My fault probably since I run a lot of inferior processes (Octave, Git, etc.) and it's easier than manually closing all the buffers.