Subject: [PATCH] kill-region fails to deactivate mark after cutting empty region
From: Kelly Dean <[email-masked]>
To: [email-masked]
Date: Thu, 13 Dec 2012 00:19:16 -0800 (PST)
List-Id: <debbugs-submit.debbugs.gnu.org>

On 24.2, emacs -Q
C-SPC M-w C-p
kill-ring-save copied an empty region, and deactivated the mark. This is correct. But now do
C-SPC C-w C-p
kill-region cut an empty region, which is correct, but the mark is still active, which is incorrect. When the buffer and text aren't read-only, kill-region relies on the command loop to deactivate the mark after the buffer is modified, but when cutting an empty region, the buffer isn't modified, so the mark is never deactivated.
The attached killregionbug.patch fixes it.

--- emacs-24.2/lisp/simple.el	2012-08-22 22:33:42.000000000 -0700
+++ emacs-24.2/lisp/simple.el.new2	2012-12-12 22:52:46.258462306 -0800
@@ -3233,6 +3233,7 @@
 	    (kill-new string nil yank-handler)))
 	(when (or string (eq last-command 'kill-region))
 	  (setq this-command 'kill-region))
+	(setq deactivate-mark t)
 	nil)
     ((buffer-read-only text-read-only)
      ;; The code above failed because the buffer, or some of the characters