visual-mode and X-selections
Frank Fischer
frank-fischer at shadow-soft.de
Thu Nov 1 16:54:27 CET 2012
On 2012-11-01, Hans-Peter Deifel <hpdeifel at gmx.de> wrote:
> Hi List!
>
> I think that the interaction between visual-mode and the X11 selections
> is not optimal. Since I don't know if the current behavior is
> intentional, I haven't yet opened a bug report.
>
> The selected text in visual-mode is currently copied via the function
> x-select-text. With the Emacs 24.1 default configuration, this copies to
> the X-selection CLIPBOARD (configurable through
> x-select-enable-clipboard and x-select-enable-primary.)
>
> In the rest of Emacs, this function is only used for the explicit
> copy/yank commands. Copying the active region is controlled by the
> variable select-active-regions and uses the PRIMARY X-selection by
> default.
>
> This behavior is consistent with most other X applications: The mouse
> selection is saved in PRIMARY and the explicit copy/paste commands use
> the CLIPBOARD.
>
> Thus, it would be nice if Evil would also use the PRIMARY selection by
> default for the selected text in visual-mode.
If this works on all other platforms as well (also compared with Vim),
then that's fine with me. I remember that I had some trouble with
MacOS and this x-selection stuff. Unfortunately I do not have access
to a Mac or to a Windows machine, so it would be nice if others could
verify that this change works there, too (in all settings, i.e
graphical environment and terminal, Emacs 23 and Emacs 24).
I would change the "fbound" line, though.
#+BEGIN_SRC elisp
(defun evil-visual-update-x-selection (&optional buffer)
"Update the X selection with the current visual region."
(with-current-buffer (or buffer (current-buffer))
(when (and (evil-visual-state-p)
(fboundp 'x-set-selection) ; <-- small change, hope it works ;)
(or (not (boundp 'ns-initialized))
(with-no-warnings ns-initialized))
(not (eq evil-visual-selection 'block)))
(x-set-selection 'PRIMARY (buffer-substring-no-properties
evil-visual-beginning
evil-visual-end))
(setq x-last-selected-text-primary ))))
#+END_SRC
Best
Frank
More information about the implementations-list
mailing list