I'm happy enough with the default M-w as (kill-ring-save) which loses the region's highlighting upon running the command. I don't want to alter its behaviour, but I do want to re-bind <C-insert> to perform a similar action and maintain the region's highlighting.
I've tried (un)setting transient-mark-mode directly and via a function, but the region still loses its highlighting.
Running only (kill-ring-save (region-beginning) (region-end)) in an interactive function works as expected, ie. it loses highlighting.
Running only (exchange-point-and-mark) (exchange-point-and-mark) in an interactive function works as expected, ie. it re-highlights the region and puts/leaves point in its original/correct place.
However when I put them all together in a function, it does not re-highlight the region. Here is non-functioning function and binding:
(defun kill-ring-save-keep-highlight ()
(interactive)
(kill-ring-save (region-beginning) (region-end))
(exchange-point-and-mark) (exchange-point-and-mark)
)
(global-unset-key (kbd "<C-insert>"))
(global-set-key (kbd "<C-insert>") 'kill-ring-save-keep-highlight)
Using: GNU Emacs 23.1.1 in Ubuntu 10.04.3
activate-mark, but it still doesn't work. I even installed a clean-slate VM of Ubuntu 11.04 with the only code in.emacsbeing this function, but it still doesn't activate the mark, yet manually applyingC-x C-ximmediately afterC-insertdoes reinstate the highlighting... – Peter.O Sep 16 '11 at 21:35emacs -qwith the code and check to see if it works. – Trey Jackson Sep 16 '11 at 22:52~/.emacsand without anything in~/.emacs.d/, and as mentioned, also in a brand-new install of emacs in a brand new VM.... I've now tried this command, but it too doesn't work:/usr/bin/emacs --no-init-file --no-site-file --eval '(defun kill-ring-save-keep-highlight (beg end) (interactive "r") (kill-ring-save beg end) (activate-mark))'... Does the function work foryou? – Peter.O Sep 17 '11 at 01:21