Subject: Re: bug#76561: [PATCH] Promote desktop-dirname to a defcustom

From: João Guerra <[email-masked]>
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 <[email-masked]> wrote:
>
> > From: João Guerra <[email-masked]>
> > 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?= <[email-masked]>
> > 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.