Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Monnier
> +(when (version< emacs-version "27.1")
> +  (package-initialize))

That doesn't do the right thing with the current `master` (nor will it
with Emacs-27.1's pretest).

Maybe a better option is

    (when package-enable-at-startup
      (package-initialize))

or

    (unless package-activated-list
      (package-initialize))


-- Stefan


Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Kangas-2
Stefan Monnier <[hidden email]> writes:

> > +(when (version< emacs-version "27.1")
> > +  (package-initialize))
>
> That doesn't do the right thing with the current `master` (nor will it
> with Emacs-27.1's pretest).

Good point, thanks.

> Maybe a better option is
>
>     (when package-enable-at-startup
>       (package-initialize))

Yes, that would work.  But I'm not sure I understand this variable in general.

It is a defcustom (a user option), but:

1. It's ineffective when set from the custom interface, since it has
to be in the early init file.  Right?

2. It is a user option, but gets set automatically by
package-initialize.  This makes it a bit confusing, because
describe-variable says:

package-enable-at-startup is a variable defined in ‘package.el’.
Its value is nil
Original value was t

I initially thought this meant *I* had changed it for some reason,
because that's usually what it means when Emacs reports that it has
changed, and then I was confused when I couldn't find out where.  Only
after a while did I understand that this is a user option that doubles
as a variable that tracks if the package system was initialized or
not.

Would this be better as a defvar instead?  Or should we introduce a
new variable to mean that we are already initialized?  I don't mean to
rehash old discussions here, so feel free to refer me to earlier
discussions if you've already had them.

> or
>
>     (unless package-activated-list
>       (package-initialize))

That could also work.  Do we prefer not to do this by version?  For
example, my suggestion would probably have been:

(unless (< emacs-major-version 27)
  (package-initialize))

Best regards,
Stefan Kangas

Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Monnier
> It is a defcustom (a user option), but:
> 1. It's ineffective when set from the custom interface, since it has
> to be in the early init file.  Right?

I guess it can still be effective if you load your custom-file from
early-init.el, but indeed it's rather unlikely to be effective in
Emacs≥27.

> 2. It is a user option, but gets set automatically by
> package-initialize.  This makes it a bit confusing, because
> describe-variable says:

Indeed, and this problem already existed before.

> Would this be better as a defvar instead?

I think you're right.


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Kangas-2
In reply to this post by Stefan Kangas-2
Stefan Kangas <[hidden email]> writes:

> That could also work.  Do we prefer not to do this by version?  For
> example, my suggestion would probably have been:
>
> (unless (< emacs-major-version 27)
>   (package-initialize))

I've now pushed this version to master.

Best regards,
Stefan Kangas

Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Kangas-2
In reply to this post by Stefan Monnier
Stefan Monnier <[hidden email]> writes:
>
> > It is a defcustom (a user option), but:
> > 1. It's ineffective when set from the custom interface, since it has
> > to be in the early init file.  Right?
>
> I guess it can still be effective if you load your custom-file from
> early-init.el, but indeed it's rather unlikely to be effective in
> Emacs≥27.

My guess would be that this will continue to be an unusual setup.

> > 2. It is a user option, but gets set automatically by
> > package-initialize.  This makes it a bit confusing, because
> > describe-variable says:
>
> Indeed, and this problem already existed before.
>
> > Would this be better as a defvar instead?
>
> I think you're right.

I started looking into package-enabe-at-startup, and of course the
above reasoning goes for package-load-list and package-user-dir; that
is, setting them via customize has no effect.  I see two alternatives:

1. Make sure that you can set all three via customize.
2. Make all three into defvars.

I'm not sure if option 1 is either practical or clean, so I'd lean
towards option 2, I think.  I'd be interested to hear what other
people think about it.

Meanwhile, the attached patch makes us not change the value of
package-enable-at-startup by introducing a new variable.  Any
comments?

Best regards,
Stefan Kangas

package-init.diff (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Monnier
> I started looking into package-enabe-at-startup, and of course the
> above reasoning goes for package-load-list and package-user-dir; that
> is, setting them via customize has no effect.

Yes and no: you can set `package-load-list` and `package-user-dir` in
your .emacs (and/or via customize) in order to affect the place where
packages are later installed and also in order to affect a subsequent
manual package-activate-all.

Currently, this requires setting (setq package-alist nil) by hand to
force reloading the package descriptors, but my hope is that we can
improve this in the future (e.g. with a :setter placed on those vars so
that package-activate-all is called again when they're modified via
custom).

Also, a "late-setting" of `package-load-list` (e.g. when set via
customize) will still work if you use `package-quickstart`.

> Meanwhile, the attached patch makes us not change the value of
> package-enable-at-startup by introducing a new variable.  Any
> comments?

The patch looks OK to me,


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Kangas-2
Stefan Monnier <[hidden email]> writes:

> > I started looking into package-enabe-at-startup, and of course the
> > above reasoning goes for package-load-list and package-user-dir; that
> > is, setting them via customize has no effect.
>
> Yes and no: you can set `package-load-list` and `package-user-dir` in
> your .emacs (and/or via customize) in order to affect the place where
> packages are later installed and also in order to affect a subsequent
> manual package-activate-all.
>
> Currently, this requires setting (setq package-alist nil) by hand to
> force reloading the package descriptors, but my hope is that we can
> improve this in the future (e.g. with a :setter placed on those vars so
> that package-activate-all is called again when they're modified via
> custom).
OK, thanks for explaining that.  I have attached a patch which changes
package-enable-at-startup into a defvar for now.

I've also added documentation to package-load-list and
package-user-dir to explain the above quirks.

Any comments?

> Also, a "late-setting" of `package-load-list` (e.g. when set via
> customize) will still work if you use `package-quickstart`.

I have two questions here:

1. I can't find anything on package-quickstart in the user manual.  Is
that intentional?  Perhaps it would make sense to create a new node
"initialization of packages" which could describe all this.

2. Should package-quickstart have a :set attribute with a value of
'package-quickstart-refresh?

Best regards,
Stefan Kangas

0001-Make-package-enable-at-startup-into-defvar.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Stefan Monnier
>> Currently, this requires setting (setq package-alist nil) by hand to
>> force reloading the package descriptors, but my hope is that we can
>> improve this in the future (e.g. with a :setter placed on those vars so
>> that package-activate-all is called again when they're modified via
>> custom).
>
> OK, thanks for explaining that.  I have attached a patch which changes
> package-enable-at-startup into a defvar for now.

I'm not sure if there's much harm in keeping it as a defcustom, so I'll
let someone else decide whether we should change it.  But if we do want
to change it, the patch looks OK to me in this respect.

> I've also added documentation to package-load-list and
> package-user-dir to explain the above quirks.

But this doesn't mention the fact that it still works if they use
`package-quickstart`.

>> Also, a "late-setting" of `package-load-list` (e.g. when set via
>> customize) will still work if you use `package-quickstart`.
> I have two questions here:
> 1. I can't find anything on package-quickstart in the user manual.
>    Is that intentional?

No.

> Perhaps it would make sense to create a new node "initialization of
> packages" which could describe all this.

Yes.  Maybe it should be a bit more general and include discussion of
customize settings.  IOW it could talk about dependencies and ordering
between package.el, custom.el, and "manual Elisp settings".

> 2. Should package-quickstart have a :set attribute with a value of
> 'package-quickstart-refresh?

I don't think so: the refresh should happen when the set of
installed/activated packages changes, whereas what you suggest would
cause a refresh to happen at every Emacs startup.

But I guess it does deserve a :set function, which should take care to
run `package-quickstart-refresh` if there's no quickstart file yet, or
to delete the quickstart file when set to nil (in both cases it should
maybe prompt the user before actually doing it?).


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: [Emacs-diffs] master 4449301: * etc/NEWS: Improve documentation of 'package-initialize'.

Eli Zaretskii
In reply to this post by Stefan Kangas-2
> From: Stefan Kangas <[hidden email]>
> Date: Mon, 11 Nov 2019 17:07:07 +0100
> Cc: Emacs developers <[hidden email]>
>
> OK, thanks for explaining that.  I have attached a patch which changes
> package-enable-at-startup into a defvar for now.

I'm not sure I understand how grave are the problems with this
defcustom, but if they are, I'd prefer to add a :set function rather
than demoting a user option to a defvar.