5

list-packages prompts you to upgrade packages when newer versions are available. How do you tell package.el to never consider a particular package for auto-upgrades? There are some packages which I have minor customizations for and don't care about newer versions of them.

5
  • Does Emacs automatically auto-upgrade all packages? Why should you need to tell it not to automatically upgrade a particular package? (I would hope that users have some control over this.)
    – Drew
    Feb 18, 2015 at 0:47
  • It offers to automatically upgrade packages which have updates available. I like this feature - usually there would be a ton of packages and if the package author put something up on elpa/melpa/marmalade saying there's something new, I would want it. In a handful of cases, I would want to make an exception and say "No, lay off these packages."
    – Pradhan
    Feb 18, 2015 at 0:49
  • I see. I agree that it should be easy for users to do as you request. Maybe someone will say it is, and tell you how.
    – Drew
    Feb 18, 2015 at 0:51
  • 1
    I believe this functionality is referred to as pinning in other package managers. I have heard reference to it for package.el, but haven't found a description of how to do it.
    – dgtized
    Feb 18, 2015 at 0:57
  • 1
    @dgtized You can pin the packages to one of the repositories but you can't pin a package to stay put with a local version that doesn't belong to either of the repositories. Feb 18, 2015 at 1:32

1 Answer 1

10

Add the following code to your init-file (replace package-1, package-2, etc. with names of packages you would like to freeze at the current version):

(defvar package-menu-exclude-packages '("package-1" "package-2" "package-n"))

(defun package-menu--remove-excluded-packages (orig)
  (let ((included (-filter
                   (lambda (entry)
                     (let ((name (symbol-name (package-desc-name (car entry)))))
                       (not (member name package-menu-exclude-packages))))
                   tabulated-list-entries)))
    (setq-local tabulated-list-entries included)
    (funcall orig)))

(advice-add 'package-menu--find-upgrades :around #'package-menu--remove-excluded-packages)

Explanation

package-menu--find-upgrades is responsible for building the list of packages to upgrade. To do this, it looks at each entry in tabulated-list-entries. So in order to ignore certain packages, we need to:

  1. Introduce a variable that holds a list of packages to ignore (called package-menu-exclude-packages above).

  2. Advise package-menu--find-upgrades to run with a modified version of tabulated-list-entries that excludes the packages we'd like to ignore.

4
  • 3
    This will be a good addition to the emacs trunk on git. Feb 18, 2015 at 15:13
  • No longer works, getting error: error in process filter: Symbol’s function definition is void: -filter
    – Keks Dose
    Apr 26, 2018 at 16:40
  • @KeksDose -filter is defined in the dash library, so you'll need to install that before using this snippet.
    – itsjeyd
    Jun 20, 2018 at 6:33
  • @itsjeyd Thank you. Adding (require dash) to .emacs after installing solved the issue.
    – Keks Dose
    Jun 22, 2018 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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