Subject: Re: bug#30421: 25.3; desktop.el: Steal lock when no living "emacs" process owns it

From: Eli Zaretskii <[email-masked]>
Date: Sat, 24 Feb 2018 22:09:26 +0200

> From: Pierre Neidhardt <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Sat, 24 Feb 2018 20:44:45 +0100
> 
> Correct me if I did not understand your instructions correctly.  I did this:
> 
> - Add this to my init.el
> 
>   (defun ambrevar/desktop-init ()
>     (desktop-save-mode)
>     (desktop-read)
>     (remove-hook 'server-switch-hook 'ambrevar/desktop-init))
>   (add-hook 'server-switch-hook 'ambrevar/desktop-init)
> 
> - Kill Emacs, leaving a .emacs.desktop.lock behind.
> 
> - Switch to a TTY.
> 
> - Start `emacs --daemon`.
> 
> - Run `emacsclient foo`.

Yes.

> I correctly get prompted if I want to load the desktop then.

OK, thanks for testing.

So like I said, we need a new hook, which would be called when the
server creates a frame, but doesn't switch to any new buffers in that
frame.

> Running `emacsclient -t` does not trigger the desktop loading, but I
> guess that's to be expected.

Right, because in that case server-switch-hook is not run.