emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r118019: New gui-selection-value consolidating x-sel


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r118019: New gui-selection-value consolidating x-selection-value.
Date: Fri, 03 Oct 2014 01:40:03 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 118019
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2014-10-02 21:39:49 -0400
message:
  New gui-selection-value consolidating x-selection-value.
  * lisp/select.el (gui-selection-value-alist): New method.
  (gui-selection-value): New function.
  (x-selection-value): Make it an obsolete alias.
  * lisp/simple.el (interprogram-paste-function): Default to 
gui-selection-value.
  * lisp/w32-common-fns.el (w32-get-selection-value): Simplify.
  (x-selection-value): Remove alias.
  (interprogram-paste-function): Don't set.
  (gui-selection-value): Define for w32.
  * lisp/term/x-win.el (gui-selection-value): Define for x.
  (x--selection-value): Rename from x--selection-value.
  (interprogram-paste-function): Don't set.
  * lisp/term/pc-win.el (w16-get-selection-value): Simplify.
  (msdos-initialize-window-system): Don't set interprogram-paste-function.
  (gui-selection-value): Define for pc.
  * lisp/term/ns-win.el (x-selection-value): Remove.
  (gui-selection-value): Define for ns, instead.
  * lisp/term/common-win.el (x-setup-function-keys): Don't set
  interprogram-paste-function.
  * lisp/obsolete/mouse-sel.el (mouse-sel-get-selection-function):
  Use gui-selection-value.
modified:
  etc/NEWS                       news-20141002041645-34n5fasbwydbo8t6-1
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/obsolete/mouse-sel.el     mousesel.el-20091113204419-o5vbwnq5f7feedwu-635
  lisp/select.el                 select.el-20091113204419-o5vbwnq5f7feedwu-550
  lisp/simple.el                 simple.el-20091113204419-o5vbwnq5f7feedwu-403
  lisp/term/common-win.el        
commonwin.el-20091113204419-o5vbwnq5f7feedwu-8752
  lisp/term/ns-win.el            nswin.el-20091113204419-o5vbwnq5f7feedwu-8708
  lisp/term/pc-win.el            pcwin.el-20091113204419-o5vbwnq5f7feedwu-795
  lisp/term/x-win.el             xwin.el-20091113204419-o5vbwnq5f7feedwu-113
  lisp/w32-common-fns.el         
w32commonfns.el-20120917115700-3at3xhn4to67xnca-4
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2014-10-02 04:24:07 +0000
+++ b/etc/NEWS  2014-10-03 01:39:49 +0000
@@ -247,6 +247,7 @@
 
 ** Some "x-*" were obsoleted:
 *** x-select-text is renamed gui-select-text.
+*** x-selection-value is renamed gui-selection-value.
 *** x-get-selection is renamed gui-get-selection.
 *** x-get-clipboard and x-clipboard-yank are marked obsolete.
 *** x-get-selection-value is renamed to gui-get-primary-selection.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-10-03 00:15:34 +0000
+++ b/lisp/ChangeLog    2014-10-03 01:39:49 +0000
@@ -1,3 +1,29 @@
+2014-10-03  Stefan Monnier  <address@hidden>
+
+       New gui-selection-value consolidating x-selection-value.
+       * select.el (gui-selection-value-alist): New method.
+       (gui-selection-value): New function.
+       (x-selection-value): Make it an obsolete alias.
+       * simple.el (interprogram-paste-function): Default to
+       gui-selection-value.
+       * w32-common-fns.el (w32-get-selection-value): Simplify.
+       (x-selection-value): Remove alias.
+       (interprogram-paste-function): Don't set.
+       (gui-selection-value): Define for w32.
+       * term/x-win.el (gui-selection-value): Define for x.
+       (x--selection-value): Rename from x--selection-value.
+       (interprogram-paste-function): Don't set.
+       * term/pc-win.el (w16-get-selection-value): Simplify.
+       (msdos-initialize-window-system): Don't set
+       interprogram-paste-function.
+       (gui-selection-value): Define for pc.
+       * term/ns-win.el (x-selection-value): Remove.
+       (gui-selection-value): Define for ns, instead.
+       * term/common-win.el (x-setup-function-keys): Don't set
+       interprogram-paste-function.
+       * obsolete/mouse-sel.el (mouse-sel-get-selection-function):
+       Use gui-selection-value.
+
 2014-10-02  David Raynes  <address@hidden>  (tiny change)
 
        * term/ns-win.el: Add functions to ns frame, not x frame (bug#18614).

=== modified file 'lisp/obsolete/mouse-sel.el'
--- a/lisp/obsolete/mouse-sel.el        2014-10-02 03:19:32 +0000
+++ b/lisp/obsolete/mouse-sel.el        2014-10-03 01:39:49 +0000
@@ -98,7 +98,7 @@
 ;;
 ;;       Selection/kill-ring interaction is retained
 ;;         interprogram-cut-function   = gui-select-text
-;;         interprogram-paste-function = x-selection-value
+;;         interprogram-paste-function = gui-selection-value
 ;;
 ;;       What you lose is the ability to select some text in
 ;;       delete-selection-mode and yank over the top of it.
@@ -308,13 +308,13 @@
 This sets the selection, unless `mouse-sel-default-bindings'
 is `interprogram-cut-paste'.")
 
-(declare-function x-selection-value "term/x-win" ())
 
 (defvar mouse-sel-get-selection-function
   (lambda (selection)
     (if (eq selection 'PRIMARY)
-       (or (x-selection-value)
-           (bound-and-true-p x-last-selected-text-primary))
+       (or (gui-selection-value)
+           (bound-and-true-p x-last-selected-text-primary)
+            gui-last-selected-text)
       (x-get-selection selection)))
   "Function to call to get the selection.
 Called with one argument:

=== modified file 'lisp/select.el'
--- a/lisp/select.el    2014-10-02 03:19:32 +0000
+++ b/lisp/select.el    2014-10-03 01:39:49 +0000
@@ -98,6 +98,9 @@
 TARGET-TYPE is the type of data desired, typically `STRING'.")
 
 (defvar gui-last-selected-text nil
+  ;; We keep track of the last text selected here, so we can check the
+  ;; current selection against it, and avoid passing back our own text
+  ;; from gui-selection-value.
   "Last text passed to `gui-select-text'.")
 
 (defun gui-select-text (text)
@@ -116,6 +119,25 @@
   (setq gui-last-selected-text text))
 (define-obsolete-function-alias 'x-select-text 'gui-select-text "25.1")
 
+(gui-method-declare gui-selection-value #'ignore
+  "Method to return the GUI's selection.
+Takes no argument, and returns a string.
+Should obey `gui-select-enable-clipboard'.")
+
+(defun gui-selection-value ()
+  (let ((text (gui-call gui-selection-value)))
+    (if (string= text "") (setq text nil))
+    (cond
+     ((not text) nil)
+     ((eq text gui-last-selected-text) nil)
+     ((string= text gui-last-selected-text)
+      ;; Record the newer string, so subsequent calls can use the `eq' test.
+      (setq gui-last-selected-text text)
+      nil)
+     (t
+      (setq gui-last-selected-text text)))))
+(define-obsolete-function-alias 'x-selection-value 'gui-selection-value "25.1")
+
 (defun gui-get-selection (&optional type data-type)
   "Return the value of an X Windows selection.
 The argument TYPE (default `PRIMARY') says which selection,

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2014-10-02 12:44:48 +0000
+++ b/lisp/simple.el    2014-10-03 01:39:49 +0000
@@ -3640,7 +3640,7 @@
 programs.  The function takes one argument, TEXT, which is a
 string containing the text which should be made available.")
 
-(defvar interprogram-paste-function #'ignore
+(defvar interprogram-paste-function #'gui-selection-value
   "Function to call to get text cut from other programs.
 Most window systems provide a facility for cutting and pasting
 text between different programs, such as the clipboard on X and

=== modified file 'lisp/term/common-win.el'
--- a/lisp/term/common-win.el   2014-10-01 22:13:11 +0000
+++ b/lisp/term/common-win.el   2014-10-03 01:39:49 +0000
@@ -56,8 +56,7 @@
         (set-keymap-parent map (keymap-parent local-function-key-map))
         (set-keymap-parent local-function-key-map map))
       (when (featurep 'ns)
-       (setq interprogram-paste-function 'x-selection-value
-             system-key-alist
+       (setq system-key-alist
              (list
               ;; These are special "keys" used to pass events from C to lisp.
               (cons (logior (lsh 0 16)   1) 'ns-power-off)

=== modified file 'lisp/term/ns-win.el'
--- a/lisp/term/ns-win.el       2014-10-03 00:15:34 +0000
+++ b/lisp/term/ns-win.el       2014-10-03 01:39:49 +0000
@@ -736,27 +736,14 @@
   (if (not (stringp string)) (error "Nonstring given to pasteboard"))
   (ns-store-selection-internal 'CLIPBOARD string))
 
-;; We keep track of the last text selected here, so we can check the
-;; current selection against it, and avoid passing back our own text
-;; from x-selection-value.
-
 ;; Return the value of the current Nextstep selection.  For
 ;; compatibility with older Nextstep applications, this checks cut
 ;; buffer 0 before retrieving the value of the primary selection.
-(defun x-selection-value ()
-  (let (text)
-    ;; Consult the selection.  Treat empty strings as if they were unset.
-    (or text (setq text (ns-get-pasteboard)))
-    (if (string= text "") (setq text nil))
-    (cond
-     ((not text) nil)
-     ((eq text gui-last-selected-text) nil)
-     ((string= text gui-last-selected-text)
-      ;; Record the newer string, so subsequent calls can use the `eq' test.
-      (setq gui-last-selected-text text)
-      nil)
-     (t
-      (setq gui-last-selected-text text)))))
+(gui-method-define gui-selection-value ns #'ns-selection-value)
+(defun ns-selection-value ()
+  ;; Consult the selection.  Treat empty strings as if they were unset.
+  (if gui-select-enable-clipboard
+      (ns-get-pasteboard)))
 
 (defun ns-copy-including-secondary ()
   (interactive)

=== modified file 'lisp/term/pc-win.el'
--- a/lisp/term/pc-win.el       2014-10-02 03:19:32 +0000
+++ b/lisp/term/pc-win.el       2014-10-03 01:39:49 +0000
@@ -223,20 +223,9 @@
   "Return the value of the current selection.
 Consult the selection.  Treat empty strings as if they were unset."
   (if gui-select-enable-clipboard
-      (let (text)
-       ;; Don't die if x-get-selection signals an error.
-       (with-demoted-errors "w16-get-clipboard-data:%s"
-          (setq text (w16-get-clipboard-data)))
-       (if (string= text "") (setq text nil))
-       (cond
-        ((not text) nil)
-        ((eq text gui-last-selected-text) nil)
-        ((string= text gui-last-selected-text)
-         ;; Record the newer string, so subsequent calls can use the 'eq' test.
-         (setq gui-last-selected-text text)
-         nil)
-        (t
-         (setq gui-last-selected-text text))))))
+      ;; Don't die if x-get-selection signals an error.
+      (with-demoted-errors "w16-get-clipboard-data:%s"
+        (w16-get-clipboard-data))))
 
 ;; gui-selection-owner-p is used in simple.el.
 (gui-method-define gui-selection-owner-p pc #'w16-selection-owner-p)
@@ -380,7 +369,6 @@
   (setq split-window-keep-point t)
   ;; Arrange for the kill and yank functions to set and check the
   ;; clipboard.
-  (setq interprogram-paste-function #'w16-get-selection-value)
   (menu-bar-enable-clipboard)
   (run-hooks 'terminal-init-msdos-hook))
 
@@ -398,6 +386,7 @@
 (declare-function w16-set-clipboard-data "w16select.c"
                  (string &optional ignored))
 (gui-method-define gui-select-text pc #'w16--select-text)
+(gui-method-define gui-selection-value pc #'w16-get-selection-value)
 (defun w16--select-text (text)
   (when gui-select-enable-clipboard
     (w16-set-clipboard-data text)))

=== modified file 'lisp/term/x-win.el'
--- a/lisp/term/x-win.el        2014-10-02 03:19:32 +0000
+++ b/lisp/term/x-win.el        2014-10-03 01:39:49 +0000
@@ -1156,7 +1156,7 @@
 
 ;; We keep track of the last text selected here, so we can check the
 ;; current selection against it, and avoid passing back our own text
-;; from x-selection-value.  We track both
+;; from x--selection-value.  We track both
 ;; separately in case another X application only sets one of them
 ;; we aren't fooled by the PRIMARY or CLIPBOARD selection staying the same.
 (defvar x-last-selected-text-clipboard nil
@@ -1222,73 +1222,72 @@
 ;; If this function is called twice and finds the same text,
 ;; it returns nil the second time.  This is so that a single
 ;; selection won't be added to the kill ring over and over.
-(defun x-selection-value ()
+(gui-method-define gui-selection-value x #'x--selection-value)
+(defun x--selection-value ()
   ;; With multi-tty, this function may be called from a tty frame.
-  (when (eq (framep (selected-frame)) 'x)
-    (let (clip-text primary-text)
-      (when x-select-enable-clipboard
-        (setq clip-text (x-selection-value-internal 'CLIPBOARD))
-        (if (string= clip-text "") (setq clip-text nil))
-
-        ;; Check the CLIPBOARD selection for 'newness', is it different
-        ;; from what we remembered them to be last time we did a
-        ;; cut/paste operation.
-        (setq clip-text
-              (cond ;; check clipboard
-               ((or (not clip-text) (string= clip-text ""))
-                (setq x-last-selected-text-clipboard nil))
-               ((eq      clip-text x-last-selected-text-clipboard) nil)
-               ((string= clip-text x-last-selected-text-clipboard)
-                ;; Record the newer string,
-                ;; so subsequent calls can use the `eq' test.
-                (setq x-last-selected-text-clipboard clip-text)
-                nil)
-               (t (setq x-last-selected-text-clipboard clip-text)))))
-
-      (when x-select-enable-primary
-       (setq primary-text (x-selection-value-internal 'PRIMARY))
-       ;; Check the PRIMARY selection for 'newness', is it different
-       ;; from what we remembered them to be last time we did a
-       ;; cut/paste operation.
-       (setq primary-text
-             (cond ;; check primary selection
-              ((or (not primary-text) (string= primary-text ""))
-               (setq x-last-selected-text-primary nil))
-              ((eq      primary-text x-last-selected-text-primary) nil)
-              ((string= primary-text x-last-selected-text-primary)
-               ;; Record the newer string,
-               ;; so subsequent calls can use the `eq' test.
-               (setq x-last-selected-text-primary primary-text)
-               nil)
-              (t
-               (setq x-last-selected-text-primary primary-text)))))
-
-      ;; As we have done one selection, clear this now.
-      (setq next-selection-coding-system nil)
-
-      ;; At this point we have recorded the current values for the
-      ;; selection from clipboard (if we are supposed to) and primary.
-      ;; So return the first one that has changed
-      ;; (which is the first non-null one).
-      ;;
-      ;; NOTE: There will be cases where more than one of these has
-      ;; changed and the new values differ.  This indicates that
-      ;; something like the following has happened since the last time
-      ;; we looked at the selections: Application X set all the
-      ;; selections, then Application Y set only one of them.
-      ;; In this case since we don't have
-      ;; timestamps there is no way to know what the 'correct' value to
-      ;; return is.  The nice thing to do would be to tell the user we
-      ;; saw multiple possible selections and ask the user which was the
-      ;; one they wanted.
-      (or clip-text primary-text)
-      )))
+  (let (clip-text primary-text)
+    (when x-select-enable-clipboard
+      (setq clip-text (x-selection-value-internal 'CLIPBOARD))
+      (if (string= clip-text "") (setq clip-text nil))
+
+      ;; Check the CLIPBOARD selection for 'newness', is it different
+      ;; from what we remembered them to be last time we did a
+      ;; cut/paste operation.
+      (setq clip-text
+            (cond ;; check clipboard
+             ((or (not clip-text) (string= clip-text ""))
+              (setq x-last-selected-text-clipboard nil))
+             ((eq      clip-text x-last-selected-text-clipboard) nil)
+             ((string= clip-text x-last-selected-text-clipboard)
+              ;; Record the newer string,
+              ;; so subsequent calls can use the `eq' test.
+              (setq x-last-selected-text-clipboard clip-text)
+              nil)
+             (t (setq x-last-selected-text-clipboard clip-text)))))
+
+    (when x-select-enable-primary
+      (setq primary-text (x-selection-value-internal 'PRIMARY))
+      ;; Check the PRIMARY selection for 'newness', is it different
+      ;; from what we remembered them to be last time we did a
+      ;; cut/paste operation.
+      (setq primary-text
+            (cond ;; check primary selection
+             ((or (not primary-text) (string= primary-text ""))
+              (setq x-last-selected-text-primary nil))
+             ((eq      primary-text x-last-selected-text-primary) nil)
+             ((string= primary-text x-last-selected-text-primary)
+              ;; Record the newer string,
+              ;; so subsequent calls can use the `eq' test.
+              (setq x-last-selected-text-primary primary-text)
+              nil)
+             (t
+              (setq x-last-selected-text-primary primary-text)))))
+
+    ;; As we have done one selection, clear this now.
+    (setq next-selection-coding-system nil)
+
+    ;; At this point we have recorded the current values for the
+    ;; selection from clipboard (if we are supposed to) and primary.
+    ;; So return the first one that has changed
+    ;; (which is the first non-null one).
+    ;;
+    ;; NOTE: There will be cases where more than one of these has
+    ;; changed and the new values differ.  This indicates that
+    ;; something like the following has happened since the last time
+    ;; we looked at the selections: Application X set all the
+    ;; selections, then Application Y set only one of them.
+    ;; In this case since we don't have
+    ;; timestamps there is no way to know what the 'correct' value to
+    ;; return is.  The nice thing to do would be to tell the user we
+    ;; saw multiple possible selections and ask the user which was the
+    ;; one they wanted.
+    (or clip-text primary-text)
+    ))
 
 (define-obsolete-function-alias 'x-cut-buffer-or-selection-value
   'x-selection-value "24.1")
 
 ;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-paste-function 'x-selection-value)
 
 (defun x-clipboard-yank ()
   "Insert the clipboard contents, or the last stretch of killed text."

=== modified file 'lisp/w32-common-fns.el'
--- a/lisp/w32-common-fns.el    2014-10-02 03:19:32 +0000
+++ b/lisp/w32-common-fns.el    2014-10-03 01:39:49 +0000
@@ -70,32 +70,15 @@
 
 ;;;; Selections
 
-;; We keep track of the last text selected here, so we can check the
-;; current selection against it, and avoid passing back our own text
-;; from x-selection-value.
-
 (defun w32-get-selection-value ()
   "Return the value of the current selection.
 Consult the selection.  Treat empty strings as if they were unset."
   (if gui-select-enable-clipboard
-      (let ((text
-             ;; Don't die if x-get-selection signals an error.
-             (with-demoted-errors "w32-get-clipboard-data:%S"
-               (w32-get-clipboard-data))))
-       (if (string= text "") (setq text nil))
-       (cond
-        ((not text) nil)
-        ((eq text gui-last-selected-text) nil)
-        ((string= text gui-last-selected-text)
-         ;; Record the newer string, so subsequent calls can use the 'eq' test.
-         (setq gui-last-selected-text text)
-         nil)
-        (t
-         (setq gui-last-selected-text text))))))
+      ;; Don't die if x-get-selection signals an error.
+      (with-demoted-errors "w32-get-clipboard-data:%S"
+        (w32-get-clipboard-data))))
 
-(defalias 'x-selection-value #'w32-get-selection-value)
-
 ;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-paste-function #'w32-get-selection-value)
+(gui-method-define gui-selection-value w32 #'w32-get-selection-value)
 
 (provide 'w32-common-fns)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]