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.
1 Answer
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:
Introduce a variable that holds a list of packages to ignore (called
package-menu-exclude-packages
above).Advise
package-menu--find-upgrades
to run with a modified version oftabulated-list-entries
that excludes the packages we'd like to ignore.
-
3
-
No longer works, getting error:
error in process filter: Symbol’s function definition is void: -filter
Apr 26, 2018 at 16:40 -
@KeksDose
-filter
is defined in thedash
library, so you'll need to install that before using this snippet.– itsjeydJun 20, 2018 at 6:33 -
@itsjeyd Thank you. Adding
(require dash)
to .emacs after installing solved the issue. Jun 22, 2018 at 11:16
package.el
, but haven't found a description of how to do it.