2096 |
"The value of the PRIMARY X selection last time we selected or |
"The value of the PRIMARY X selection last time we selected or |
2097 |
pasted text.") |
pasted text.") |
2098 |
(defvar x-last-selected-text-cut nil |
(defvar x-last-selected-text-cut nil |
2099 |
"The value of the X cut buffer last time we selected or pasted text.") |
"The value of the X cut buffer last time we selected or pasted text. |
2100 |
|
The actual text stored in the X cut buffer is what encoded from this value.") |
2101 |
|
(defvar x-last-selected-text-cut-encoded nil |
2102 |
|
"The value of the X cut buffer last time we selected or pasted text. |
2103 |
|
This is the actual text stored in the X cut buffer.") |
2104 |
|
|
2105 |
;;; It is said that overlarge strings are slow to put into the cut buffer. |
;;; It is said that overlarge strings are slow to put into the cut buffer. |
2106 |
;;; Note this value is overridden below. |
;;; Note this value is overridden below. |
2123 |
;; It becomes slow, and if really big it causes errors. |
;; It becomes slow, and if really big it causes errors. |
2124 |
(cond ((>= (length text) x-cut-buffer-max) |
(cond ((>= (length text) x-cut-buffer-max) |
2125 |
(x-set-cut-buffer "" push) |
(x-set-cut-buffer "" push) |
2126 |
(setq x-last-selected-text-cut "")) |
(setq x-last-selected-text-cut "" |
2127 |
;; Don't store a multibyte string that contains |
x-last-selected-text-cut-encoded "")) |
|
;; eight-bit-control/graphic chars because they can't be |
|
|
;; restored correctly by x-get-cut-buffer. |
|
|
((and (multibyte-string-p text) |
|
|
(let ((charsets (find-charset-string text))) |
|
|
(or (memq 'eight-bit-control charsets) |
|
|
(memq 'eight-bit-graphic charsets)))) |
|
|
(x-set-cut-buffer "" push) |
|
|
(setq x-last-selected-text-cut "")) |
|
2128 |
(t |
(t |
2129 |
(x-set-cut-buffer text push) |
(setq x-last-selected-text-cut text |
2130 |
(setq x-last-selected-text-cut text))) |
x-last-selected-text-cut-encoded |
2131 |
|
(encode-coding-string text (or locale-coding-system |
2132 |
|
'iso-latin-1))) |
2133 |
|
(x-set-cut-buffer x-last-selected-text-cut-encoded push))) |
2134 |
(x-set-selection 'PRIMARY text) |
(x-set-selection 'PRIMARY text) |
2135 |
(setq x-last-selected-text-primary text) |
(setq x-last-selected-text-primary text) |
2136 |
(when x-select-enable-clipboard |
(when x-select-enable-clipboard |
2290 |
;; from what we remebered them to be last time we did a |
;; from what we remebered them to be last time we did a |
2291 |
;; cut/paste operation. |
;; cut/paste operation. |
2292 |
(setq cut-text |
(setq cut-text |
2293 |
(cond;; check primary selection |
(cond;; check cut buffer |
2294 |
((or (not cut-text) (string= cut-text "")) |
((or (not cut-text) (string= cut-text "")) |
2295 |
(setq x-last-selected-text-cut nil)) |
(setq x-last-selected-text-cut nil)) |
2296 |
((eq cut-text x-last-selected-text-cut) nil) |
;; This short cut doesn't work because x-get-cut-buffer |
2297 |
((string= cut-text x-last-selected-text-cut) |
;; always returns a newly created string. |
2298 |
|
;; ((eq cut-text x-last-selected-text-cut) nil) |
2299 |
|
((string= cut-text x-last-selected-text-cut-encoded) |
2300 |
|
;; See the comment above. No need of this recording. |
2301 |
;; Record the newer string, |
;; Record the newer string, |
2302 |
;; so subsequent calls can use the `eq' test. |
;; so subsequent calls can use the `eq' test. |
2303 |
(setq x-last-selected-text-cut cut-text) |
;; (setq x-last-selected-text-cut cut-text) |
2304 |
nil) |
nil) |
2305 |
(t |
(t |
2306 |
(setq x-last-selected-text-cut cut-text)))) |
(setq x-last-selected-text-cut-encoded cut-text |
2307 |
|
x-last-selected-text-cut |
2308 |
|
(decode-coding-string cut-text (or locale-coding-system |
2309 |
|
'iso-latin-1)))))) |
2310 |
|
|
2311 |
;; As we have done one selection, clear this now. |
;; As we have done one selection, clear this now. |
2312 |
(setq next-selection-coding-system nil) |
(setq next-selection-coding-system nil) |