diff options
| author | Stefan Monnier | 2014-10-02 21:39:49 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-10-02 21:39:49 -0400 |
| commit | d6f8fef3fc17187687fafce50b428f88a278aee9 (patch) | |
| tree | 042705e9c52b2799144888fe9a602022f8d84e72 | |
| parent | f0da11bd3978faee12cd15b26dbf2fbf837d8a2b (diff) | |
| download | emacs-d6f8fef3fc17187687fafce50b428f88a278aee9.tar.gz emacs-d6f8fef3fc17187687fafce50b428f88a278aee9.zip | |
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.
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | lisp/ChangeLog | 26 | ||||
| -rw-r--r-- | lisp/obsolete/mouse-sel.el | 8 | ||||
| -rw-r--r-- | lisp/select.el | 22 | ||||
| -rw-r--r-- | lisp/simple.el | 2 | ||||
| -rw-r--r-- | lisp/term/common-win.el | 3 | ||||
| -rw-r--r-- | lisp/term/ns-win.el | 23 | ||||
| -rw-r--r-- | lisp/term/pc-win.el | 19 | ||||
| -rw-r--r-- | lisp/term/x-win.el | 123 | ||||
| -rw-r--r-- | lisp/w32-common-fns.el | 25 |
10 files changed, 129 insertions, 123 deletions
| @@ -247,6 +247,7 @@ Emacs-21. | |||
| 247 | 247 | ||
| 248 | ** Some "x-*" were obsoleted: | 248 | ** Some "x-*" were obsoleted: |
| 249 | *** x-select-text is renamed gui-select-text. | 249 | *** x-select-text is renamed gui-select-text. |
| 250 | *** x-selection-value is renamed gui-selection-value. | ||
| 250 | *** x-get-selection is renamed gui-get-selection. | 251 | *** x-get-selection is renamed gui-get-selection. |
| 251 | *** x-get-clipboard and x-clipboard-yank are marked obsolete. | 252 | *** x-get-clipboard and x-clipboard-yank are marked obsolete. |
| 252 | *** x-get-selection-value is renamed to gui-get-primary-selection. | 253 | *** x-get-selection-value is renamed to gui-get-primary-selection. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1f9ac164cfa..d7e24c735a6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,29 @@ | |||
| 1 | 2014-10-03 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | New gui-selection-value consolidating x-selection-value. | ||
| 4 | * select.el (gui-selection-value-alist): New method. | ||
| 5 | (gui-selection-value): New function. | ||
| 6 | (x-selection-value): Make it an obsolete alias. | ||
| 7 | * simple.el (interprogram-paste-function): Default to | ||
| 8 | gui-selection-value. | ||
| 9 | * w32-common-fns.el (w32-get-selection-value): Simplify. | ||
| 10 | (x-selection-value): Remove alias. | ||
| 11 | (interprogram-paste-function): Don't set. | ||
| 12 | (gui-selection-value): Define for w32. | ||
| 13 | * term/x-win.el (gui-selection-value): Define for x. | ||
| 14 | (x--selection-value): Rename from x--selection-value. | ||
| 15 | (interprogram-paste-function): Don't set. | ||
| 16 | * term/pc-win.el (w16-get-selection-value): Simplify. | ||
| 17 | (msdos-initialize-window-system): Don't set | ||
| 18 | interprogram-paste-function. | ||
| 19 | (gui-selection-value): Define for pc. | ||
| 20 | * term/ns-win.el (x-selection-value): Remove. | ||
| 21 | (gui-selection-value): Define for ns, instead. | ||
| 22 | * term/common-win.el (x-setup-function-keys): Don't set | ||
| 23 | interprogram-paste-function. | ||
| 24 | * obsolete/mouse-sel.el (mouse-sel-get-selection-function): | ||
| 25 | Use gui-selection-value. | ||
| 26 | |||
| 1 | 2014-10-02 David Raynes <rayners@gmail.com> (tiny change) | 27 | 2014-10-02 David Raynes <rayners@gmail.com> (tiny change) |
| 2 | 28 | ||
| 3 | * term/ns-win.el: Add functions to ns frame, not x frame (bug#18614). | 29 | * term/ns-win.el: Add functions to ns frame, not x frame (bug#18614). |
diff --git a/lisp/obsolete/mouse-sel.el b/lisp/obsolete/mouse-sel.el index 7d7cd1f137f..837aefb8b7f 100644 --- a/lisp/obsolete/mouse-sel.el +++ b/lisp/obsolete/mouse-sel.el | |||
| @@ -98,7 +98,7 @@ | |||
| 98 | ;; | 98 | ;; |
| 99 | ;; Selection/kill-ring interaction is retained | 99 | ;; Selection/kill-ring interaction is retained |
| 100 | ;; interprogram-cut-function = gui-select-text | 100 | ;; interprogram-cut-function = gui-select-text |
| 101 | ;; interprogram-paste-function = x-selection-value | 101 | ;; interprogram-paste-function = gui-selection-value |
| 102 | ;; | 102 | ;; |
| 103 | ;; What you lose is the ability to select some text in | 103 | ;; What you lose is the ability to select some text in |
| 104 | ;; delete-selection-mode and yank over the top of it. | 104 | ;; delete-selection-mode and yank over the top of it. |
| @@ -308,13 +308,13 @@ Called with two arguments: | |||
| 308 | This sets the selection, unless `mouse-sel-default-bindings' | 308 | This sets the selection, unless `mouse-sel-default-bindings' |
| 309 | is `interprogram-cut-paste'.") | 309 | is `interprogram-cut-paste'.") |
| 310 | 310 | ||
| 311 | (declare-function x-selection-value "term/x-win" ()) | ||
| 312 | 311 | ||
| 313 | (defvar mouse-sel-get-selection-function | 312 | (defvar mouse-sel-get-selection-function |
| 314 | (lambda (selection) | 313 | (lambda (selection) |
| 315 | (if (eq selection 'PRIMARY) | 314 | (if (eq selection 'PRIMARY) |
| 316 | (or (x-selection-value) | 315 | (or (gui-selection-value) |
| 317 | (bound-and-true-p x-last-selected-text-primary)) | 316 | (bound-and-true-p x-last-selected-text-primary) |
| 317 | gui-last-selected-text) | ||
| 318 | (x-get-selection selection))) | 318 | (x-get-selection selection))) |
| 319 | "Function to call to get the selection. | 319 | "Function to call to get the selection. |
| 320 | Called with one argument: | 320 | Called with one argument: |
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'. | |||
| 98 | TARGET-TYPE is the type of data desired, typically `STRING'.") | 98 | TARGET-TYPE is the type of data desired, typically `STRING'.") |
| 99 | 99 | ||
| 100 | (defvar gui-last-selected-text nil | 100 | (defvar gui-last-selected-text nil |
| 101 | ;; We keep track of the last text selected here, so we can check the | ||
| 102 | ;; current selection against it, and avoid passing back our own text | ||
| 103 | ;; from gui-selection-value. | ||
| 101 | "Last text passed to `gui-select-text'.") | 104 | "Last text passed to `gui-select-text'.") |
| 102 | 105 | ||
| 103 | (defun gui-select-text (text) | 106 | (defun gui-select-text (text) |
| @@ -116,6 +119,25 @@ On MS-Windows, make TEXT the current selection." | |||
| 116 | (setq gui-last-selected-text text)) | 119 | (setq gui-last-selected-text text)) |
| 117 | (define-obsolete-function-alias 'x-select-text 'gui-select-text "25.1") | 120 | (define-obsolete-function-alias 'x-select-text 'gui-select-text "25.1") |
| 118 | 121 | ||
| 122 | (gui-method-declare gui-selection-value #'ignore | ||
| 123 | "Method to return the GUI's selection. | ||
| 124 | Takes no argument, and returns a string. | ||
| 125 | Should obey `gui-select-enable-clipboard'.") | ||
| 126 | |||
| 127 | (defun gui-selection-value () | ||
| 128 | (let ((text (gui-call gui-selection-value))) | ||
| 129 | (if (string= text "") (setq text nil)) | ||
| 130 | (cond | ||
| 131 | ((not text) nil) | ||
| 132 | ((eq text gui-last-selected-text) nil) | ||
| 133 | ((string= text gui-last-selected-text) | ||
| 134 | ;; Record the newer string, so subsequent calls can use the `eq' test. | ||
| 135 | (setq gui-last-selected-text text) | ||
| 136 | nil) | ||
| 137 | (t | ||
| 138 | (setq gui-last-selected-text text))))) | ||
| 139 | (define-obsolete-function-alias 'x-selection-value 'gui-selection-value "25.1") | ||
| 140 | |||
| 119 | (defun gui-get-selection (&optional type data-type) | 141 | (defun gui-get-selection (&optional type data-type) |
| 120 | "Return the value of an X Windows selection. | 142 | "Return the value of an X Windows selection. |
| 121 | The argument TYPE (default `PRIMARY') says which selection, | 143 | The argument TYPE (default `PRIMARY') says which selection, |
diff --git a/lisp/simple.el b/lisp/simple.el index fc5ecbad10e..9b59b65b851 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3640,7 +3640,7 @@ put in the kill ring, to make the new kill available to other | |||
| 3640 | programs. The function takes one argument, TEXT, which is a | 3640 | programs. The function takes one argument, TEXT, which is a |
| 3641 | string containing the text which should be made available.") | 3641 | string containing the text which should be made available.") |
| 3642 | 3642 | ||
| 3643 | (defvar interprogram-paste-function #'ignore | 3643 | (defvar interprogram-paste-function #'gui-selection-value |
| 3644 | "Function to call to get text cut from other programs. | 3644 | "Function to call to get text cut from other programs. |
| 3645 | Most window systems provide a facility for cutting and pasting | 3645 | Most window systems provide a facility for cutting and pasting |
| 3646 | text between different programs, such as the clipboard on X and | 3646 | text between different programs, such as the clipboard on X and |
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el index fcb9fd55bb1..d026ee8eabe 100644 --- a/lisp/term/common-win.el +++ b/lisp/term/common-win.el | |||
| @@ -56,8 +56,7 @@ | |||
| 56 | (set-keymap-parent map (keymap-parent local-function-key-map)) | 56 | (set-keymap-parent map (keymap-parent local-function-key-map)) |
| 57 | (set-keymap-parent local-function-key-map map)) | 57 | (set-keymap-parent local-function-key-map map)) |
| 58 | (when (featurep 'ns) | 58 | (when (featurep 'ns) |
| 59 | (setq interprogram-paste-function 'x-selection-value | 59 | (setq system-key-alist |
| 60 | system-key-alist | ||
| 61 | (list | 60 | (list |
| 62 | ;; These are special "keys" used to pass events from C to lisp. | 61 | ;; These are special "keys" used to pass events from C to lisp. |
| 63 | (cons (logior (lsh 0 16) 1) 'ns-power-off) | 62 | (cons (logior (lsh 0 16) 1) 'ns-power-off) |
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index b1d3a00df0c..22e99d87968 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el | |||
| @@ -736,27 +736,14 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 736 | (if (not (stringp string)) (error "Nonstring given to pasteboard")) | 736 | (if (not (stringp string)) (error "Nonstring given to pasteboard")) |
| 737 | (ns-store-selection-internal 'CLIPBOARD string)) | 737 | (ns-store-selection-internal 'CLIPBOARD string)) |
| 738 | 738 | ||
| 739 | ;; We keep track of the last text selected here, so we can check the | ||
| 740 | ;; current selection against it, and avoid passing back our own text | ||
| 741 | ;; from x-selection-value. | ||
| 742 | |||
| 743 | ;; Return the value of the current Nextstep selection. For | 739 | ;; Return the value of the current Nextstep selection. For |
| 744 | ;; compatibility with older Nextstep applications, this checks cut | 740 | ;; compatibility with older Nextstep applications, this checks cut |
| 745 | ;; buffer 0 before retrieving the value of the primary selection. | 741 | ;; buffer 0 before retrieving the value of the primary selection. |
| 746 | (defun x-selection-value () | 742 | (gui-method-define gui-selection-value ns #'ns-selection-value) |
| 747 | (let (text) | 743 | (defun ns-selection-value () |
| 748 | ;; Consult the selection. Treat empty strings as if they were unset. | 744 | ;; Consult the selection. Treat empty strings as if they were unset. |
| 749 | (or text (setq text (ns-get-pasteboard))) | 745 | (if gui-select-enable-clipboard |
| 750 | (if (string= text "") (setq text nil)) | 746 | (ns-get-pasteboard))) |
| 751 | (cond | ||
| 752 | ((not text) nil) | ||
| 753 | ((eq text gui-last-selected-text) nil) | ||
| 754 | ((string= text gui-last-selected-text) | ||
| 755 | ;; Record the newer string, so subsequent calls can use the `eq' test. | ||
| 756 | (setq gui-last-selected-text text) | ||
| 757 | nil) | ||
| 758 | (t | ||
| 759 | (setq gui-last-selected-text text))))) | ||
| 760 | 747 | ||
| 761 | (defun ns-copy-including-secondary () | 748 | (defun ns-copy-including-secondary () |
| 762 | (interactive) | 749 | (interactive) |
diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el index 3498937b4d2..a7507377bda 100644 --- a/lisp/term/pc-win.el +++ b/lisp/term/pc-win.el | |||
| @@ -223,20 +223,9 @@ the operating system.") | |||
| 223 | "Return the value of the current selection. | 223 | "Return the value of the current selection. |
| 224 | Consult the selection. Treat empty strings as if they were unset." | 224 | Consult the selection. Treat empty strings as if they were unset." |
| 225 | (if gui-select-enable-clipboard | 225 | (if gui-select-enable-clipboard |
| 226 | (let (text) | 226 | ;; Don't die if x-get-selection signals an error. |
| 227 | ;; Don't die if x-get-selection signals an error. | 227 | (with-demoted-errors "w16-get-clipboard-data:%s" |
| 228 | (with-demoted-errors "w16-get-clipboard-data:%s" | 228 | (w16-get-clipboard-data)))) |
| 229 | (setq text (w16-get-clipboard-data))) | ||
| 230 | (if (string= text "") (setq text nil)) | ||
| 231 | (cond | ||
| 232 | ((not text) nil) | ||
| 233 | ((eq text gui-last-selected-text) nil) | ||
| 234 | ((string= text gui-last-selected-text) | ||
| 235 | ;; Record the newer string, so subsequent calls can use the 'eq' test. | ||
| 236 | (setq gui-last-selected-text text) | ||
| 237 | nil) | ||
| 238 | (t | ||
| 239 | (setq gui-last-selected-text text)))))) | ||
| 240 | 229 | ||
| 241 | ;; gui-selection-owner-p is used in simple.el. | 230 | ;; gui-selection-owner-p is used in simple.el. |
| 242 | (gui-method-define gui-selection-owner-p pc #'w16-selection-owner-p) | 231 | (gui-method-define gui-selection-owner-p pc #'w16-selection-owner-p) |
| @@ -380,7 +369,6 @@ Errors out because it is not supposed to be called, ever." | |||
| 380 | (setq split-window-keep-point t) | 369 | (setq split-window-keep-point t) |
| 381 | ;; Arrange for the kill and yank functions to set and check the | 370 | ;; Arrange for the kill and yank functions to set and check the |
| 382 | ;; clipboard. | 371 | ;; clipboard. |
| 383 | (setq interprogram-paste-function #'w16-get-selection-value) | ||
| 384 | (menu-bar-enable-clipboard) | 372 | (menu-bar-enable-clipboard) |
| 385 | (run-hooks 'terminal-init-msdos-hook)) | 373 | (run-hooks 'terminal-init-msdos-hook)) |
| 386 | 374 | ||
| @@ -398,6 +386,7 @@ Errors out because it is not supposed to be called, ever." | |||
| 398 | (declare-function w16-set-clipboard-data "w16select.c" | 386 | (declare-function w16-set-clipboard-data "w16select.c" |
| 399 | (string &optional ignored)) | 387 | (string &optional ignored)) |
| 400 | (gui-method-define gui-select-text pc #'w16--select-text) | 388 | (gui-method-define gui-select-text pc #'w16--select-text) |
| 389 | (gui-method-define gui-selection-value pc #'w16-get-selection-value) | ||
| 401 | (defun w16--select-text (text) | 390 | (defun w16--select-text (text) |
| 402 | (when gui-select-enable-clipboard | 391 | (when gui-select-enable-clipboard |
| 403 | (w16-set-clipboard-data text))) | 392 | (w16-set-clipboard-data text))) |
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index a50f886c66a..d6848628bf3 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el | |||
| @@ -1156,7 +1156,7 @@ as returned by `x-server-vendor'." | |||
| 1156 | 1156 | ||
| 1157 | ;; We keep track of the last text selected here, so we can check the | 1157 | ;; We keep track of the last text selected here, so we can check the |
| 1158 | ;; current selection against it, and avoid passing back our own text | 1158 | ;; current selection against it, and avoid passing back our own text |
| 1159 | ;; from x-selection-value. We track both | 1159 | ;; from x--selection-value. We track both |
| 1160 | ;; separately in case another X application only sets one of them | 1160 | ;; separately in case another X application only sets one of them |
| 1161 | ;; we aren't fooled by the PRIMARY or CLIPBOARD selection staying the same. | 1161 | ;; we aren't fooled by the PRIMARY or CLIPBOARD selection staying the same. |
| 1162 | (defvar x-last-selected-text-clipboard nil | 1162 | (defvar x-last-selected-text-clipboard nil |
| @@ -1222,73 +1222,72 @@ The value nil is the same as the list (UTF8_STRING COMPOUND_TEXT STRING)." | |||
| 1222 | ;; If this function is called twice and finds the same text, | 1222 | ;; If this function is called twice and finds the same text, |
| 1223 | ;; it returns nil the second time. This is so that a single | 1223 | ;; it returns nil the second time. This is so that a single |
| 1224 | ;; selection won't be added to the kill ring over and over. | 1224 | ;; selection won't be added to the kill ring over and over. |
| 1225 | (defun x-selection-value () | 1225 | (gui-method-define gui-selection-value x #'x--selection-value) |
| 1226 | (defun x--selection-value () | ||
| 1226 | ;; With multi-tty, this function may be called from a tty frame. | 1227 | ;; With multi-tty, this function may be called from a tty frame. |
| 1227 | (when (eq (framep (selected-frame)) 'x) | 1228 | (let (clip-text primary-text) |
| 1228 | (let (clip-text primary-text) | 1229 | (when x-select-enable-clipboard |
| 1229 | (when x-select-enable-clipboard | 1230 | (setq clip-text (x-selection-value-internal 'CLIPBOARD)) |
| 1230 | (setq clip-text (x-selection-value-internal 'CLIPBOARD)) | 1231 | (if (string= clip-text "") (setq clip-text nil)) |
| 1231 | (if (string= clip-text "") (setq clip-text nil)) | 1232 | |
| 1232 | 1233 | ;; Check the CLIPBOARD selection for 'newness', is it different | |
| 1233 | ;; Check the CLIPBOARD selection for 'newness', is it different | 1234 | ;; from what we remembered them to be last time we did a |
| 1234 | ;; from what we remembered them to be last time we did a | 1235 | ;; cut/paste operation. |
| 1235 | ;; cut/paste operation. | 1236 | (setq clip-text |
| 1236 | (setq clip-text | 1237 | (cond ;; check clipboard |
| 1237 | (cond ;; check clipboard | 1238 | ((or (not clip-text) (string= clip-text "")) |
| 1238 | ((or (not clip-text) (string= clip-text "")) | 1239 | (setq x-last-selected-text-clipboard nil)) |
| 1239 | (setq x-last-selected-text-clipboard nil)) | 1240 | ((eq clip-text x-last-selected-text-clipboard) nil) |
| 1240 | ((eq clip-text x-last-selected-text-clipboard) nil) | 1241 | ((string= clip-text x-last-selected-text-clipboard) |
| 1241 | ((string= clip-text x-last-selected-text-clipboard) | 1242 | ;; Record the newer string, |
| 1242 | ;; Record the newer string, | 1243 | ;; so subsequent calls can use the `eq' test. |
| 1243 | ;; so subsequent calls can use the `eq' test. | 1244 | (setq x-last-selected-text-clipboard clip-text) |
| 1244 | (setq x-last-selected-text-clipboard clip-text) | 1245 | nil) |
| 1245 | nil) | 1246 | (t (setq x-last-selected-text-clipboard clip-text))))) |
| 1246 | (t (setq x-last-selected-text-clipboard clip-text))))) | 1247 | |
| 1247 | 1248 | (when x-select-enable-primary | |
| 1248 | (when x-select-enable-primary | 1249 | (setq primary-text (x-selection-value-internal 'PRIMARY)) |
| 1249 | (setq primary-text (x-selection-value-internal 'PRIMARY)) | 1250 | ;; Check the PRIMARY selection for 'newness', is it different |
| 1250 | ;; Check the PRIMARY selection for 'newness', is it different | 1251 | ;; from what we remembered them to be last time we did a |
| 1251 | ;; from what we remembered them to be last time we did a | 1252 | ;; cut/paste operation. |
| 1252 | ;; cut/paste operation. | 1253 | (setq primary-text |
| 1253 | (setq primary-text | 1254 | (cond ;; check primary selection |
| 1254 | (cond ;; check primary selection | 1255 | ((or (not primary-text) (string= primary-text "")) |
| 1255 | ((or (not primary-text) (string= primary-text "")) | 1256 | (setq x-last-selected-text-primary nil)) |
| 1256 | (setq x-last-selected-text-primary nil)) | 1257 | ((eq primary-text x-last-selected-text-primary) nil) |
| 1257 | ((eq primary-text x-last-selected-text-primary) nil) | 1258 | ((string= primary-text x-last-selected-text-primary) |
| 1258 | ((string= primary-text x-last-selected-text-primary) | 1259 | ;; Record the newer string, |
| 1259 | ;; Record the newer string, | 1260 | ;; so subsequent calls can use the `eq' test. |
| 1260 | ;; so subsequent calls can use the `eq' test. | 1261 | (setq x-last-selected-text-primary primary-text) |
| 1261 | (setq x-last-selected-text-primary primary-text) | 1262 | nil) |
| 1262 | nil) | 1263 | (t |
| 1263 | (t | 1264 | (setq x-last-selected-text-primary primary-text))))) |
| 1264 | (setq x-last-selected-text-primary primary-text))))) | 1265 | |
| 1265 | 1266 | ;; As we have done one selection, clear this now. | |
| 1266 | ;; As we have done one selection, clear this now. | 1267 | (setq next-selection-coding-system nil) |
| 1267 | (setq next-selection-coding-system nil) | 1268 | |
| 1268 | 1269 | ;; At this point we have recorded the current values for the | |
| 1269 | ;; At this point we have recorded the current values for the | 1270 | ;; selection from clipboard (if we are supposed to) and primary. |
| 1270 | ;; selection from clipboard (if we are supposed to) and primary. | 1271 | ;; So return the first one that has changed |
| 1271 | ;; So return the first one that has changed | 1272 | ;; (which is the first non-null one). |
| 1272 | ;; (which is the first non-null one). | 1273 | ;; |
| 1273 | ;; | 1274 | ;; NOTE: There will be cases where more than one of these has |
| 1274 | ;; NOTE: There will be cases where more than one of these has | 1275 | ;; changed and the new values differ. This indicates that |
| 1275 | ;; changed and the new values differ. This indicates that | 1276 | ;; something like the following has happened since the last time |
| 1276 | ;; something like the following has happened since the last time | 1277 | ;; we looked at the selections: Application X set all the |
| 1277 | ;; we looked at the selections: Application X set all the | 1278 | ;; selections, then Application Y set only one of them. |
| 1278 | ;; selections, then Application Y set only one of them. | 1279 | ;; In this case since we don't have |
| 1279 | ;; In this case since we don't have | 1280 | ;; timestamps there is no way to know what the 'correct' value to |
| 1280 | ;; timestamps there is no way to know what the 'correct' value to | 1281 | ;; return is. The nice thing to do would be to tell the user we |
| 1281 | ;; return is. The nice thing to do would be to tell the user we | 1282 | ;; saw multiple possible selections and ask the user which was the |
| 1282 | ;; saw multiple possible selections and ask the user which was the | 1283 | ;; one they wanted. |
| 1283 | ;; one they wanted. | 1284 | (or clip-text primary-text) |
| 1284 | (or clip-text primary-text) | 1285 | )) |
| 1285 | ))) | ||
| 1286 | 1286 | ||
| 1287 | (define-obsolete-function-alias 'x-cut-buffer-or-selection-value | 1287 | (define-obsolete-function-alias 'x-cut-buffer-or-selection-value |
| 1288 | 'x-selection-value "24.1") | 1288 | 'x-selection-value "24.1") |
| 1289 | 1289 | ||
| 1290 | ;; Arrange for the kill and yank functions to set and check the clipboard. | 1290 | ;; Arrange for the kill and yank functions to set and check the clipboard. |
| 1291 | (setq interprogram-paste-function 'x-selection-value) | ||
| 1292 | 1291 | ||
| 1293 | (defun x-clipboard-yank () | 1292 | (defun x-clipboard-yank () |
| 1294 | "Insert the clipboard contents, or the last stretch of killed text." | 1293 | "Insert the clipboard contents, or the last stretch of killed text." |
diff --git a/lisp/w32-common-fns.el b/lisp/w32-common-fns.el index 3f8cbc19dba..04037839b94 100644 --- a/lisp/w32-common-fns.el +++ b/lisp/w32-common-fns.el | |||
| @@ -70,32 +70,15 @@ That includes all Windows systems except for 9X/Me." | |||
| 70 | 70 | ||
| 71 | ;;;; Selections | 71 | ;;;; Selections |
| 72 | 72 | ||
| 73 | ;; We keep track of the last text selected here, so we can check the | ||
| 74 | ;; current selection against it, and avoid passing back our own text | ||
| 75 | ;; from x-selection-value. | ||
| 76 | |||
| 77 | (defun w32-get-selection-value () | 73 | (defun w32-get-selection-value () |
| 78 | "Return the value of the current selection. | 74 | "Return the value of the current selection. |
| 79 | Consult the selection. Treat empty strings as if they were unset." | 75 | Consult the selection. Treat empty strings as if they were unset." |
| 80 | (if gui-select-enable-clipboard | 76 | (if gui-select-enable-clipboard |
| 81 | (let ((text | 77 | ;; Don't die if x-get-selection signals an error. |
| 82 | ;; Don't die if x-get-selection signals an error. | 78 | (with-demoted-errors "w32-get-clipboard-data:%S" |
| 83 | (with-demoted-errors "w32-get-clipboard-data:%S" | 79 | (w32-get-clipboard-data)))) |
| 84 | (w32-get-clipboard-data)))) | ||
| 85 | (if (string= text "") (setq text nil)) | ||
| 86 | (cond | ||
| 87 | ((not text) nil) | ||
| 88 | ((eq text gui-last-selected-text) nil) | ||
| 89 | ((string= text gui-last-selected-text) | ||
| 90 | ;; Record the newer string, so subsequent calls can use the 'eq' test. | ||
| 91 | (setq gui-last-selected-text text) | ||
| 92 | nil) | ||
| 93 | (t | ||
| 94 | (setq gui-last-selected-text text)))))) | ||
| 95 | 80 | ||
| 96 | (defalias 'x-selection-value #'w32-get-selection-value) | ||
| 97 | |||
| 98 | ;; Arrange for the kill and yank functions to set and check the clipboard. | 81 | ;; Arrange for the kill and yank functions to set and check the clipboard. |
| 99 | (setq interprogram-paste-function #'w32-get-selection-value) | 82 | (gui-method-define gui-selection-value w32 #'w32-get-selection-value) |
| 100 | 83 | ||
| 101 | (provide 'w32-common-fns) | 84 | (provide 'w32-common-fns) |