unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* package-installed-p issue.
       [not found] <20210109024756.en34g7b7ol45qtqs.ref@Ergus>
@ 2021-01-09  2:47 ` Ergus
  2021-01-09 16:53   ` Stefan Monnier
  2021-01-09 18:02   ` Philipp Stephani
  0 siblings, 2 replies; 3+ messages in thread
From: Ergus @ 2021-01-09  2:47 UTC (permalink / raw)
  To: help-gnu-emacs

Hi I'm trying to simplify some of my code in the init file and
something like:

(package-installed-p 'use-package)

Triggers an error so I need to do something like:

(unless (fboundp 'package-installed-p)
     (require 'package))

(unless (package-installed-p 'use-package)
   ...
)

My question is: Shouldn't package-installed-p be an autoload?

Is there a reason why it is not an autoload?

Some time ago package-installed-p was loaded when calling package-initialize
but now such call is not required anymore. So what's the right way?

Thanks in advance,
Ergus



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: package-installed-p issue.
  2021-01-09  2:47 ` package-installed-p issue Ergus
@ 2021-01-09 16:53   ` Stefan Monnier
  2021-01-09 18:02   ` Philipp Stephani
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2021-01-09 16:53 UTC (permalink / raw)
  To: help-gnu-emacs

> (unless (fboundp 'package-installed-p)
>     (require 'package))

You can replace that with just

    (require 'package)

> (unless (package-installed-p 'use-package)
>   ...
> )
>
> My question is: Shouldn't package-installed-p be an autoload?

Hmm... maybe it should.  Tho

    (fboundp 'use-package)

might do the trick as well.

BTW what you do within the "..." tho (I can guess that there's
(package-install 'use-package) in there, but I wonder if there's much
more setup code in there).

> Is there a reason why it is not an autoload?

No strong one, no.  It's basically that the need hadn't come up.


        Stefan




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: package-installed-p issue.
  2021-01-09  2:47 ` package-installed-p issue Ergus
  2021-01-09 16:53   ` Stefan Monnier
@ 2021-01-09 18:02   ` Philipp Stephani
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Stephani @ 2021-01-09 18:02 UTC (permalink / raw)
  To: Ergus; +Cc: help-gnu-emacs

Am Sa., 9. Jan. 2021 um 03:48 Uhr schrieb Ergus <spacibba@aol.com>:
>
> Hi I'm trying to simplify some of my code in the init file and
> something like:
>
> (package-installed-p 'use-package)
>
> Triggers an error so I need to do something like:
>
> (unless (fboundp 'package-installed-p)
>      (require 'package))
>
> (unless (package-installed-p 'use-package)
>    ...
> )
>
> My question is: Shouldn't package-installed-p be an autoload?
>
> Is there a reason why it is not an autoload?
>

Most functions should not be autoloaded. Autoloads are useful for
high-level interactive commands in optional libraries, so that e.g.
users can start ERT with `M-x ert' without having to load `ert'
explicitly. In code (including ~/.emacs), just use `require' to load
the required library. There's no need to surround it with `unless' -
`require' is idempotent.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-09 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20210109024756.en34g7b7ol45qtqs.ref@Ergus>
2021-01-09  2:47 ` package-installed-p issue Ergus
2021-01-09 16:53   ` Stefan Monnier
2021-01-09 18:02   ` Philipp Stephani

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).