1

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?;)

shynur
  • 4,065
  • 1
  • 3
  • 23
Jason Hunter
  • 519
  • 2
  • 9

1 Answers1

2

You 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)
Drew
  • 75,699
  • 9
  • 109
  • 225