all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Connect use-package to package-selected-packages
@ 2016-07-30  0:04 John Mastro
  0 siblings, 0 replies; only message in thread
From: John Mastro @ 2016-07-30  0:04 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-30  0:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-30  0:04 Connect use-package to package-selected-packages John Mastro

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.