aboutsummaryrefslogtreecommitdiff
path: root/evil-states.el
diff options
context:
space:
mode:
authorFrank Fischer <frank.fischer@mathematik.tu-chemnitz.de>2012-07-28 22:15:30 +0200
committerFrank Fischer <frank.fischer@mathematik.tu-chemnitz.de>2012-07-28 22:15:30 +0200
commitb91db8d77aafb707c9287cbdbe5a32138427872e (patch)
treedbf78331e431a77660ff333aa2870e99643604c8 /evil-states.el
parentce1f8debc3b9f29b115b708da4af1fb8a1d12356 (diff)
Update X selection according to visual state region
When *selecting* some visual region then the X selection should be updated according to the values of `x-select-enable-primary' and `x-select-enable-clipboard'. The default Emacs behavior is to update the X selection whenever the mark is changed if `select-active-regions' is non-nil. This usually interferes with Evil visual state because then the visual selection does not correspond to the Emacs region. This patch sets this variable to temporarily to nil during visual state so Evil takes responsibility for the X selection. The X selection is updated in `evil-visual-post-command' by calling `x-select-text' with the appropriate values. This update does not work in block visual state. This addresses issue #110. This addresses issue #158.
Diffstat (limited to 'evil-states.el')
-rw-r--r--evil-states.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/evil-states.el b/evil-states.el
index 33bbaa2..a644e59 100644
--- a/evil-states.el
+++ b/evil-states.el
@@ -199,6 +199,7 @@ the selection is enabled.
(cond
((evil-visual-state-p)
(evil-save-transient-mark-mode)
+ (setq select-active-regions nil)
(cond
((region-active-p)
(if (< (evil-visual-direction) 0)
@@ -239,6 +240,7 @@ Expand the region to the selection unless COMMAND is a motion."
;; unless the command has real need of it
(and (eq (evil-visual-type) 'line)
(evil-get-command-property command :exclude-newline))))))
+
(put 'evil-visual-pre-command 'permanent-local-hook t)
(defun evil-visual-post-command (&optional command)
@@ -259,9 +261,17 @@ otherwise exit Visual state."
(evil-adjust-cursor))
(evil-visual-region-expanded
(evil-visual-contract-region)
+ (unless (eq evil-visual-selection 'block)
+ (x-select-text (buffer-substring-no-properties
+ evil-visual-beginning
+ evil-visual-end)))
(evil-visual-highlight))
(t
(evil-visual-refresh)
+ (unless (eq evil-visual-selection 'block)
+ (x-select-text (buffer-substring-no-properties
+ evil-visual-beginning
+ evil-visual-end)))
(evil-visual-highlight)))))
(put 'evil-visual-post-command 'permanent-local-hook t)