In most modern editors, after canceling a selection by a left/right motion, the cursor will be moved to the beginning/end of the previously-selected region correspondingly. Similarly, if we cancel a selection by a up/down motion, the cursor will be moved up/down one line from the beginning/end of the previously-selected region correspondingly.
Could we have the same behaviors in Emacs under shift-select-mode
?
I tried to define my own movement function:
(bind-key* "M-l"
(lambda (arg)
(interactive "^p")
(if (use-region-p)
(goto-char (region-end))
(syntax-subword-forward arg))))
But it doesn't work. The goto-char
never run even if I am selecting a region. Is it because I used (interactive "^p")
? Any solution?
C-x C-x
. Thus, in shift selection mode, an unshifted motion command exits the selection at the end that you've been focusing on (moving the cursor), and you pressC-x C-x
first to exit the selection at the other end.