Subject: bug#29972: 25.3; dired-hide-details-mode does not persist in desktop session

From: Jimmy Yuen Ho Wong <[email-masked]>
Date: Fri, 5 Jan 2018 13:08:35 +0000

I don't believe so. I've looked at a number of approaches.

1. `desktop-minor-mode-handlers` on desktop-read
    Not going to be consulted unless `dired-hide-details-mode` is saved as
a buffer minor mode.
2. `desktop-minor-mode-table` on desktop-save
    If `dired-hide-details-mode` is not in `minor-mode-alist`,
`desktop-minor-mode-table` will not even be consulted.
3. `desktop-locals-to-save`
    This does save the minor mode local variable to the desktop file, but
desktop won't be able to restore the minor mode because minor modes are
activated before buffer local variables are restored, not after.

So the only choices left to me are:
- :lighter ""
- (add-minor-mode 'dired-hide-details-mode "")

Either way adds an empty string as a lighter, and the second option makes
you ask why you are declaring *and* adding a minor mode, so I picked the
first option. It's more concise.

Jimmy Wong

On Thu, Jan 4, 2018 at 4:42 PM, Eli Zaretskii <[email-masked]> wrote:

> > From: Yuen Ho Wong <[email-masked]>
> > Date: Thu, 04 Jan 2018 01:11:13 +0000
> >
> > How to reproduce:
> > 1. Turn on `desktop-save-mode`
> > 2. dired some directory
> > 3. Press `(` to turn on `dired-hide-details-mode`
> > 4. C-x C-c, when asked to save desktop, choose yes
> > 5. Launch emacs again, desktop restored the dired buffer but not
> > `dired-hide-details-mode`
> >
> > What went wrong:
> > `dired-hide-details-mode`'s definition does not declare a lighter or a
> > keymap, thus it is not added to `minor-mode-alist` by
> > `define-minor-mode`. So when `desktop` tries to get the buffer's info to
> > save to `.emacs.desktop` via `desktop-buffer-info`,
> > `dired-hide-details-mode` does not exist, and thus not saved to the
> > session file.
> >
> > Fix:
> > Just declare an empty lighter. I've attached a patch for this.
>
> Can't you instead customize desktop-locals-to-save?
>