GNU bug report logs - #76561
[PATCH] Promote desktop-dirname to a defcustom

Previous Next

Package: emacs;

Reported by: João Guerra <joca.bt <at> gmail.com>

Date: Tue, 25 Feb 2025 17:48:01 UTC

Severity: normal

Tags: patch

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76561 in the body.
You can then email your comments to 76561 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#76561; Package emacs. (Tue, 25 Feb 2025 17:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to João Guerra <joca.bt <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 25 Feb 2025 17:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: João Guerra <joca.bt <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Promote desktop-dirname to a defcustom
Date: Tue, 25 Feb 2025 18:46:47 +0100
[Message part 1 (text/plain, inline)]

[0001-Promote-desktop-dirname-to-a-defcustom.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76561; Package emacs. (Tue, 25 Feb 2025 18:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 76561 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: João Guerra <joca.bt <at> gmail.com>
Cc: 76561 <at> debbugs.gnu.org
Subject: Re: bug#76561: [PATCH] Promote desktop-dirname to a defcustom
Date: Tue, 25 Feb 2025 19:59:03 +0200
> From: João Guerra <joca.bt <at> gmail.com>
> Date: Tue, 25 Feb 2025 18:46:47 +0100
> 
> From 16c4e88d7ae08d10f8965e35bb08d4fb4d048bc7 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Jo=C3=A3o=20Guerra?= <joca.bt <at> gmail.com>
> Date: Tue, 25 Feb 2025 18:36:57 +0100
> Subject: [PATCH] Promote desktop-dirname to a defcustom
> 
> This should make it more explicit that this variable can be customized by the
> user.

Thanks, but I don't think this is right.  desktop-dirname is a
variable, not a user option, because desktop.el modifies its value
when the user reads or saves desktop, and it is wrong for a Lisp
program to change the value of a user option.

Moreover, one can read several different desktop filers in the same
Emacs session, and desktop.el currently arranges for the subsequent
desktop-save to save desktop to the file from which it was last read.
If users customize desktop-dirname to some value, and desktop.el will
be forced to use this value unconditionally (as it should do with user
options), then this feature will be lost.

May I ask what problem you are trying to solve by this change?  Can
you describe a situation where you needed to force a particular value
of desktop-dirname?

> +(defcustom desktop-dirname nil
> +  "The directory in which the desktop file should be saved."
> +  :type 'directory

If the type is 'directory', then the value cannot be nil, because nil
is not a valid directory.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76561; Package emacs. (Tue, 25 Feb 2025 18:14:01 GMT) Full text and rfc822 format available.

Message #11 received at 76561 <at> debbugs.gnu.org (full text, mbox):

From: João Guerra <joca.bt <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76561 <at> debbugs.gnu.org
Subject: Re: bug#76561: [PATCH] Promote desktop-dirname to a defcustom
Date: Tue, 25 Feb 2025 19:12:37 +0100
Hello, the idea is to allow the user to customize where the desktop
file is saved by default. Currently, the user can only customize the
name for the file, its lock, and the directories where to search for
desktop files for loading. I've been customizing desktop-dirname this
way for a long time, but I don't use multiple desktops.

Note that desktop-dirname appears in the documentation of other
options, which can lead to the idea that it can be customized. For
example:

```
(defcustom desktop-save 'ask-if-new
  "Specifies whether the desktop should be saved when it is killed.
...
The variables `desktop-dirname' and `desktop-base-file-name'
determine where the desktop is saved."
```

> If users customize desktop-dirname to some value, and desktop.el will be forced to use this value unconditionally (as it should do with user options), then this feature will be lost.

Since the user can only have one desktop active at a time, it
shouldn't be problematic but I now understand that's not ideal. In
that case, what about introducing a new option that feeds the
variable? Unless there are already other alternatives.


On Tue, 25 Feb 2025 at 18:59, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: João Guerra <joca.bt <at> gmail.com>
> > Date: Tue, 25 Feb 2025 18:46:47 +0100
> >
> > From 16c4e88d7ae08d10f8965e35bb08d4fb4d048bc7 Mon Sep 17 00:00:00 2001
> > From: =?UTF-8?q?Jo=C3=A3o=20Guerra?= <joca.bt <at> gmail.com>
> > Date: Tue, 25 Feb 2025 18:36:57 +0100
> > Subject: [PATCH] Promote desktop-dirname to a defcustom
> >
> > This should make it more explicit that this variable can be customized by the
> > user.
>
> Thanks, but I don't think this is right.  desktop-dirname is a
> variable, not a user option, because desktop.el modifies its value
> when the user reads or saves desktop, and it is wrong for a Lisp
> program to change the value of a user option.
>
> Moreover, one can read several different desktop filers in the same
> Emacs session, and desktop.el currently arranges for the subsequent
> desktop-save to save desktop to the file from which it was last read.
> If users customize desktop-dirname to some value, and desktop.el will
> be forced to use this value unconditionally (as it should do with user
> options), then this feature will be lost.
>
> May I ask what problem you are trying to solve by this change?  Can
> you describe a situation where you needed to force a particular value
> of desktop-dirname?
>
> > +(defcustom desktop-dirname nil
> > +  "The directory in which the desktop file should be saved."
> > +  :type 'directory
>
> If the type is 'directory', then the value cannot be nil, because nil
> is not a valid directory.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76561; Package emacs. (Tue, 25 Feb 2025 19:44:03 GMT) Full text and rfc822 format available.

Message #14 received at 76561 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: João Guerra <joca.bt <at> gmail.com>
Cc: 76561 <at> debbugs.gnu.org
Subject: Re: bug#76561: [PATCH] Promote desktop-dirname to a defcustom
Date: Tue, 25 Feb 2025 21:42:38 +0200
> From: João Guerra <joca.bt <at> gmail.com>
> Date: Tue, 25 Feb 2025 19:12:37 +0100
> Cc: 76561 <at> debbugs.gnu.org
> 
> Hello, the idea is to allow the user to customize where the desktop
> file is saved by default. Currently, the user can only customize the
> name for the file, its lock, and the directories where to search for
> desktop files for loading.

That's not true: if you invoke "M-x desktop-save", it will prompt you
for the directory in which to save, and will record that directory in
the desktop-dirname variable for future saves.  This is one way users
have today to customize where the desktop is saved.

> Note that desktop-dirname appears in the documentation of other
> options, which can lead to the idea that it can be customized. For
> example:
> 
> ```
> (defcustom desktop-save 'ask-if-new
>   "Specifies whether the desktop should be saved when it is killed.
> ...
> The variables `desktop-dirname' and `desktop-base-file-name'
> determine where the desktop is saved."
> ```

Yes, because various commands, like desktop-save, desktop-read,
desktop-change-dir, and others, set the variable.

> > If users customize desktop-dirname to some value, and desktop.el will be forced to use this value unconditionally (as it should do with user options), then this feature will be lost.
> 
> Since the user can only have one desktop active at a time, it
> shouldn't be problematic but I now understand that's not ideal. In
> that case, what about introducing a new option that feeds the
> variable? Unless there are already other alternatives.

See above: there are already other alternatives.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76561; Package emacs. (Tue, 25 Feb 2025 20:05:01 GMT) Full text and rfc822 format available.

Message #17 received at 76561 <at> debbugs.gnu.org (full text, mbox):

From: João Guerra <joca.bt <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76561 <at> debbugs.gnu.org
Subject: Re: bug#76561: [PATCH] Promote desktop-dirname to a defcustom
Date: Tue, 25 Feb 2025 21:03:42 +0100
Hi Eli, I was just testing it out again and overriding desktop-path is
enough for the behaviour I was looking for. No need to manually run
desktop-save or anything (which I wanted to avoid on the first run).
I'm flabbergasted. I'm not sure why I was always overriding it. I've
also seen similar configurations doing the same (e.g. no-littering).

It seems as desktop-read sets desktop-dirname even if a file is not
actually read due to not existing.

Thanks!

On Tue, 25 Feb 2025 at 20:43, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: João Guerra <joca.bt <at> gmail.com>
> > Date: Tue, 25 Feb 2025 19:12:37 +0100
> > Cc: 76561 <at> debbugs.gnu.org
> >
> > Hello, the idea is to allow the user to customize where the desktop
> > file is saved by default. Currently, the user can only customize the
> > name for the file, its lock, and the directories where to search for
> > desktop files for loading.
>
> That's not true: if you invoke "M-x desktop-save", it will prompt you
> for the directory in which to save, and will record that directory in
> the desktop-dirname variable for future saves.  This is one way users
> have today to customize where the desktop is saved.
>
> > Note that desktop-dirname appears in the documentation of other
> > options, which can lead to the idea that it can be customized. For
> > example:
> >
> > ```
> > (defcustom desktop-save 'ask-if-new
> >   "Specifies whether the desktop should be saved when it is killed.
> > ...
> > The variables `desktop-dirname' and `desktop-base-file-name'
> > determine where the desktop is saved."
> > ```
>
> Yes, because various commands, like desktop-save, desktop-read,
> desktop-change-dir, and others, set the variable.
>
> > > If users customize desktop-dirname to some value, and desktop.el will be forced to use this value unconditionally (as it should do with user options), then this feature will be lost.
> >
> > Since the user can only have one desktop active at a time, it
> > shouldn't be problematic but I now understand that's not ideal. In
> > that case, what about introducing a new option that feeds the
> > variable? Unless there are already other alternatives.
>
> See above: there are already other alternatives.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Tue, 25 Feb 2025 23:13:02 GMT) Full text and rfc822 format available.

Notification sent to João Guerra <joca.bt <at> gmail.com>:
bug acknowledged by developer. (Tue, 25 Feb 2025 23:13:02 GMT) Full text and rfc822 format available.

Message #22 received at 76561-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: João Guerra <joca.bt <at> gmail.com>, 
 Eli Zaretskii <eliz <at> gnu.org>
Cc: 76561-done <at> debbugs.gnu.org
Subject: Re: bug#76561: [PATCH] Promote desktop-dirname to a defcustom
Date: Tue, 25 Feb 2025 23:12:47 +0000
João Guerra <joca.bt <at> gmail.com> writes:

> Hi Eli, I was just testing it out again and overriding desktop-path is
> enough for the behaviour I was looking for. No need to manually run
> desktop-save or anything (which I wanted to avoid on the first run).
> I'm flabbergasted. I'm not sure why I was always overriding it. I've
> also seen similar configurations doing the same (e.g. no-littering).

We also have `desktop-path`.  Mine is set to

    '("~/.emacs.d/cache" "~/.emacs.d/" "~")

and it seems to always DTRT, i.e. save the desktop file to

    ~/.emacs.d/cache/

It seems like there was no bug here, so I'm closing this now.

If this conclusion is incorrect and this is still an issue, please reply
to this email (use "Reply to all" in your email client) and we can
reopen the bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 26 Mar 2025 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 80 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.