help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mark set by ‘mark-*’ not deactivated by point motion


From: Yuri Khan
Subject: Mark set by ‘mark-*’ not deactivated by point motion
Date: Tue, 18 Sep 2018 00:25:31 +0700

Hello,

the raging discussion about the region models in emacs-devel reminded
me of an annoyance that I never took the time to report.

$ emacs -Q
M-x emacs-version
→ GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
of 2018-05-29
M-: transient-mark-mode
→ t
M-: shift-select-mode
→ t

1. Move point before the word “buffer” in the first line in *scratch*.
2. Press M-@ for ‘mark-word’. Observe that the mark is set after the
word ”buffer” and activated.
3. Move point with an unshifted point motion key.

Observed behavior: point moves as commanded, mark remains active.

Expected behavior: point moves, mark is deactivated.

Carefully looking at the docstring of shift-select-mode and the
implementation code in simple.el, I see that unshifted point motion
keys only deactivate mark if it was activated by shift-selection, but
it runs against my general expectation that selection goes away after
any motion that is not specifically directed to extend/shrink
selection. The only exception I’d make is C-SPC ‘set-mark-command’
because I see that as an explicit command to start marking an active
region without holding down Shift (e.g. as a workaround for terminals
that do not report Shift+arrows to the application).

Pre-emptive counterarguments:

“You could use Ctrl+Shift+<right> to mark a word in a way that will be
deactivate on motion.” — Yes, but the issue also affects mark-sexp,
mark-end-of-sentence, mark-paragraph, mark-defun, and mark-page, and
not all of these have shift-translatable motion equivalent. (E.g.
forward-paragraph is on M-} which is already shifted, and forward-page
is on C-x ] whose shifted version, C-x }, is bound to
enlarge-window-horizontally.)

“You could advise mark-* so that they set transient-mark-mode the same
way as shift-selection does.” — Why yes, I could. Thanks.

(defun yk-mark-*:after (&rest _args)
  (setq-local transient-mark-mode (cons 'only transient-mark-mode)))

(advice-add 'mark-word :after 'yk-mark-*:after)
(advice-add 'mark-sexp :after 'yk-mark-*:after)
…
(advice-add 'mark-whole-buffer :after 'yk-mark-*:after)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]