Emacs 25 yank of x windows PRIMARY keyboard clipboard

Using Emacs 25 in linux environment, I often copy text with the mouse and want me to be able to paste the copied text with some command in Emacs, but currently the only way I know is with the middle mouse click, which is linked for mouse yankee primary.

I tried to associate this with a key command and also set true-mouse-at-point true, but this (as I suspected) requires the mouse event to work correctly, and I'm not sure how to make Emacs believe that the mouse event disappeared from - by pressing a key.

Does anyone have any ideas? Or just know the right way to pull the keyboard out of the PRIMARY selection?

+5
source share
3 answers

Looking around thanks to the Christian answer, I found select.el and came up with the following to paste into my .emacs

;; Pull from PRIMARY (same as middle mouse click) (defun get-primary () (interactive) (insert (gui-get-primary-selection))) (global-set-key "\Cc\Cy" 'get-primary) 

Edit: As Stefan noted, gui-get-primary-selection (and more generally, gui-get-selection) is only available in Emacs 25 and later. In Emacs 25.1, x-get-selection was deprecated.

+8
source

I was just annoyed by the emacs default behavior of inserting a secondary X-pick in S-insert and found this thread. I tried using code from Silfheed, but emacs 24 does not have a function like "gui-get-primary-selection". So I looked at the source of "mouse-yank-primary" and came up with this alternative solution:

 ;; Pull from PRIMARY (same as middle mouse click) (defun paste-primary-selection () (interactive) (insert (x-get-selection 'PRIMARY))) (global-set-key (kbd "S-<insert>") 'paste-primary-selection) 

Thus, s-insert inserts the main X-selection at the cursor position - just like in xterm ...

+4
source

Try installing this:

 (setq select-enable-clipboard t) 

thus, normal kill / yank commands (e.g. Cw and Cy) will work with the clipboard. It works on both X11 and OSX (and, in my opinion, Windows as well).

If you refer to the documentation for this variable (for example, via Ch v), you should make the following sentence:

 You can customize this variable. 

where "configure" is a link that you can click. This will lead you to the Emacs configuration system, which provides a simpler and more manageable way to configure Emacs. In particular, it will show you a lot about the controls that may be related to customization. Even you do not want to control your configuration in this way, you can use it as a guide to important variables for installation and to what they can be set.

+1
source

Source: https://habr.com/ru/post/1212934/


All Articles