all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Mastro <john.b.mastro@gmail.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Connect use-package to package-selected-packages
Date: Fri, 29 Jul 2016 17:04:51 -0700	[thread overview]
Message-ID: <CAOj2CQSMjhNxpe9BJa2Zb03j7zCYh4TzYphrb6dbHM6PsAaAdA@mail.gmail.com> (raw)

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	other threads:[~2016-07-30  0:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOj2CQSMjhNxpe9BJa2Zb03j7zCYh4TzYphrb6dbHM6PsAaAdA@mail.gmail.com \
    --to=john.b.mastro@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.