Subject: bug#55560: 29.0.50; kill-emacs on daemon doesn't remove ~/.emacs.d/.emacs.desktop.lock

From: Eli Zaretskii <[email-masked]>
Date: Sat, 21 May 2022 22:50:40 +0300

> From: Peter Ludemann <[email-masked]>
> Date: Sat, 21 May 2022 12:16:50 -0700
> 
> I started emacs with "emacs --daemon". I stopped it with the
> "kill-emacs" command. Emacs stopped, but the desktop lock file
> remained. Following is the my console (not showing the
> "emacs --daemon" command).
> 
> I'm pretty sure that older emacsen deleted the lock file 
> when the daemon was stopped, so this looks like a 
> regression. If it makes a difference, there was an 
> existing .emacs.desktop file when I started the daemon.

This was a deliberate change in Emacs 28.1: the function that deletes
the desktop lock file is now on kill-emacs-query-functions, and that
hook is not called from kill-emacs (because kill-emacs isn't supposed
to prompt the user, and desktop-kill sometimes need to prompt).

Why are you stopping Emacs will kill-emacs?  The right way of doing
that is to invoke save-buffers-kill-emacs instead, which _will_ delete
the desktop lock file.