[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 564cac7 1/3: Add option to stop updating X PRIMARY se
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 564cac7 1/3: Add option to stop updating X PRIMARY selection with the current visual region |
Date: |
Tue, 16 Nov 2021 16:57:47 -0500 (EST) |
branch: elpa/evil
commit 564cac7233d0000e51def7608f60d1dd14811c16
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Add option to stop updating X PRIMARY selection with the current visual
region
Vim user can select a region in visual mode and press the key `p` to
replace the selected text.
But in GUI Emacs, the selected text might not be replaced when:
- `select-enable-primary` is `t`
- Third plugins override `interprogram-paste-function` (xclip.el, for
example)
- Clipboard managers syncronise data between PRIMARY and CLIPBOARD selection
It's because the visual commands automatically insert the content of
visually
selected region into X PRIMARY selection. But paste commands call the api
`current-kill` which calls `interprogram-paste-function`.
Value of `interprogram-paste-function` is `gui-selection-value` which
might return CLIPBOARD or PRIMARY selection.
---
doc/docstringdb.json | 11 +++++++++++
evil-states.el | 21 +++++++++++----------
evil-vars.el | 5 +++++
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/doc/docstringdb.json b/doc/docstringdb.json
index 96695ec..466ef38 100644
--- a/doc/docstringdb.json
+++ b/doc/docstringdb.json
@@ -17052,5 +17052,16 @@
"functionp": true,
"macrop": null,
"keymap-inv": null
+ },
+ "evil-visual-update-x-selection-p": {
+ "default": "t",
+ "local": false,
+ "default-type": "symbol",
+ "var-docstring": "Whether to update the X PRIMARY selection with the
current visual region automatically.",
+ "fn-docstring": null,
+ "arglist": true,
+ "functionp": null,
+ "macrop": null,
+ "keymap-inv": null
}
}
\ No newline at end of file
diff --git a/evil-states.el b/evil-states.el
index 3d9a4c1..3781a65 100644
--- a/evil-states.el
+++ b/evil-states.el
@@ -364,16 +364,17 @@ otherwise exit Visual state."
(put 'evil-visual-post-command 'permanent-local-hook t)
(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)
- (display-selections-p)
- (not (eq evil-visual-selection 'block)))
- (evil-set-selection 'PRIMARY (buffer-substring-no-properties
- evil-visual-beginning
- evil-visual-end)))))))
+ "Update the X selection with the current visual region of BUFFER."
+ (when evil-visual-update-x-selection-p
+ (let ((buf (or buffer (current-buffer))))
+ (when (buffer-live-p buf)
+ (with-current-buffer buf
+ (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."
diff --git a/evil-vars.el b/evil-vars.el
index 42a45a1..b87814b 100644
--- a/evil-vars.el
+++ b/evil-vars.el
@@ -2038,6 +2038,11 @@ to `undo-redo', Evil uses commands natively available in
Emacs 28."
(evil-set-undo-system value)
(set-default sym value)))
+(defcustom evil-visual-update-x-selection-p t
+ "Whether to update the X PRIMARY selection with the current visual region
automatically."
+ :type 'boolean
+ :group 'evil)
+
(defun evil-version ()
(interactive)
(message "Evil version %s" evil-version))