Subject: bug#19058: [PATCH] Desktop restore fails to run mark activation hooks when it should

From: Kelly Dean <[email-masked]>
Date: Sat, 15 Nov 2014 06:56:28 +0000

Delete your .emacs.desktop, and put in init.el:

(desktop-save-mode 1)
(add-hook 'deactivate-mark-hook (lambda () (setq cursor-type t)))
(add-hook 'activate-mark-hook (lambda () (setq cursor-type 'bar)))

Start Emacs 24.4, open a file, press C-SPC, then exit Emacs and save the desktop, then restart Emacs. Notice that the cursor type is now a block, not a bar. It should be a bar.

This bug wasn't in 24.3, and is the opposite of bug 14430. The fix for this new bug is the same patch that I already sent on May 20, 2013 for that bug (my patch fixed that bug without introducing this new bug). That patch wasn't accepted, and instead this new bug and a FIXME comment were introduced into desktop.el for 24.4.

This new bug could be fixed without applying that patch by instead applying second-restoremarkbug.bad-patch that's attached to this message (conditionally calling activate-mark as the new FIXME proposes), but that's a hack that invites future bugs when somebody modifies set-mark and forgets to correspondingly modify the code in desktop-create-buffer that duplicates the functionality of set-mark. The right fix is to not duplicate the functionality of set-mark, and instead just call set-mark and tell it whether to call activate-mark, as my original patch did.

I've been asked to not send any more patches to apply to Emacs, but this new patch is just to point out what NOT to apply, so I trust it's ok to send it.

Of course, nobody besides me cares about this bug, but its existence serves as a convenient excuse for me to ask Stefan to please add the dont-activate option to set-mark so I don't have to maintain it anymore in my personal patches. ;-)