* [PATCH] Use deactivate-mark from cua-cancel
@ 2020-06-07 8:20 Andrew Burgess
2020-06-20 7:45 ` Eli Zaretskii
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Burgess @ 2020-06-07 8:20 UTC (permalink / raw)
To: emacs-devel; +Cc: Andrew Burgess
Create a config file ~/tmp/setup.el containing:
(defun cursor-activate-mark ()
(setq cursor-type 'bar))
(add-hook 'activate-mark-hook 'cursor-activate-mark)
(defun cursor-deactivate-mark ()
(setq cursor-type 'box))
(add-hook 'deactivate-mark-hook 'cursor-deactivate-mark)
Start emacs like this:
emacs -Q -l ~/tmp/setup.el ~/tmp/setup.el
Now do the following:
M-x set-mark-command
M-x forward-paragraph
C-g
You should see that after `set-mark-command` the cursor changes from
box to bar, then after the C-g (`keyboard-quit`) the cursor changes
back to box.
Now do:
M-x cua-selection-mode
M-x set-mark-command
M-x forward-paragraph
C-g
In this case the cursor should still change from box to bar when the
mark is set, but after the C-g the cursor will be left as a bar.
The reason is that with `cua-selection-mode` enabled, C-g now calls
`cua-cancel` instead of `keyboard-quit`. Currently `cua-cancel` looks
like this:
(defun cua-cancel ()
"Cancel the active region, rectangle, or global mark."
(interactive)
(setq mark-active nil)
(if (fboundp 'cua--cancel-rectangle)
(cua--cancel-rectangle)))
It is the line:
(setq mark-active nil)
that is problematic, setting `mark-active` directly avoids the
`deactivate-mark-hook`. I think that instead we should be calling
`deactivate-mark`, and this is what this patch does.
* lisp/emulation/cua-base.el (cua-cancel): Use deactivate-mark
instead of setting mark-active directly.
---
lisp/emulation/cua-base.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index 26a1a8955f..c4dcb76446 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -860,7 +860,7 @@ With numeric prefix arg, copy to register 0-9 instead."
(defun cua-cancel ()
"Cancel the active region, rectangle, or global mark."
(interactive)
- (setq mark-active nil)
+ (deactivate-mark)
(if (fboundp 'cua--cancel-rectangle)
(cua--cancel-rectangle)))
--
2.25.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Use deactivate-mark from cua-cancel
2020-06-07 8:20 [PATCH] Use deactivate-mark from cua-cancel Andrew Burgess
@ 2020-06-20 7:45 ` Eli Zaretskii
0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2020-06-20 7:45 UTC (permalink / raw)
To: Andrew Burgess; +Cc: emacs-devel
> From: Andrew Burgess <andrew.burgess@embecosm.com>
> Date: Sun, 7 Jun 2020 09:20:19 +0100
> Cc: Andrew Burgess <andrew.burgess@embecosm.com>
>
> The reason is that with `cua-selection-mode` enabled, C-g now calls
> `cua-cancel` instead of `keyboard-quit`. Currently `cua-cancel` looks
> like this:
>
> (defun cua-cancel ()
> "Cancel the active region, rectangle, or global mark."
> (interactive)
> (setq mark-active nil)
> (if (fboundp 'cua--cancel-rectangle)
> (cua--cancel-rectangle)))
>
> It is the line:
>
> (setq mark-active nil)
>
> that is problematic, setting `mark-active` directly avoids the
> `deactivate-mark-hook`. I think that instead we should be calling
> `deactivate-mark`, and this is what this patch does.
Thanks, pushed to the master branch.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-20 7:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-07 8:20 [PATCH] Use deactivate-mark from cua-cancel Andrew Burgess
2020-06-20 7:45 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).