How can I programmatically define a secondary selection with beginning and end defined?;)
I try to look for this, but only find mouse usage;)
Any pointers?;)
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityYou can use library second-sel.el
to do what you want (and more) with secondary selections. See description here, along with other info about the secondary selection.
In particular, you can set the secondary selection using Lisp code or using the keyboard. And you can have a ring of secondary selections, just like the ring (kill-ring
) of primary selections.
Here are some key bindings you might want to use:
(global-set-key (kbd "C-M-y") 'secondary-yank|select|move|swap)
(define-key esc-map "y" 'yank-pop-commands)
(define-key isearch-mode-map (kbd "C-M-y") 'isearch-yank-secondary)
(global-set-key (kbd "C-x C-M-SPC") 'set-secondary-start)
(global-set-key (kbd "C-x C-M-<return>") 'secondary-save-then-kill)
(global-set-key (kbd "C-M-<mouse-3>") 'mouse-secondary-save-then-kill)
But the quick answer to your question is to just do this, where BEG and END are the limits you want for the secondary selection:
(secondary-swap-region BEG END)