From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: emacs-devel@gnu.org, Eli Zaretskii <eliz@gnu.org>,
John Wiegley <johnw@newartisans.com>
Subject: Re: emacs-29 acd462b0306: ; Improve the use-package manual
Date: Sat, 10 Dec 2022 11:20:14 -0500 [thread overview]
Message-ID: <jwvh6y3p8bl.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CADwFkm=OuwvADgVsF1F_nRG+KBUV_eHQYG8vSEFEZ-hnTDGRDA@mail.gmail.com> (Stefan Kangas's message of "Sat, 10 Dec 2022 03:57:02 -0800")
> The answer to your first question is yes: the macro-expansion of
>
> (use-package foo)
>
> is just
>
> (require 'foo nil nil)
BTW, I can't resist mentioning that `require`ing a file like that should
be extremely rarely needed in an init file. There's a good reason for
that: by convention, the mere act of loading a file should not affect
Emacs behavior very much, if at all, so those `require` will usually
just slow down startup for no good reason.
I think this part of `use-package` is a result of its having been
designed before things like `package.el` became common practice (the
main effect of which (in this respect) has been to make `;;;###autoload`
cookies usable in all packages without any extra work on the package's
author's side).
(A similar "old style" thingy is that (use-package foo-mode :mode
".bar\\'") will setup an autoload for the `foo-mode` function, whereas
that autoload should have already been setup by the package's own
installation).
It would be nice to try and evolve `use-package` towards a default
behavior that's more aligned with current best practices rather than
what was done back when installing a package meant reading the
"Commentary:" section and copying a chunk of ELisp code into your
init file.
> The last two examples, using package-installed-p and locate-library, are
> more important to keep, as users have reported issues specifically
> related to not knowing what the difference is between them, for example:
>
> https://github.com/jwiegley/use-package/issues/693
I think in most cases, neither of them are good choices.
Instead better choices will usually look like `:if (fboundp '...)`
(which should be a lot faster than `locate-library` and doesn't care
how the package was installed).
Also, the wording in that paragraph is weird:
This example loads a package only when the @samp{foo} package
is installed.
since users should rarely care about "loading" (since, as
mentioned earlier, this should have mostly no visible effect).
`use-package` should be about configuring packages, not about loading
them (the `;;;###autoload` cookies should take care of the loading part
already).
> Alternatively, we could perhaps consider changing the docstring of
> `package-installed-p' to just let people know of `locate-library' (and
> maybe even when to use it).
This doesn't sound right since those two are only distantly related.
Stefan
next prev parent reply other threads:[~2022-12-10 16:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <167059642832.4265.15913417645926264658@vcs2.savannah.gnu.org>
[not found] ` <20221209143348.961DEC0E4CA@vcs2.savannah.gnu.org>
2022-12-10 11:57 ` emacs-29 acd462b0306: ; Improve the use-package manual Stefan Kangas
2022-12-10 14:26 ` Eli Zaretskii
2022-12-10 20:34 ` Stefan Kangas
2022-12-11 6:22 ` Eli Zaretskii
2022-12-11 14:24 ` Stefan Monnier
2022-12-11 20:04 ` John Yates
2022-12-12 1:35 ` Stefan Kangas
2022-12-12 1:34 ` Stefan Kangas
2022-12-10 16:20 ` Stefan Monnier [this message]
2022-12-10 16:30 ` Philip Kaludercic
2022-12-10 16:40 ` Stefan Monnier
2022-12-12 19:37 ` John Wiegley
2022-12-12 20:06 ` Philip Kaludercic
2022-12-10 20:33 ` Stefan Kangas
2022-12-10 22:01 ` Stefan Monnier
2022-12-11 7:09 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvh6y3p8bl.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=johnw@newartisans.com \
--cc=stefankangas@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).