When I copy some selected text (kill-ring-save
with M-w
), I automatically lose my selection. I have tried with Transient Mark Mode with no luck. (Note that I'm not using CUA Mode.)
1 Answer
The best solution is using C-x C-x
to reactivate the mark.
But if you want to really keep the selection you can use:
(defun copy-keep-highlight (beg end)
(interactive "r")
(prog1 (kill-ring-save beg end)
(setq deactivate-mark nil)))
-
1I'd suggest using a piece of advice like this :
(defun yf/no-deactivate-mark (&rest _) (setq deactivate-mark nil)) (advice-addadvice-add 'kill-ring-save :after #'yf/no-deactivate-mark)
Feb 1, 2016 at 10:48 -
-
@YoungFrog, thanks, but your code doesn't work as its got a syntax error somewhere.– NVaughanFeb 2, 2016 at 1:19
-
2Ah, copy paste error :
advice-add
should be there only once. I can't edit the comment. Feb 2, 2016 at 9:20 -
1@NVaughan here a good explanation: emacs.stackexchange.com/questions/5829/… Feb 2, 2016 at 11:10
select-active-regions
would be relevant), but it seems to be about highlighting the region.