]> code.delx.au - gnu-emacs/commitdiff
(x-last-cut-buffer-coding): New variable.
authorJan Djärv <jan.h.d@swipnet.se>
Mon, 20 Nov 2006 07:43:41 +0000 (07:43 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Mon, 20 Nov 2006 07:43:41 +0000 (07:43 +0000)
(x-select-text): Set it.
(x-cut-buffer-or-selection-value): Check also x-last-cut-buffer-coding
when checking for newness.

lisp/ChangeLog
lisp/term/x-win.el

index 364a68d849aeb9a760128b2476833d7348e6802b..ed928d5a12316df8300daebcddaa4eb9ef6ea3a3 100644 (file)
@@ -1,3 +1,10 @@
+2006-11-20  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
+
+       * term/x-win.el (x-last-cut-buffer-coding): New variable.
+       (x-select-text): Set it.
+       (x-cut-buffer-or-selection-value): Check also x-last-cut-buffer-coding
+       when checking for newness.
+
 2006-11-19  Juanma Barranquero  <lekktu@gmail.com>
 
        * subr.el (posn-image):
index b0e2dc85a048ca3193d09e6222bff666d847dd65..e97d3752704eba57b2104570d3517fd073c6d33c 100644 (file)
@@ -2138,6 +2138,8 @@ The actual text stored in the X cut buffer is what encoded from this value.")
 (defvar x-last-selected-text-cut-encoded nil
   "The value of the X cut buffer last time we selected or pasted text.
 This is the actual text stored in the X cut buffer.")
+(defvar x-last-cut-buffer-coding 'iso-latin-1
+  "The coding we last used to encode/decode the text from the X cut buffer")
 
 (defvar x-cut-buffer-max 20000 ; Note this value is overridden below.
   "Max number of characters to put in the cut buffer.
@@ -2163,6 +2165,7 @@ in the clipboard."
               x-last-selected-text-cut-encoded ""))
        (t
         (setq x-last-selected-text-cut text
+              x-last-cut-buffer-coding 'iso-latin-1
               x-last-selected-text-cut-encoded
               ;; ICCCM says cut buffer always contain ISO-Latin-1
               (encode-coding-string text 'iso-latin-1))
@@ -2331,20 +2334,28 @@ order until succeed.")
     ;; from what we remebered them to be last time we did a
     ;; cut/paste operation.
     (setq cut-text
-         (cond;; check cut buffer
-          ((or (not cut-text) (string= cut-text ""))
-           (setq x-last-selected-text-cut nil))
-          (t
-           ;; We can not compare  x-last-selected-text-cut-encoded with
-           ;; cut-text because the next-selection-coding-system may have changed
-           ;; so we need to re-decode anyway.
-           (setq x-last-selected-text-cut-encoded cut-text
+         (let ((next-coding (or next-selection-coding-system 'iso-latin-1)))
+           (cond;; check cut buffer
+            ((or (not cut-text) (string= cut-text ""))
+             (setq x-last-selected-text-cut nil))
+            ;; This short cut doesn't work because x-get-cut-buffer     
+            ;; always returns a newly created string.   
+            ;; ((eq      cut-text x-last-selected-text-cut) nil)        
+            ((and (string= cut-text x-last-selected-text-cut-encoded)
+                  (eq x-last-cut-buffer-coding next-coding))
+             ;; See the comment above.  No need of this recording.      
+             ;; Record the newer string,        
+             ;; so subsequent calls can use the `eq' test.      
+             ;; (setq x-last-selected-text-cut cut-text)        
+             nil)
+            (t
+             (setq x-last-selected-text-cut-encoded cut-text
+                 x-last-cut-buffer-coding next-coding
                  x-last-selected-text-cut
                  ;; ICCCM says cut buffer always contain ISO-Latin-1, but
                  ;; use next-selection-coding-system if not nil.
                  (decode-coding-string 
-                  cut-text 
-                  (or next-selection-coding-system 'iso-latin-1))))))
+                  cut-text next-coding))))))
 
     ;; As we have done one selection, clear this now.
     (setq next-selection-coding-system nil)