diff options
| author | Kenichi Handa | 2004-12-01 00:35:37 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-12-01 00:35:37 +0000 |
| commit | eb5ad2428beab8d29e38af323238c53126cd6332 (patch) | |
| tree | 84db2940e602583f660e0dc5353131c4e38a3874 | |
| parent | 30a2ee1b335d65cc288fa9e766268527f403f21a (diff) | |
| download | emacs-eb5ad2428beab8d29e38af323238c53126cd6332.tar.gz emacs-eb5ad2428beab8d29e38af323238c53126cd6332.zip | |
(x-last-selected-text-cut-encoded): New variable.
(x-select-text): Don't treat eight-bit-control/graphic chars
specially. Store the encoded text in the X cut buffer.
(x-cut-buffer-or-selection-value): Compare the X cut buffer text
with x-last-selected-text-cut-encoded.
| -rw-r--r-- | lisp/term/x-win.el | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index 61602d1f355..17ec969e45b 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el | |||
| @@ -2096,7 +2096,11 @@ pasted text.") | |||
| 2096 | "The value of the PRIMARY X selection last time we selected or | 2096 | "The value of the PRIMARY X selection last time we selected or |
| 2097 | pasted text.") | 2097 | pasted text.") |
| 2098 | (defvar x-last-selected-text-cut nil | 2098 | (defvar x-last-selected-text-cut nil |
| 2099 | "The value of the X cut buffer last time we selected or pasted text.") | 2099 | "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.") | ||
| 2100 | 2104 | ||
| 2101 | ;;; It is said that overlarge strings are slow to put into the cut buffer. | 2105 | ;;; It is said that overlarge strings are slow to put into the cut buffer. |
| 2102 | ;;; Note this value is overridden below. | 2106 | ;;; Note this value is overridden below. |
| @@ -2119,19 +2123,14 @@ This is in addition to, but in preference to, the primary selection." | |||
| 2119 | ;; It becomes slow, and if really big it causes errors. | 2123 | ;; It becomes slow, and if really big it causes errors. |
| 2120 | (cond ((>= (length text) x-cut-buffer-max) | 2124 | (cond ((>= (length text) x-cut-buffer-max) |
| 2121 | (x-set-cut-buffer "" push) | 2125 | (x-set-cut-buffer "" push) |
| 2122 | (setq x-last-selected-text-cut "")) | 2126 | (setq x-last-selected-text-cut "" |
| 2123 | ;; Don't store a multibyte string that contains | 2127 | x-last-selected-text-cut-encoded "")) |
| 2124 | ;; eight-bit-control/graphic chars because they can't be | ||
| 2125 | ;; restored correctly by x-get-cut-buffer. | ||
| 2126 | ((and (multibyte-string-p text) | ||
| 2127 | (let ((charsets (find-charset-string text))) | ||
| 2128 | (or (memq 'eight-bit-control charsets) | ||
| 2129 | (memq 'eight-bit-graphic charsets)))) | ||
| 2130 | (x-set-cut-buffer "" push) | ||
| 2131 | (setq x-last-selected-text-cut "")) | ||
| 2132 | (t | 2128 | (t |
| 2133 | (x-set-cut-buffer text push) | 2129 | (setq x-last-selected-text-cut text |
| 2134 | (setq x-last-selected-text-cut text))) | 2130 | 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))) | ||
| 2135 | (x-set-selection 'PRIMARY text) | 2134 | (x-set-selection 'PRIMARY text) |
| 2136 | (setq x-last-selected-text-primary text) | 2135 | (setq x-last-selected-text-primary text) |
| 2137 | (when x-select-enable-clipboard | 2136 | (when x-select-enable-clipboard |
| @@ -2291,17 +2290,23 @@ order until succeed.") | |||
| 2291 | ;; from what we remebered them to be last time we did a | 2290 | ;; from what we remebered them to be last time we did a |
| 2292 | ;; cut/paste operation. | 2291 | ;; cut/paste operation. |
| 2293 | (setq cut-text | 2292 | (setq cut-text |
| 2294 | (cond;; check primary selection | 2293 | (cond;; check cut buffer |
| 2295 | ((or (not cut-text) (string= cut-text "")) | 2294 | ((or (not cut-text) (string= cut-text "")) |
| 2296 | (setq x-last-selected-text-cut nil)) | 2295 | (setq x-last-selected-text-cut nil)) |
| 2297 | ((eq cut-text x-last-selected-text-cut) nil) | 2296 | ;; This short cut doesn't work because x-get-cut-buffer |
| 2298 | ((string= cut-text x-last-selected-text-cut) | 2297 | ;; 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. | ||
| 2299 | ;; Record the newer string, | 2301 | ;; Record the newer string, |
| 2300 | ;; so subsequent calls can use the `eq' test. | 2302 | ;; so subsequent calls can use the `eq' test. |
| 2301 | (setq x-last-selected-text-cut cut-text) | 2303 | ;; (setq x-last-selected-text-cut cut-text) |
| 2302 | nil) | 2304 | nil) |
| 2303 | (t | 2305 | (t |
| 2304 | (setq x-last-selected-text-cut cut-text)))) | 2306 | (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)))))) | ||
| 2305 | 2310 | ||
| 2306 | ;; As we have done one selection, clear this now. | 2311 | ;; As we have done one selection, clear this now. |
| 2307 | (setq next-selection-coding-system nil) | 2312 | (setq next-selection-coding-system nil) |