summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2014-10-02 21:39:49 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2014-10-02 21:39:49 -0400
commitd6f8fef3fc17187687fafce50b428f88a278aee9 (patch)
tree042705e9c52b2799144888fe9a602022f8d84e72 /lisp/select.el
parentf0da11bd3978faee12cd15b26dbf2fbf837d8a2b (diff)
downloademacs-d6f8fef3fc17187687fafce50b428f88a278aee9.tar.gz
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.
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/select.el b/lisp/select.el
index d6be917f291..9e48cc0b432 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -98,6 +98,9 @@ SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
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 @@ On MS-Windows, make TEXT the current selection."
(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,