Skip to content

Commit

Permalink
Use x-get-selection for accessing selection with conversion (re ema…
Browse files Browse the repository at this point in the history
…cs-evil#580)

Hopefully, this code is platform independent.
  • Loading branch information
f-fr committed Oct 5, 2015
1 parent f4bf96e commit 3841842
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -2020,10 +2020,23 @@ The following special registers are supported.
(let ((reg (- register ?1)))
(and (< reg (length kill-ring))
(current-kill reg t))))
((eq register ?*)
(x-selection-value-internal 'PRIMARY))
((eq register ?+)
(x-selection-value-internal 'CLIPBOARD))
((memq register '(?* ?+))
;; the following code is modified from
;; `x-selection-value-internal'
(let ((what (if (eq register ?*) 'PRIMARY 'CLIPBOARD))
(request-type (or (and (boundp 'x-select-request-type)
x-select-request-type)
'(UTF8_STRING COMPOUNT_TEXT STRING)))
text)
(unless (consp request-type)
(setq request-type (list request-type)))
(while (and request-type (not text))
(condition-case nil
(setq text (x-get-selection what (pop request-type)))
(error nil)))
(when text
(remove-text-properties 0 (length text) '(foreign-selection nil) text))
text))
((eq register ?\C-W)
(unless (evil-ex-p)
(user-error "Register <C-w> only available in ex state"))
Expand Down

0 comments on commit 3841842

Please sign in to comment.