help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Connect use-package to package-selected-packages


From: John Mastro
Subject: Connect use-package to package-selected-packages
Date: Fri, 29 Jul 2016 17:04:51 -0700

In a moment of boredom it occurred to me that, if you're using
`use-package' for all your ELPA packages, the
`package-selected-packages' mechanism is somewhat redundant. Why have
Emacs maintain a list of "selected packages" when they're already listed
in your init file?

I threw this in my non-byte-compiled init file, and it seems to work as
you'd expect[1]:

    (require 'package)

    (package-initialize)

    (advice-add 'package--save-selected-packages :override #'ignore)

    (unless (package-installed-p 'use-package)
      (package-refresh-contents)
      (package-install 'use-package))

    (defun use-package-select-package (name &rest args)
      (let ((ensure (cadr (member :ensure args))))
        (when ensure
          (add-to-list 'package-selected-packages
                       (if (eq ensure t) name ensure)
                       nil
                       #'eq))))

    (advice-add 'use-package :before #'use-package-select-package)

    (require 'use-package)

However, I haven't quite convinced myself that it's actually a good
idea. Other `use-package' users, especially those of you that take
advantage of `package-selected-packages', what do you think?

If it is a good idea, I'll submit it as a(n optional) feature to
`use-package'.

        John



reply via email to

[Prev in Thread] Current Thread [Next in Thread]