diff options
| author | Hans-Peter Deifel <hpd@hpdeifel.de> | 2018-01-11 18:12:32 +0100 |
|---|---|---|
| committer | Hans-Peter Deifel <hpd@hpdeifel.de> | 2018-01-11 19:48:59 +0100 |
| commit | 31375555e5f91947fb2b2c7abe885a2811b5770e (patch) | |
| tree | 3990ee0ae07c6fc6e52761ee9fbf24d78214fd32 /evil-states.el | |
| parent | 49d6167d6bb97454afe1d06a5324483682de8ab6 (diff) | |
Copy text to PRIMARY, not CLIPBOARD in visual mode
Previously, the selected text in visual mode was copied to the X
CLIPBOARD, while 'normal' Emacs copies the active region to the
PRIMARY selection (controlled by `select-active-regions`). The latter
is also what the major X toolkits do by default.
This changes evil-visual-update-x-selection to use the PRIMARY
selection and also...
- Uses the wrapper `evil-set-selection` instead of the obsolete
`x-select-text`
- Tests for `display-selections-p` instead of boundness of
`x-select-text` or `ns-initialized`
Diffstat (limited to 'evil-states.el')
| -rw-r--r-- | evil-states.el | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/evil-states.el b/evil-states.el index 9655b65..309ec27 100644 --- a/evil-states.el +++ b/evil-states.el @@ -350,17 +350,13 @@ otherwise exit Visual state." (defun evil-visual-update-x-selection (&optional buffer) "Update the X selection with the current visual region." - (let ((buf (or buffer (current-buffer)))) - (when (buffer-live-p buf) - (with-current-buffer buf - (when (and (evil-visual-state-p) - (fboundp 'x-select-text) - (or (not (boundp 'ns-initialized)) - (with-no-warnings ns-initialized)) - (not (eq evil-visual-selection 'block))) - (x-select-text (buffer-substring-no-properties - evil-visual-beginning - evil-visual-end))))))) + (with-current-buffer (or buffer (current-buffer)) + (when (and (evil-visual-state-p) + (display-selections-p) + (not (eq evil-visual-selection 'block))) + (evil-set-selection 'PRIMARY (buffer-substring-no-properties + evil-visual-beginning + evil-visual-end))))) (defun evil-visual-activate-hook (&optional command) "Enable Visual state if the region is activated." |
