diff options
| author | Stefan Monnier | 2014-10-01 23:19:32 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-10-01 23:19:32 -0400 |
| commit | 31300bee24ddcfd7dc27e757513d3c176a7fad83 (patch) | |
| tree | 28aba34a75aeafb3246cb60f2c8c55d3043436f8 | |
| parent | c7c0acd47bad506647ca3445aba1ced77d201daf (diff) | |
| download | emacs-31300bee24ddcfd7dc27e757513d3c176a7fad83.tar.gz emacs-31300bee24ddcfd7dc27e757513d3c176a7fad83.zip | |
Consolidate management/ownership of selections.
* lisp/select.el (gui-get-selection-alist): New method.
(gui-get-selection): Use it. Rename from x-get-selection.
(x-get-selection): Define as obsolete alias.
(x-get-clipboard): Mark obsolete.
(gui-get-primary-selection): New function.
(x-get-selection-value): Mark obsolete.
(gui-own-selection-alist, gui-disown-selection-alist)
(gui-selection-owner-p-alist): New methods.
(gui-set-selection): Use them. Rename from x-set-selection.
(x-set-selection): Define as obsolete alias.
(gui--valid-simple-selection-p): Rename from
x-valid-simple-selection-p.
* lisp/w32-common-fns.el (gui-own-selection, gui-disown-selection)
(gui-selection-owner-p, gui-get-selection): Define for w32.
(w32-get-selection-value): Rename from x-get-selection-value.
Use the new gui-last-selected-text.
* lisp/term/x-win.el (x-get-selection-value): Remove.
(x-clipboard-yank): Declare obsolete.
(gui-own-selection, gui-disown-selection, gui-get-selection)
(gui-selection-owner-p): Define for x.
* lisp/term/w32-win.el (w32-win-suspend-error): Rename from
x-win-suspend-error.
* lisp/term/pc-win.el (w16-get-selection-value): Rename from
x-get-selection-value.
(w16-selection-owner-p): Rename from x-selection-owner-p.
(gui-own-selection, gui-disown-selection, gui-get-selection)
(gui-selection-owner-p): Define for pc.
(w16--select-text): New function.
* lisp/term/ns-win.el (gui-own-selection, gui-disown-selection)
(gui-get-selection, gui-selection-owner-p): Define for ns.
* lisp/term.el (term-mouse-paste):
* lisp/mouse.el (mouse-yank-primary): Use gui-get-primary-selection.
* src/nsselect.m (ns-own-selection-internal, ns-disown-selection-internal):
Rename from the "x-" prefix.
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/ChangeLog | 36 | ||||
| -rw-r--r-- | lisp/mouse-copy.el | 4 | ||||
| -rw-r--r-- | lisp/mouse.el | 27 | ||||
| -rw-r--r-- | lisp/obsolete/mouse-sel.el | 11 | ||||
| -rw-r--r-- | lisp/select.el | 105 | ||||
| -rw-r--r-- | lisp/simple.el | 14 | ||||
| -rw-r--r-- | lisp/term.el | 11 | ||||
| -rw-r--r-- | lisp/term/ns-win.el | 5 | ||||
| -rw-r--r-- | lisp/term/pc-win.el | 137 | ||||
| -rw-r--r-- | lisp/term/w32-win.el | 7 | ||||
| -rw-r--r-- | lisp/term/x-win.el | 21 | ||||
| -rw-r--r-- | lisp/w32-common-fns.el | 87 | ||||
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/nsselect.m | 43 |
15 files changed, 238 insertions, 282 deletions
| @@ -245,7 +245,12 @@ Emacs-21. | |||
| 245 | 245 | ||
| 246 | * Lisp Changes in Emacs 25.1 | 246 | * Lisp Changes in Emacs 25.1 |
| 247 | 247 | ||
| 248 | ** x-select-text is renamed gui-select-text. | 248 | ** Some "x-*" were obsoleted: |
| 249 | *** x-select-text is renamed gui-select-text. | ||
| 250 | *** x-get-selection is renamed gui-get-selection. | ||
| 251 | *** x-get-clipboard and x-clipboard-yank are marked obsolete. | ||
| 252 | *** x-get-selection-value is renamed to gui-get-primary-selection. | ||
| 253 | *** x-set-selection is renamed to gui-set-selection | ||
| 249 | 254 | ||
| 250 | ** call-process-shell-command and process-file-shell-command | 255 | ** call-process-shell-command and process-file-shell-command |
| 251 | don't take "&rest args" any more. | 256 | don't take "&rest args" any more. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4e27e66a0b3..58dc8372a7a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,39 @@ | |||
| 1 | 2014-10-02 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | Consolidate management/ownership of selections. | ||
| 4 | * select.el (gui-get-selection-alist): New method. | ||
| 5 | (gui-get-selection): Use it. Rename from x-get-selection. | ||
| 6 | (x-get-selection): Define as obsolete alias. | ||
| 7 | (x-get-clipboard): Mark obsolete. | ||
| 8 | (gui-get-primary-selection): New function. | ||
| 9 | (x-get-selection-value): Mark obsolete. | ||
| 10 | (gui-own-selection-alist, gui-disown-selection-alist) | ||
| 11 | (gui-selection-owner-p-alist): New methods. | ||
| 12 | (gui-set-selection): Use them. Rename from x-set-selection. | ||
| 13 | (x-set-selection): Define as obsolete alias. | ||
| 14 | (gui--valid-simple-selection-p): Rename from | ||
| 15 | x-valid-simple-selection-p. | ||
| 16 | * w32-common-fns.el (gui-own-selection, gui-disown-selection) | ||
| 17 | (gui-selection-owner-p, gui-get-selection): Define for w32. | ||
| 18 | (w32-get-selection-value): Rename from x-get-selection-value. | ||
| 19 | Use the new gui-last-selected-text. | ||
| 20 | * term/x-win.el (x-get-selection-value): Remove. | ||
| 21 | (x-clipboard-yank): Declare obsolete. | ||
| 22 | (gui-own-selection, gui-disown-selection, gui-get-selection) | ||
| 23 | (gui-selection-owner-p): Define for x. | ||
| 24 | * term/w32-win.el (w32-win-suspend-error): Rename from | ||
| 25 | x-win-suspend-error. | ||
| 26 | * term/pc-win.el (w16-get-selection-value): Rename from | ||
| 27 | x-get-selection-value. | ||
| 28 | (w16-selection-owner-p): Rename from x-selection-owner-p. | ||
| 29 | (gui-own-selection, gui-disown-selection, gui-get-selection) | ||
| 30 | (gui-selection-owner-p): Define for pc. | ||
| 31 | (w16--select-text): New function. | ||
| 32 | * term/ns-win.el (gui-own-selection, gui-disown-selection) | ||
| 33 | (gui-get-selection, gui-selection-owner-p): Define for ns. | ||
| 34 | * term.el (term-mouse-paste): | ||
| 35 | * mouse.el (mouse-yank-primary): Use gui-get-primary-selection. | ||
| 36 | |||
| 1 | 2014-10-02 H. Dieter Wilhelm <dieter@duenenhof-wilhelm.de> (tiny change) | 37 | 2014-10-02 H. Dieter Wilhelm <dieter@duenenhof-wilhelm.de> (tiny change) |
| 2 | 38 | ||
| 3 | * calc/calc-help.el (calc-describe-thing): Quote strings | 39 | * calc/calc-help.el (calc-describe-thing): Quote strings |
diff --git a/lisp/mouse-copy.el b/lisp/mouse-copy.el index b8bd339acb3..ddfb879318f 100644 --- a/lisp/mouse-copy.el +++ b/lisp/mouse-copy.el | |||
| @@ -147,7 +147,7 @@ If you have the bug (or the real fix :-), please let me know." | |||
| 147 | ;; Third, set the selection. | 147 | ;; Third, set the selection. |
| 148 | ;; (setq me-beg beg me-end end me-range range) ; for debugging | 148 | ;; (setq me-beg beg me-end end me-range range) ; for debugging |
| 149 | (set-buffer end-buffer) | 149 | (set-buffer end-buffer) |
| 150 | (x-set-selection 'SECONDARY (buffer-substring beg end))))) | 150 | (gui-set-selection 'SECONDARY (buffer-substring beg end))))) |
| 151 | 151 | ||
| 152 | 152 | ||
| 153 | (defun mouse-drag-secondary-pasting (start-event) | 153 | (defun mouse-drag-secondary-pasting (start-event) |
| @@ -203,7 +203,7 @@ by johnh@ficus.cs.ucla.edu." | |||
| 203 | (kill-region (overlay-start mouse-secondary-overlay) | 203 | (kill-region (overlay-start mouse-secondary-overlay) |
| 204 | (overlay-end mouse-secondary-overlay))) | 204 | (overlay-end mouse-secondary-overlay))) |
| 205 | ;; (delete-overlay mouse-secondary-overlay) | 205 | ;; (delete-overlay mouse-secondary-overlay) |
| 206 | ;; (x-set-selection 'SECONDARY nil) | 206 | ;; (gui-set-selection 'SECONDARY nil) |
| 207 | ;; (setq mouse-secondary-overlay nil) | 207 | ;; (setq mouse-secondary-overlay nil) |
| 208 | ) | 208 | ) |
| 209 | 209 | ||
diff --git a/lisp/mouse.el b/lisp/mouse.el index 93bd6283158..f569ec3577d 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -1068,24 +1068,7 @@ regardless of where you click." | |||
| 1068 | (let (select-active-regions) | 1068 | (let (select-active-regions) |
| 1069 | (deactivate-mark))) | 1069 | (deactivate-mark))) |
| 1070 | (or mouse-yank-at-point (mouse-set-point click)) | 1070 | (or mouse-yank-at-point (mouse-set-point click)) |
| 1071 | (let ((primary | 1071 | (let ((primary (gui-get-primary-selection))) |
| 1072 | (if (fboundp 'x-get-selection-value) | ||
| 1073 | (if (eq (framep (selected-frame)) 'w32) | ||
| 1074 | ;; MS-Windows emulates PRIMARY in x-get-selection, but not | ||
| 1075 | ;; in x-get-selection-value (the latter only accesses the | ||
| 1076 | ;; clipboard). So try PRIMARY first, in case they selected | ||
| 1077 | ;; something with the mouse in the current Emacs session. | ||
| 1078 | (or (x-get-selection 'PRIMARY) | ||
| 1079 | (x-get-selection-value)) | ||
| 1080 | ;; Else MS-DOS or X. | ||
| 1081 | ;; On X, x-get-selection-value supports more formats and | ||
| 1082 | ;; encodings, so use it in preference to x-get-selection. | ||
| 1083 | (or (x-get-selection-value) | ||
| 1084 | (x-get-selection 'PRIMARY))) | ||
| 1085 | ;; FIXME: What about xterm-mouse-mode etc.? | ||
| 1086 | (x-get-selection 'PRIMARY)))) | ||
| 1087 | (unless primary | ||
| 1088 | (error "No selection is available")) | ||
| 1089 | (push-mark (point)) | 1072 | (push-mark (point)) |
| 1090 | (insert-for-yank primary))) | 1073 | (insert-for-yank primary))) |
| 1091 | 1074 | ||
| @@ -1272,7 +1255,7 @@ This must be bound to a mouse drag event." | |||
| 1272 | (if (numberp (posn-point posn)) | 1255 | (if (numberp (posn-point posn)) |
| 1273 | (setq beg (posn-point posn))) | 1256 | (setq beg (posn-point posn))) |
| 1274 | (move-overlay mouse-secondary-overlay beg (posn-point end)) | 1257 | (move-overlay mouse-secondary-overlay beg (posn-point end)) |
| 1275 | (x-set-selection | 1258 | (gui-set-selection |
| 1276 | 'SECONDARY | 1259 | 'SECONDARY |
| 1277 | (buffer-substring (overlay-start mouse-secondary-overlay) | 1260 | (buffer-substring (overlay-start mouse-secondary-overlay) |
| 1278 | (overlay-end mouse-secondary-overlay)))))) | 1261 | (overlay-end mouse-secondary-overlay)))))) |
| @@ -1347,13 +1330,13 @@ The function returns a non-nil value if it creates a secondary selection." | |||
| 1347 | (if (marker-position mouse-secondary-start) | 1330 | (if (marker-position mouse-secondary-start) |
| 1348 | (save-window-excursion | 1331 | (save-window-excursion |
| 1349 | (delete-overlay mouse-secondary-overlay) | 1332 | (delete-overlay mouse-secondary-overlay) |
| 1350 | (x-set-selection 'SECONDARY nil) | 1333 | (gui-set-selection 'SECONDARY nil) |
| 1351 | (select-window start-window) | 1334 | (select-window start-window) |
| 1352 | (save-excursion | 1335 | (save-excursion |
| 1353 | (goto-char mouse-secondary-start) | 1336 | (goto-char mouse-secondary-start) |
| 1354 | (sit-for 1) | 1337 | (sit-for 1) |
| 1355 | nil)) | 1338 | nil)) |
| 1356 | (x-set-selection | 1339 | (gui-set-selection |
| 1357 | 'SECONDARY | 1340 | 'SECONDARY |
| 1358 | (buffer-substring (overlay-start mouse-secondary-overlay) | 1341 | (buffer-substring (overlay-start mouse-secondary-overlay) |
| 1359 | (overlay-end mouse-secondary-overlay))))))))) | 1342 | (overlay-end mouse-secondary-overlay))))))))) |
| @@ -1486,7 +1469,7 @@ CLICK position, kill the secondary selection." | |||
| 1486 | (setq str (buffer-substring (overlay-start mouse-secondary-overlay) | 1469 | (setq str (buffer-substring (overlay-start mouse-secondary-overlay) |
| 1487 | (overlay-end mouse-secondary-overlay))) | 1470 | (overlay-end mouse-secondary-overlay))) |
| 1488 | (> (length str) 0) | 1471 | (> (length str) 0) |
| 1489 | (x-set-selection 'SECONDARY str)))) | 1472 | (gui-set-selection 'SECONDARY str)))) |
| 1490 | 1473 | ||
| 1491 | 1474 | ||
| 1492 | (defcustom mouse-buffer-menu-maxlen 20 | 1475 | (defcustom mouse-buffer-menu-maxlen 20 |
diff --git a/lisp/obsolete/mouse-sel.el b/lisp/obsolete/mouse-sel.el index 21765c3d652..7d7cd1f137f 100644 --- a/lisp/obsolete/mouse-sel.el +++ b/lisp/obsolete/mouse-sel.el | |||
| @@ -97,7 +97,7 @@ | |||
| 97 | ;; In this mode, mouse-insert-selection just calls mouse-yank-at-click. | 97 | ;; In this mode, mouse-insert-selection just calls mouse-yank-at-click. |
| 98 | ;; | 98 | ;; |
| 99 | ;; Selection/kill-ring interaction is retained | 99 | ;; Selection/kill-ring interaction is retained |
| 100 | ;; interprogram-cut-function = x-select-text | 100 | ;; interprogram-cut-function = gui-select-text |
| 101 | ;; interprogram-paste-function = x-selection-value | 101 | ;; interprogram-paste-function = x-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 |
| @@ -292,15 +292,13 @@ where SELECTION-NAME = name of selection | |||
| 292 | SELECTION-THING-SYMBOL = name of variable where the current selection | 292 | SELECTION-THING-SYMBOL = name of variable where the current selection |
| 293 | type for this selection should be stored.") | 293 | type for this selection should be stored.") |
| 294 | 294 | ||
| 295 | (declare-function x-select-text "term/common-win" (text)) | ||
| 296 | |||
| 297 | (defvar mouse-sel-set-selection-function | 295 | (defvar mouse-sel-set-selection-function |
| 298 | (if (eq mouse-sel-default-bindings 'interprogram-cut-paste) | 296 | (if (eq mouse-sel-default-bindings 'interprogram-cut-paste) |
| 299 | 'x-set-selection | 297 | 'gui-set-selection |
| 300 | (lambda (selection value) | 298 | (lambda (selection value) |
| 301 | (if (eq selection 'PRIMARY) | 299 | (if (eq selection 'PRIMARY) |
| 302 | (x-select-text value) | 300 | (gui-select-text value) |
| 303 | (x-set-selection selection value)))) | 301 | (gui-set-selection selection value)))) |
| 304 | "Function to call to set selection. | 302 | "Function to call to set selection. |
| 305 | Called with two arguments: | 303 | Called with two arguments: |
| 306 | 304 | ||
| @@ -316,7 +314,6 @@ is `interprogram-cut-paste'.") | |||
| 316 | (lambda (selection) | 314 | (lambda (selection) |
| 317 | (if (eq selection 'PRIMARY) | 315 | (if (eq selection 'PRIMARY) |
| 318 | (or (x-selection-value) | 316 | (or (x-selection-value) |
| 319 | (bound-and-true-p x-last-selected-text) | ||
| 320 | (bound-and-true-p x-last-selected-text-primary)) | 317 | (bound-and-true-p x-last-selected-text-primary)) |
| 321 | (x-get-selection selection))) | 318 | (x-get-selection selection))) |
| 322 | "Function to call to get the selection. | 319 | "Function to call to get the selection. |
diff --git a/lisp/select.el b/lisp/select.el index c32b45f1c85..d6be917f291 100644 --- a/lisp/select.el +++ b/lisp/select.el | |||
| @@ -71,9 +71,6 @@ other programs (X Windows clients or MS Windows programs). But, if this | |||
| 71 | variable is set, it is used for the next communication only. | 71 | variable is set, it is used for the next communication only. |
| 72 | After the communication, this variable is set to nil.") | 72 | After the communication, this variable is set to nil.") |
| 73 | 73 | ||
| 74 | (declare-function x-get-selection-internal "xselect.c" | ||
| 75 | (selection-symbol target-type &optional time-stamp terminal)) | ||
| 76 | |||
| 77 | ;; Only declared obsolete in 23.3. | 74 | ;; Only declared obsolete in 23.3. |
| 78 | (define-obsolete-function-alias 'x-selection 'x-get-selection "at least 19.34") | 75 | (define-obsolete-function-alias 'x-selection 'x-get-selection "at least 19.34") |
| 79 | 76 | ||
| @@ -93,6 +90,13 @@ if applicable (i.e. under X11)." | |||
| 93 | Called with one argument (the text selected). | 90 | Called with one argument (the text selected). |
| 94 | Should obey `gui-select-enable-clipboard' where applicable.") | 91 | Should obey `gui-select-enable-clipboard' where applicable.") |
| 95 | 92 | ||
| 93 | (gui-method-declare gui-get-selection #'ignore | ||
| 94 | "Return selected text. | ||
| 95 | Called with 2 arguments: (SELECTION-SYMBOL TARGET-TYPE) | ||
| 96 | SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. | ||
| 97 | \(Those are literal upper-case symbol names, since that's what X expects.) | ||
| 98 | TARGET-TYPE is the type of data desired, typically `STRING'.") | ||
| 99 | |||
| 96 | (defvar gui-last-selected-text nil | 100 | (defvar gui-last-selected-text nil |
| 97 | "Last text passed to `gui-select-text'.") | 101 | "Last text passed to `gui-select-text'.") |
| 98 | 102 | ||
| @@ -112,7 +116,7 @@ On MS-Windows, make TEXT the current selection." | |||
| 112 | (setq gui-last-selected-text text)) | 116 | (setq gui-last-selected-text text)) |
| 113 | (define-obsolete-function-alias 'x-select-text 'gui-select-text "25.1") | 117 | (define-obsolete-function-alias 'x-select-text 'gui-select-text "25.1") |
| 114 | 118 | ||
| 115 | (defun x-get-selection (&optional type data-type) | 119 | (defun gui-get-selection (&optional type data-type) |
| 116 | "Return the value of an X Windows selection. | 120 | "Return the value of an X Windows selection. |
| 117 | The argument TYPE (default `PRIMARY') says which selection, | 121 | The argument TYPE (default `PRIMARY') says which selection, |
| 118 | and the argument DATA-TYPE (default `STRING') says | 122 | and the argument DATA-TYPE (default `STRING') says |
| @@ -126,39 +130,69 @@ all upper-case names. The most often used ones, in addition to | |||
| 126 | DATA-TYPE is usually `STRING', but can also be one of the symbols | 130 | DATA-TYPE is usually `STRING', but can also be one of the symbols |
| 127 | in `selection-converter-alist', which see. This argument is | 131 | in `selection-converter-alist', which see. This argument is |
| 128 | ignored on MS-Windows and MS-DOS." | 132 | ignored on MS-Windows and MS-DOS." |
| 129 | (let ((data (x-get-selection-internal (or type 'PRIMARY) | 133 | (let ((data (gui-call gui-get-selection (or type 'PRIMARY) |
| 130 | (or data-type 'STRING))) | 134 | (or data-type 'STRING)))) |
| 131 | coding) | ||
| 132 | (when (and (stringp data) | 135 | (when (and (stringp data) |
| 133 | (setq data-type (get-text-property 0 'foreign-selection data))) | 136 | (setq data-type (get-text-property 0 'foreign-selection data))) |
| 134 | (setq coding (or next-selection-coding-system | 137 | (let ((coding (or next-selection-coding-system |
| 135 | selection-coding-system | 138 | selection-coding-system |
| 136 | (cond ((eq data-type 'UTF8_STRING) | 139 | (pcase data-type |
| 137 | 'utf-8) | 140 | ('UTF8_STRING 'utf-8) |
| 138 | ((eq data-type 'COMPOUND_TEXT) | 141 | ('COMPOUND_TEXT 'compound-text-with-extensions) |
| 139 | 'compound-text-with-extensions) | 142 | ('C_STRING nil) |
| 140 | ((eq data-type 'C_STRING) | 143 | ('STRING 'iso-8859-1) |
| 141 | nil) | 144 | (_ (error "Unknown selection data type: %S" |
| 142 | ((eq data-type 'STRING) | 145 | type)))))) |
| 143 | 'iso-8859-1) | 146 | (setq data (if coding (decode-coding-string data coding) |
| 144 | (t | 147 | (string-to-multibyte data)))) |
| 145 | (error "Unknown selection data type: %S" type)))) | ||
| 146 | data (if coding (decode-coding-string data coding) | ||
| 147 | (string-to-multibyte data))) | ||
| 148 | (setq next-selection-coding-system nil) | 148 | (setq next-selection-coding-system nil) |
| 149 | (put-text-property 0 (length data) 'foreign-selection data-type data)) | 149 | (put-text-property 0 (length data) 'foreign-selection data-type data)) |
| 150 | data)) | 150 | data)) |
| 151 | (define-obsolete-function-alias 'x-get-selection 'gui-get-selection "25.1") | ||
| 151 | 152 | ||
| 152 | (defun x-get-clipboard () | 153 | (defun x-get-clipboard () |
| 153 | "Return text pasted to the clipboard." | 154 | "Return text pasted to the clipboard." |
| 154 | (x-get-selection-internal 'CLIPBOARD 'STRING)) | 155 | (declare (obsolete gui-get-selection "25.1")) |
| 155 | 156 | (gui-call gui-get-selection 'CLIPBOARD 'STRING)) | |
| 156 | (declare-function x-own-selection-internal "xselect.c" | 157 | |
| 157 | (selection-name selection-value &optional frame)) | 158 | (defun gui-get-primary-selection () |
| 158 | (declare-function x-disown-selection-internal "xselect.c" | 159 | "Return the PRIMARY selection, or the best emulation thereof." |
| 159 | (selection &optional time terminal)) | 160 | (or (gui-get-selection 'PRIMARY) |
| 160 | 161 | (and (fboundp 'w32-get-selection-value) | |
| 161 | (defun x-set-selection (type data) | 162 | (eq (framep (selected-frame)) 'w32) |
| 163 | ;; MS-Windows emulates PRIMARY in x-get-selection, but only | ||
| 164 | ;; within the Emacs session, so consult the clipboard if | ||
| 165 | ;; primary is not found. | ||
| 166 | (w32-get-selection-value)) | ||
| 167 | (error "No selection is available"))) | ||
| 168 | (define-obsolete-function-alias 'x-get-selection-value | ||
| 169 | 'gui-get-primary-selection "25.1") | ||
| 170 | |||
| 171 | (gui-method-declare gui-own-selection nil | ||
| 172 | "Method to assert a selection of type SELECTION and value VALUE. | ||
| 173 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. | ||
| 174 | (Those are literal upper-case symbol names, since that's what X expects.) | ||
| 175 | VALUE is typically a string, or a cons of two markers, but may be | ||
| 176 | anything that the functions on `selection-converter-alist' know about. | ||
| 177 | |||
| 178 | Called with 2 args: (SELECTION VALUE).") | ||
| 179 | |||
| 180 | (gui-method-declare gui-disown-selection nil | ||
| 181 | "If we own the selection SELECTION, disown it. | ||
| 182 | Disowning it means there is no such selection. | ||
| 183 | |||
| 184 | Called with one argument: (SELECTION)") | ||
| 185 | |||
| 186 | (gui-method-declare gui-selection-owner-p #'ignore | ||
| 187 | "Whether the current Emacs process owns the given X Selection. | ||
| 188 | Called with one argument: (SELECTION). | ||
| 189 | The arg should be the name of the selection in question, typically one of | ||
| 190 | the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. | ||
| 191 | (Those are literal upper-case symbol names, since that's what X expects.) | ||
| 192 | For convenience, the symbol nil is the same as `PRIMARY', | ||
| 193 | and t is the same as `SECONDARY'.") | ||
| 194 | |||
| 195 | (defun gui-set-selection (type data) | ||
| 162 | "Make an X selection of type TYPE and value DATA. | 196 | "Make an X selection of type TYPE and value DATA. |
| 163 | The argument TYPE (nil means `PRIMARY') says which selection, and | 197 | The argument TYPE (nil means `PRIMARY') says which selection, and |
| 164 | DATA specifies the contents. TYPE must be a symbol. \(It can also | 198 | DATA specifies the contents. TYPE must be a symbol. \(It can also |
| @@ -186,23 +220,24 @@ are not available to other programs." | |||
| 186 | (list 'PRIMARY (read-string "Set text for pasting: ")) | 220 | (list 'PRIMARY (read-string "Set text for pasting: ")) |
| 187 | (list 'PRIMARY (buffer-substring (region-beginning) (region-end))))) | 221 | (list 'PRIMARY (buffer-substring (region-beginning) (region-end))))) |
| 188 | (if (stringp type) (setq type (intern type))) | 222 | (if (stringp type) (setq type (intern type))) |
| 189 | (or (x-valid-simple-selection-p data) | 223 | (or (gui--valid-simple-selection-p data) |
| 190 | (and (vectorp data) | 224 | (and (vectorp data) |
| 191 | (let ((valid t) | 225 | (let ((valid t) |
| 192 | (i (1- (length data)))) | 226 | (i (1- (length data)))) |
| 193 | (while (>= i 0) | 227 | (while (>= i 0) |
| 194 | (or (x-valid-simple-selection-p (aref data i)) | 228 | (or (gui--valid-simple-selection-p (aref data i)) |
| 195 | (setq valid nil)) | 229 | (setq valid nil)) |
| 196 | (setq i (1- i))) | 230 | (setq i (1- i))) |
| 197 | valid)) | 231 | valid)) |
| 198 | (signal 'error (list "invalid selection" data))) | 232 | (signal 'error (list "invalid selection" data))) |
| 199 | (or type (setq type 'PRIMARY)) | 233 | (or type (setq type 'PRIMARY)) |
| 200 | (if data | 234 | (if data |
| 201 | (x-own-selection-internal type data) | 235 | (gui-call gui-own-selection type data) |
| 202 | (x-disown-selection-internal type)) | 236 | (gui-call gui-disown-selection type)) |
| 203 | data) | 237 | data) |
| 238 | (define-obsolete-function-alias 'x-set-selection 'gui-set-selection "25.1") | ||
| 204 | 239 | ||
| 205 | (defun x-valid-simple-selection-p (data) | 240 | (defun gui--valid-simple-selection-p (data) |
| 206 | (or (bufferp data) | 241 | (or (bufferp data) |
| 207 | (and (consp data) | 242 | (and (consp data) |
| 208 | (markerp (car data)) | 243 | (markerp (car data)) |
| @@ -358,7 +393,7 @@ two markers or an overlay. Otherwise, it is nil." | |||
| 358 | (apply 'vector all))) | 393 | (apply 'vector all))) |
| 359 | 394 | ||
| 360 | (defun xselect-convert-to-delete (selection _type _value) | 395 | (defun xselect-convert-to-delete (selection _type _value) |
| 361 | (x-disown-selection-internal selection) | 396 | (gui-call gui-disown-selection selection) |
| 362 | ;; A return value of nil means that we do not know how to do this conversion, | 397 | ;; A return value of nil means that we do not know how to do this conversion, |
| 363 | ;; and replies with an "error". A return value of NULL means that we have | 398 | ;; and replies with an "error". A return value of NULL means that we have |
| 364 | ;; done the conversion (and any side-effects) but have no value to return. | 399 | ;; done the conversion (and any side-effects) but have no value to return. |
diff --git a/lisp/simple.el b/lisp/simple.el index 8504cf4be19..f96904cc177 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3629,7 +3629,7 @@ No filtering is done unless a hook says to." | |||
| 3629 | 3629 | ||
| 3630 | ;;;; Window system cut and paste hooks. | 3630 | ;;;; Window system cut and paste hooks. |
| 3631 | 3631 | ||
| 3632 | (defvar interprogram-cut-function #'x-select-text | 3632 | (defvar interprogram-cut-function #'gui-select-text |
| 3633 | "Function to call to make a killed region available to other programs. | 3633 | "Function to call to make a killed region available to other programs. |
| 3634 | Most window systems provide a facility for cutting and pasting | 3634 | Most window systems provide a facility for cutting and pasting |
| 3635 | text between different programs, such as the clipboard on X and | 3635 | text between different programs, such as the clipboard on X and |
| @@ -4497,8 +4497,6 @@ a mistake; see the documentation of `set-mark'." | |||
| 4497 | (signal 'mark-inactive nil))) | 4497 | (signal 'mark-inactive nil))) |
| 4498 | 4498 | ||
| 4499 | ;; Behind display-selections-p. | 4499 | ;; Behind display-selections-p. |
| 4500 | (declare-function x-selection-owner-p "xselect.c" | ||
| 4501 | (&optional selection terminal)) | ||
| 4502 | (declare-function x-selection-exists-p "xselect.c" | 4500 | (declare-function x-selection-exists-p "xselect.c" |
| 4503 | (&optional selection terminal)) | 4501 | (&optional selection terminal)) |
| 4504 | 4502 | ||
| @@ -4525,15 +4523,15 @@ run `deactivate-mark-hook'." | |||
| 4525 | ;; the region prior to the last command modifying the buffer. | 4523 | ;; the region prior to the last command modifying the buffer. |
| 4526 | ;; Set the selection to that, or to the current region. | 4524 | ;; Set the selection to that, or to the current region. |
| 4527 | (cond (saved-region-selection | 4525 | (cond (saved-region-selection |
| 4528 | (x-set-selection 'PRIMARY saved-region-selection) | 4526 | (gui-set-selection 'PRIMARY saved-region-selection) |
| 4529 | (setq saved-region-selection nil)) | 4527 | (setq saved-region-selection nil)) |
| 4530 | ;; If another program has acquired the selection, region | 4528 | ;; If another program has acquired the selection, region |
| 4531 | ;; deactivation should not clobber it (Bug#11772). | 4529 | ;; deactivation should not clobber it (Bug#11772). |
| 4532 | ((and (/= (region-beginning) (region-end)) | 4530 | ((and (/= (region-beginning) (region-end)) |
| 4533 | (or (x-selection-owner-p 'PRIMARY) | 4531 | (or (call-gui gui-selection-owner-p 'PRIMARY) |
| 4534 | (null (x-selection-exists-p 'PRIMARY)))) | 4532 | (null (gui-selection-exists-p 'PRIMARY)))) |
| 4535 | (x-set-selection 'PRIMARY | 4533 | (gui-set-selection 'PRIMARY |
| 4536 | (funcall region-extract-function nil))))) | 4534 | (funcall region-extract-function nil))))) |
| 4537 | (when mark-active (force-mode-line-update)) ;Refresh toolbar (bug#16382). | 4535 | (when mark-active (force-mode-line-update)) ;Refresh toolbar (bug#16382). |
| 4538 | (cond | 4536 | (cond |
| 4539 | ((eq (car-safe transient-mark-mode) 'only) | 4537 | ((eq (car-safe transient-mark-mode) 'only) |
diff --git a/lisp/term.el b/lisp/term.el index 825a202c046..611a0c660e1 100644 --- a/lisp/term.el +++ b/lisp/term.el | |||
| @@ -1249,16 +1249,7 @@ without any interpretation." | |||
| 1249 | (run-hooks 'mouse-leave-buffer-hook) | 1249 | (run-hooks 'mouse-leave-buffer-hook) |
| 1250 | (setq this-command 'yank) | 1250 | (setq this-command 'yank) |
| 1251 | (mouse-set-point click) | 1251 | (mouse-set-point click) |
| 1252 | (term-send-raw-string | 1252 | (term-send-raw-string (gui-get-primary-selection)))) |
| 1253 | ;; From `mouse-yank-primary': | ||
| 1254 | (or (if (fboundp 'x-get-selection-value) | ||
| 1255 | (if (eq system-type 'windows-nt) | ||
| 1256 | (or (x-get-selection 'PRIMARY) | ||
| 1257 | (x-get-selection-value)) | ||
| 1258 | (or (x-get-selection-value) | ||
| 1259 | (x-get-selection 'PRIMARY))) | ||
| 1260 | (x-get-selection 'PRIMARY)) | ||
| 1261 | (error "No selection is available"))))) | ||
| 1262 | 1253 | ||
| 1263 | (defun term-paste () | 1254 | (defun term-paste () |
| 1264 | "Insert the last stretch of killed text at point." | 1255 | "Insert the last stretch of killed text at point." |
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index fc13a2c5ddf..5889baf6946 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el | |||
| @@ -971,6 +971,11 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 971 | (when gui-select-enable-clipboard | 971 | (when gui-select-enable-clipboard |
| 972 | (ns-set-pasteboard text)))) | 972 | (ns-set-pasteboard text)))) |
| 973 | 973 | ||
| 974 | (gui-method-define gui-own-selection x #'ns-own-selection-internal) | ||
| 975 | (gui-method-define gui-disown-selection x #'ns-disown-selection-internal) | ||
| 976 | (gui-method-define gui-selection-owner-p x #'ns-selection-owner-p) | ||
| 977 | (gui-method-define gui-get-selection x #'x-get-selection-internal) ;FIXME:name! | ||
| 978 | |||
| 974 | (provide 'ns-win) | 979 | (provide 'ns-win) |
| 975 | 980 | ||
| 976 | ;;; ns-win.el ends here | 981 | ;;; ns-win.el ends here |
diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el index 264d881bc15..3498937b4d2 100644 --- a/lisp/term/pc-win.el +++ b/lisp/term/pc-win.el | |||
| @@ -219,7 +219,7 @@ the operating system.") | |||
| 219 | ; | 219 | ; |
| 220 | ;;;; Selections | 220 | ;;;; Selections |
| 221 | ; | 221 | ; |
| 222 | (defun x-get-selection-value () | 222 | (defun w16-get-selection-value () |
| 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 |
| @@ -238,93 +238,44 @@ Consult the selection. Treat empty strings as if they were unset." | |||
| 238 | (t | 238 | (t |
| 239 | (setq gui-last-selected-text text)))))) | 239 | (setq gui-last-selected-text text)))))) |
| 240 | 240 | ||
| 241 | ;; x-selection-owner-p is used in simple.el. | 241 | ;; gui-selection-owner-p is used in simple.el. |
| 242 | (defun x-selection-owner-p (&optional _selection _terminal) | 242 | (gui-method-define gui-selection-owner-p pc #'w16-selection-owner-p) |
| 243 | "Whether the current Emacs process owns the given X Selection. | 243 | (defun w16-selection-owner-p (_selection) |
| 244 | The arg should be the name of the selection in question, typically one of | 244 | ;; FIXME: Other systems don't obey gui-select-enable-clipboard here. |
| 245 | the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. | 245 | (if gui-select-enable-clipboard |
| 246 | \(Those are literal upper-case symbol names, since that's what X expects.) | 246 | (let ((text |
| 247 | For convenience, the symbol nil is the same as `PRIMARY', | 247 | ;; Don't die if w16-get-clipboard-data signals an error. |
| 248 | and t is the same as `SECONDARY'. | 248 | (ignore-errors |
| 249 | 249 | (w16-get-clipboard-data)))) | |
| 250 | TERMINAL should be a terminal object or a frame specifying the X | 250 | ;; We consider ourselves the owner of the selection |
| 251 | server to query. If omitted or nil, that stands for the selected | 251 | ;; if it does not exist, or exists and compares |
| 252 | frame's display, or the first available X display. | 252 | ;; equal with the last text we've put into the |
| 253 | 253 | ;; Windows clipboard. | |
| 254 | On Nextstep, TERMINAL is unused. | 254 | (cond |
| 255 | 255 | ((not text) t) | |
| 256 | \(fn &optional SELECTION TERMINAL)" | 256 | ((or (eq text gui-last-selected-text) |
| 257 | (if gui-select-enable-clipboard | 257 | (string= text gui-last-selected-text)) |
| 258 | (let (text) | 258 | text) |
| 259 | ;; Don't die if w16-get-clipboard-data signals an error. | 259 | (t nil))))) |
| 260 | (ignore-errors | 260 | |
| 261 | (setq text (w16-get-clipboard-data))) | 261 | ;; gui-own-selection and gui-disown-selection are used in gui-set-selection. |
| 262 | ;; We consider ourselves the owner of the selection if it does | 262 | (gui-method-define gui-own-selection pc |
| 263 | ;; not exist, or exists and compares equal with the last text | 263 | (lambda (_selection value) |
| 264 | ;; we've put into the Windows clipboard. | 264 | ;; FIXME: Other systems don't obey |
| 265 | (cond | 265 | ;; gui-select-enable-clipboard here. |
| 266 | ((not text) t) | 266 | (ignore-errors |
| 267 | ((or (eq text gui-last-selected-text) | 267 | (w16--select-text value)) |
| 268 | (string= text gui-last-selected-text)) | 268 | value)) |
| 269 | text) | 269 | |
| 270 | (t nil))))) | 270 | (gui-method-define gui-disown-selection pc |
| 271 | 271 | (lambda (selection &optional _time-object _terminal) | |
| 272 | ;; x-own-selection-internal and x-disown-selection-internal are used | 272 | (if (w16-selection-owner-p selection) |
| 273 | ;; in select.el:x-set-selection. | 273 | t))) |
| 274 | (defun x-own-selection-internal (_selection value &optional _frame) | 274 | |
| 275 | "Assert an X selection of the type SELECTION with and value VALUE. | 275 | ;; gui-get-selection is used in select.el |
| 276 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. | 276 | (gui-method-define gui-get-selection pc |
| 277 | \(Those are literal upper-case symbol names, since that's what X expects.) | 277 | (lambda (selection-symbol target-type) |
| 278 | VALUE is typically a string, or a cons of two markers, but may be | 278 | (w16-get-selection-value))) |
| 279 | anything that the functions on `selection-converter-alist' know about. | ||
| 280 | |||
| 281 | FRAME should be a frame that should own the selection. If omitted or | ||
| 282 | nil, it defaults to the selected frame. | ||
| 283 | |||
| 284 | On Nextstep, FRAME is unused. | ||
| 285 | |||
| 286 | \(fn SELECTION VALUE &optional FRAME)" | ||
| 287 | (ignore-errors | ||
| 288 | (x-select-text value)) | ||
| 289 | value) | ||
| 290 | |||
| 291 | (defun x-disown-selection-internal (selection &optional _time-object _terminal) | ||
| 292 | "If we own the selection SELECTION, disown it. | ||
| 293 | Disowning it means there is no such selection. | ||
| 294 | |||
| 295 | Sets the last-change time for the selection to TIME-OBJECT (by default | ||
| 296 | the time of the last event). | ||
| 297 | |||
| 298 | TERMINAL should be a terminal object or a frame specifying the X | ||
| 299 | server to query. If omitted or nil, that stands for the selected | ||
| 300 | frame's display, or the first available X display. | ||
| 301 | |||
| 302 | On Nextstep, the TIME-OBJECT and TERMINAL arguments are unused. | ||
| 303 | On MS-DOS, all this does is return non-nil if we own the selection. | ||
| 304 | |||
| 305 | \(fn SELECTION &optional TIME-OBJECT TERMINAL)" | ||
| 306 | (if (x-selection-owner-p selection) | ||
| 307 | t)) | ||
| 308 | |||
| 309 | ;; x-get-selection-internal is used in select.el | ||
| 310 | (defun x-get-selection-internal (_selection-symbol _target-type | ||
| 311 | &optional _time-stamp _terminal) | ||
| 312 | "Return text selected from some X window. | ||
| 313 | SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. | ||
| 314 | \(Those are literal upper-case symbol names, since that's what X expects.) | ||
| 315 | TARGET-TYPE is the type of data desired, typically `STRING'. | ||
| 316 | |||
| 317 | TIME-STAMP is the time to use in the XConvertSelection call for foreign | ||
| 318 | selections. If omitted, defaults to the time for the last event. | ||
| 319 | |||
| 320 | TERMINAL should be a terminal object or a frame specifying the X | ||
| 321 | server to query. If omitted or nil, that stands for the selected | ||
| 322 | frame's display, or the first available X display. | ||
| 323 | |||
| 324 | On Nextstep, TIME-STAMP and TERMINAL are unused. | ||
| 325 | |||
| 326 | \(fn SELECTION-SYMBOL TARGET-TYPE &optional TIME-STAMP TERMINAL)" | ||
| 327 | (x-get-selection-value)) | ||
| 328 | 279 | ||
| 329 | ;; From src/fontset.c: | 280 | ;; From src/fontset.c: |
| 330 | (fset 'query-fontset 'ignore) | 281 | (fset 'query-fontset 'ignore) |
| @@ -429,7 +380,7 @@ Errors out because it is not supposed to be called, ever." | |||
| 429 | (setq split-window-keep-point t) | 380 | (setq split-window-keep-point t) |
| 430 | ;; Arrange for the kill and yank functions to set and check the | 381 | ;; Arrange for the kill and yank functions to set and check the |
| 431 | ;; clipboard. | 382 | ;; clipboard. |
| 432 | (setq interprogram-paste-function 'x-get-selection-value) | 383 | (setq interprogram-paste-function #'w16-get-selection-value) |
| 433 | (menu-bar-enable-clipboard) | 384 | (menu-bar-enable-clipboard) |
| 434 | (run-hooks 'terminal-init-msdos-hook)) | 385 | (run-hooks 'terminal-init-msdos-hook)) |
| 435 | 386 | ||
| @@ -446,10 +397,10 @@ Errors out because it is not supposed to be called, ever." | |||
| 446 | 397 | ||
| 447 | (declare-function w16-set-clipboard-data "w16select.c" | 398 | (declare-function w16-set-clipboard-data "w16select.c" |
| 448 | (string &optional ignored)) | 399 | (string &optional ignored)) |
| 449 | (gui-method-define gui-select-text pc | 400 | (gui-method-define gui-select-text pc #'w16--select-text) |
| 450 | (lambda (text) | 401 | (defun w16--select-text (text) |
| 451 | (when gui-select-enable-clipboard | 402 | (when gui-select-enable-clipboard |
| 452 | (w16-set-clipboard-data text)))) | 403 | (w16-set-clipboard-data text))) |
| 453 | 404 | ||
| 454 | ;; --------------------------------------------------------------------------- | 405 | ;; --------------------------------------------------------------------------- |
| 455 | 406 | ||
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el index 3eb8e69c28d..8ef718ad230 100644 --- a/lisp/term/w32-win.el +++ b/lisp/term/w32-win.el | |||
| @@ -205,9 +205,8 @@ European languages which are distributed with Windows as | |||
| 205 | 205 | ||
| 206 | See the documentation of `create-fontset-from-fontset-spec' for the format.") | 206 | See the documentation of `create-fontset-from-fontset-spec' for the format.") |
| 207 | 207 | ||
| 208 | (defun x-win-suspend-error () | 208 | (defun w32-win-suspend-error () |
| 209 | "Report an error when a suspend is attempted. | 209 | "Report an error when a suspend is attempted." |
| 210 | This returns an error if any Emacs frames are X frames, or always under W32." | ||
| 211 | (error "Suspending an Emacs running under W32 makes no sense")) | 210 | (error "Suspending an Emacs running under W32 makes no sense")) |
| 212 | 211 | ||
| 213 | (defvar dynamic-library-alist) | 212 | (defvar dynamic-library-alist) |
| @@ -353,7 +352,7 @@ This returns an error if any Emacs frames are X frames, or always under W32." | |||
| 353 | (cons '(reverse . t) default-frame-alist))))) | 352 | (cons '(reverse . t) default-frame-alist))))) |
| 354 | 353 | ||
| 355 | ;; Don't let Emacs suspend under Windows. | 354 | ;; Don't let Emacs suspend under Windows. |
| 356 | (add-hook 'suspend-hook 'x-win-suspend-error) | 355 | (add-hook 'suspend-hook #'w32-win-suspend-error) |
| 357 | 356 | ||
| 358 | ;; Turn off window-splitting optimization; w32 is usually fast enough | 357 | ;; Turn off window-splitting optimization; w32 is usually fast enough |
| 359 | ;; that this is only annoying. | 358 | ;; that this is only annoying. |
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index daaef61e494..a50f886c66a 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el | |||
| @@ -1290,16 +1290,9 @@ The value nil is the same as the list (UTF8_STRING COMPOUND_TEXT STRING)." | |||
| 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) | 1291 | (setq interprogram-paste-function 'x-selection-value) |
| 1292 | 1292 | ||
| 1293 | ;; Make paste from other applications use the decoding in x-select-request-type | ||
| 1294 | ;; and not just STRING. | ||
| 1295 | (defun x-get-selection-value () | ||
| 1296 | "Get the current value of the PRIMARY selection. | ||
| 1297 | Request data types in the order specified by `x-select-request-type'." | ||
| 1298 | (x-selection-value-internal 'PRIMARY)) | ||
| 1299 | |||
| 1300 | (defun x-clipboard-yank () | 1293 | (defun x-clipboard-yank () |
| 1301 | ;; FIXME: How is that different from `clipboard-yank'? | ||
| 1302 | "Insert the clipboard contents, or the last stretch of killed text." | 1294 | "Insert the clipboard contents, or the last stretch of killed text." |
| 1295 | (declare (obsolete clipboard-yank "25.1")) | ||
| 1303 | (interactive "*") | 1296 | (interactive "*") |
| 1304 | (let ((clipboard-text (x-selection-value-internal 'CLIPBOARD)) | 1297 | (let ((clipboard-text (x-selection-value-internal 'CLIPBOARD)) |
| 1305 | (x-select-enable-clipboard t)) | 1298 | (x-select-enable-clipboard t)) |
| @@ -1325,9 +1318,9 @@ Request data types in the order specified by `x-select-request-type'." | |||
| 1325 | 1318 | ||
| 1326 | (defun x-win-suspend-error () | 1319 | (defun x-win-suspend-error () |
| 1327 | "Report an error when a suspend is attempted. | 1320 | "Report an error when a suspend is attempted. |
| 1328 | This returns an error if any Emacs frames are X frames, or always under W32." | 1321 | This returns an error if any Emacs frames are X frames." |
| 1329 | ;; Don't allow suspending if any of the frames are X frames. | 1322 | ;; Don't allow suspending if any of the frames are X frames. |
| 1330 | (if (memq 'x (mapcar 'window-system (frame-list))) | 1323 | (if (memq 'x (mapcar #'window-system (frame-list))) |
| 1331 | (error "Cannot suspend Emacs while running under X"))) | 1324 | (error "Cannot suspend Emacs while running under X"))) |
| 1332 | 1325 | ||
| 1333 | (defvar x-initialized nil | 1326 | (defvar x-initialized nil |
| @@ -1469,15 +1462,19 @@ This returns an error if any Emacs frames are X frames, or always under W32." | |||
| 1469 | (gui-method-define gui-select-text x | 1462 | (gui-method-define gui-select-text x |
| 1470 | (lambda (text) | 1463 | (lambda (text) |
| 1471 | (when x-select-enable-primary | 1464 | (when x-select-enable-primary |
| 1472 | (x-set-selection 'PRIMARY text) | 1465 | (gui-set-selection 'PRIMARY text) |
| 1473 | (setq x-last-selected-text-primary text)) | 1466 | (setq x-last-selected-text-primary text)) |
| 1474 | (when x-select-enable-clipboard | 1467 | (when x-select-enable-clipboard |
| 1475 | ;; When cutting, the selection is cleared and PRIMARY | 1468 | ;; When cutting, the selection is cleared and PRIMARY |
| 1476 | ;; set to the empty string. Prevent that, PRIMARY | 1469 | ;; set to the empty string. Prevent that, PRIMARY |
| 1477 | ;; should not be reset by cut (Bug#16382). | 1470 | ;; should not be reset by cut (Bug#16382). |
| 1478 | (setq saved-region-selection text) | 1471 | (setq saved-region-selection text) |
| 1479 | (x-set-selection 'CLIPBOARD text) | 1472 | (gui-set-selection 'CLIPBOARD text) |
| 1480 | (setq x-last-selected-text-clipboard text)))) | 1473 | (setq x-last-selected-text-clipboard text)))) |
| 1474 | (gui-method-define gui-own-selection x #'x-own-selection-internal) | ||
| 1475 | (gui-method-define gui-disown-selection x #'x-disown-selection-internal) | ||
| 1476 | (gui-method-define gui-selection-owner-p x #'x-selection-owner-p) | ||
| 1477 | (gui-method-define gui-get-selection x #'x-get-selection-internal) | ||
| 1481 | 1478 | ||
| 1482 | ;; Initiate drag and drop | 1479 | ;; Initiate drag and drop |
| 1483 | (add-hook 'after-make-frame-functions 'x-dnd-init-frame) | 1480 | (add-hook 'after-make-frame-functions 'x-dnd-init-frame) |
diff --git a/lisp/w32-common-fns.el b/lisp/w32-common-fns.el index 343a4c25895..3f8cbc19dba 100644 --- a/lisp/w32-common-fns.el +++ b/lisp/w32-common-fns.el | |||
| @@ -41,53 +41,23 @@ That includes all Windows systems except for 9X/Me." | |||
| 41 | (declare-function x-server-version "w32fns.c" (&optional display)) | 41 | (declare-function x-server-version "w32fns.c" (&optional display)) |
| 42 | 42 | ||
| 43 | ;;; Fix interface to (X-specific) mouse.el | 43 | ;;; Fix interface to (X-specific) mouse.el |
| 44 | (defun x-set-selection (type data) | 44 | (gui-method-define gui-own-selection w32 |
| 45 | "Make an X selection of type TYPE and value DATA. | 45 | (lambda (type value) |
| 46 | The argument TYPE (nil means `PRIMARY') says which selection, and | 46 | (put 'x-selections (or type 'PRIMARY) data))) |
| 47 | DATA specifies the contents. TYPE must be a symbol. \(It can also | 47 | |
| 48 | be a string, which stands for the symbol with that name, but this | 48 | (gui-method-define gui-disown-selection w32 |
| 49 | is considered obsolete.) DATA may be a string, a symbol, an | 49 | (lambda (type &optional _time-object _frame) |
| 50 | integer (or a cons of two integers or list of two integers). | 50 | (put 'x-selections (or type 'PRIMARY) nil))) |
| 51 | 51 | ||
| 52 | The selection may also be a cons of two markers pointing to the same buffer, | 52 | (gui-method-define gui-get-selection w32 |
| 53 | or an overlay. In these cases, the selection is considered to be the text | 53 | (lambda (&optional type _data-type) |
| 54 | between the markers *at whatever time the selection is examined*. | 54 | (get 'x-selections (or type 'PRIMARY)))) |
| 55 | Thus, editing done in the buffer after you specify the selection | 55 | |
| 56 | can alter the effective value of the selection. | 56 | ;; gui-selection-owner-p is used in simple.el |
| 57 | 57 | (gui-method-define gui-selection-owner-p w32 | |
| 58 | The data may also be a vector of valid non-vector selection values. | 58 | (lambda (selection) |
| 59 | 59 | (and (memq selection '(nil PRIMARY SECONDARY)) | |
| 60 | The return value is DATA. | 60 | (get 'x-selections (or selection 'PRIMARY))))) |
| 61 | |||
| 62 | Interactively, this command sets the primary selection. Without | ||
| 63 | prefix argument, it reads the selection in the minibuffer. With | ||
| 64 | prefix argument, it uses the text of the region as the selection value. | ||
| 65 | |||
| 66 | Note that on MS-Windows, primary and secondary selections set by Emacs | ||
| 67 | are not available to other programs." | ||
| 68 | (put 'x-selections (or type 'PRIMARY) data)) | ||
| 69 | |||
| 70 | (defun x-get-selection (&optional type _data-type) | ||
| 71 | "Return the value of an X Windows selection. | ||
| 72 | The argument TYPE (default `PRIMARY') says which selection, | ||
| 73 | and the argument DATA-TYPE (default `STRING') says | ||
| 74 | how to convert the data. | ||
| 75 | |||
| 76 | TYPE may be any symbol \(but nil stands for `PRIMARY'). However, | ||
| 77 | only a few symbols are commonly used. They conventionally have | ||
| 78 | all upper-case names. The most often used ones, in addition to | ||
| 79 | `PRIMARY', are `SECONDARY' and `CLIPBOARD'. | ||
| 80 | |||
| 81 | DATA-TYPE is usually `STRING', but can also be one of the symbols | ||
| 82 | in `selection-converter-alist', which see. This argument is | ||
| 83 | ignored on MS-Windows and MS-DOS." | ||
| 84 | (get 'x-selections (or type 'PRIMARY))) | ||
| 85 | |||
| 86 | ;; x-selection-owner-p is used in simple.el | ||
| 87 | (defun x-selection-owner-p (&optional selection _terminal) | ||
| 88 | "" ; placeholder for doc.c | ||
| 89 | (and (memq selection '(nil PRIMARY SECONDARY)) | ||
| 90 | (get 'x-selections (or selection 'PRIMARY)))) | ||
| 91 | 61 | ||
| 92 | ;; The "Windows" keys on newer keyboards bring up the Start menu | 62 | ;; The "Windows" keys on newer keyboards bring up the Start menu |
| 93 | ;; whether you want it or not - make Emacs ignore these keystrokes | 63 | ;; whether you want it or not - make Emacs ignore these keystrokes |
| @@ -103,30 +73,29 @@ ignored on MS-Windows and MS-DOS." | |||
| 103 | ;; We keep track of the last text selected here, so we can check the | 73 | ;; We keep track of the last text selected here, so we can check the |
| 104 | ;; current selection against it, and avoid passing back our own text | 74 | ;; current selection against it, and avoid passing back our own text |
| 105 | ;; from x-selection-value. | 75 | ;; from x-selection-value. |
| 106 | (defvar x-last-selected-text nil) | ||
| 107 | 76 | ||
| 108 | (defun x-get-selection-value () | 77 | (defun w32-get-selection-value () |
| 109 | "Return the value of the current selection. | 78 | "Return the value of the current selection. |
| 110 | Consult the selection. Treat empty strings as if they were unset." | 79 | Consult the selection. Treat empty strings as if they were unset." |
| 111 | (if gui-select-enable-clipboard | 80 | (if gui-select-enable-clipboard |
| 112 | (let (text) | 81 | (let ((text |
| 113 | ;; Don't die if x-get-selection signals an error. | 82 | ;; Don't die if x-get-selection signals an error. |
| 114 | (with-demoted-errors "w32-get-clipboard-data:%s" | 83 | (with-demoted-errors "w32-get-clipboard-data:%S" |
| 115 | (setq text (w32-get-clipboard-data))) | 84 | (w32-get-clipboard-data)))) |
| 116 | (if (string= text "") (setq text nil)) | 85 | (if (string= text "") (setq text nil)) |
| 117 | (cond | 86 | (cond |
| 118 | ((not text) nil) | 87 | ((not text) nil) |
| 119 | ((eq text x-last-selected-text) nil) | 88 | ((eq text gui-last-selected-text) nil) |
| 120 | ((string= text x-last-selected-text) | 89 | ((string= text gui-last-selected-text) |
| 121 | ;; Record the newer string, so subsequent calls can use the 'eq' test. | 90 | ;; Record the newer string, so subsequent calls can use the 'eq' test. |
| 122 | (setq x-last-selected-text text) | 91 | (setq gui-last-selected-text text) |
| 123 | nil) | 92 | nil) |
| 124 | (t | 93 | (t |
| 125 | (setq x-last-selected-text text)))))) | 94 | (setq gui-last-selected-text text)))))) |
| 126 | 95 | ||
| 127 | (defalias 'x-selection-value 'x-get-selection-value) | 96 | (defalias 'x-selection-value #'w32-get-selection-value) |
| 128 | 97 | ||
| 129 | ;; Arrange for the kill and yank functions to set and check the clipboard. | 98 | ;; Arrange for the kill and yank functions to set and check the clipboard. |
| 130 | (setq interprogram-paste-function 'x-get-selection-value) | 99 | (setq interprogram-paste-function #'w32-get-selection-value) |
| 131 | 100 | ||
| 132 | (provide 'w32-common-fns) | 101 | (provide 'w32-common-fns) |
diff --git a/src/ChangeLog b/src/ChangeLog index 34f19b85389..2c5aa61e417 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-10-02 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * nsselect.m (ns-own-selection-internal, ns-disown-selection-internal): | ||
| 4 | Rename from the "x-" prefix. | ||
| 5 | |||
| 1 | 2014-10-01 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2014-10-01 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * xselect.c (selection-converter-alist): Fix docstring. | 8 | * xselect.c (selection-converter-alist): Fix docstring. |
diff --git a/src/nsselect.m b/src/nsselect.m index 038849c0aed..3712ba064e7 100644 --- a/src/nsselect.m +++ b/src/nsselect.m | |||
| @@ -328,19 +328,14 @@ ns_string_to_pasteboard (id pb, Lisp_Object str) | |||
| 328 | ========================================================================== */ | 328 | ========================================================================== */ |
| 329 | 329 | ||
| 330 | 330 | ||
| 331 | DEFUN ("x-own-selection-internal", Fx_own_selection_internal, | 331 | DEFUN ("ns-own-selection-internal", Fns_own_selection_internal, |
| 332 | Sx_own_selection_internal, 2, 3, 0, | 332 | Sns_own_selection_internal, 2, 2, 0, |
| 333 | doc: /* Assert an X selection of type SELECTION and value VALUE. | 333 | doc: /* Assert an X selection of type SELECTION and value VALUE. |
| 334 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. | 334 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. |
| 335 | \(Those are literal upper-case symbol names, since that's what X expects.) | 335 | \(Those are literal upper-case symbol names, since that's what X expects.) |
| 336 | VALUE is typically a string, or a cons of two markers, but may be | 336 | VALUE is typically a string, or a cons of two markers, but may be |
| 337 | anything that the functions on `selection-converter-alist' know about. | 337 | anything that the functions on `selection-converter-alist' know about. */) |
| 338 | 338 | (Lisp_Object selection, Lisp_Object value) | |
| 339 | FRAME should be a frame that should own the selection. If omitted or | ||
| 340 | nil, it defaults to the selected frame. | ||
| 341 | |||
| 342 | On Nextstep, FRAME is unused. */) | ||
| 343 | (Lisp_Object selection, Lisp_Object value, Lisp_Object frame) | ||
| 344 | { | 339 | { |
| 345 | id pb; | 340 | id pb; |
| 346 | Lisp_Object old_value, new_value; | 341 | Lisp_Object old_value, new_value; |
| @@ -385,21 +380,11 @@ On Nextstep, FRAME is unused. */) | |||
| 385 | } | 380 | } |
| 386 | 381 | ||
| 387 | 382 | ||
| 388 | DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal, | 383 | DEFUN ("ns-disown-selection-internal", Fns_disown_selection_internal, |
| 389 | Sx_disown_selection_internal, 1, 3, 0, | 384 | Sns_disown_selection_internal, 1, 1, 0, |
| 390 | doc: /* If we own the selection SELECTION, disown it. | 385 | doc: /* If we own the selection SELECTION, disown it. |
| 391 | Disowning it means there is no such selection. | 386 | Disowning it means there is no such selection. */) |
| 392 | 387 | (Lisp_Object selection) | |
| 393 | Sets the last-change time for the selection to TIME-OBJECT (by default | ||
| 394 | the time of the last event). | ||
| 395 | |||
| 396 | TERMINAL should be a terminal object or a frame specifying the X | ||
| 397 | server to query. If omitted or nil, that stands for the selected | ||
| 398 | frame's display, or the first available X display. | ||
| 399 | |||
| 400 | On Nextstep, the TIME-OBJECT and TERMINAL arguments are unused. | ||
| 401 | On MS-DOS, all this does is return non-nil if we own the selection. */) | ||
| 402 | (Lisp_Object selection, Lisp_Object time_object, Lisp_Object terminal) | ||
| 403 | { | 388 | { |
| 404 | id pb; | 389 | id pb; |
| 405 | check_window_system (NULL); | 390 | check_window_system (NULL); |
| @@ -443,7 +428,7 @@ On Nextstep, TERMINAL is unused. */) | |||
| 443 | } | 428 | } |
| 444 | 429 | ||
| 445 | 430 | ||
| 446 | DEFUN ("x-selection-owner-p", Fx_selection_owner_p, Sx_selection_owner_p, | 431 | DEFUN ("ns-selection-owner-p", Fns_selection_owner_p, Sns_selection_owner_p, |
| 447 | 0, 2, 0, | 432 | 0, 2, 0, |
| 448 | doc: /* Whether the current Emacs process owns the given X Selection. | 433 | doc: /* Whether the current Emacs process owns the given X Selection. |
| 449 | The arg should be the name of the selection in question, typically one of | 434 | The arg should be the name of the selection in question, typically one of |
| @@ -507,7 +492,7 @@ On Nextstep, TIME-STAMP and TERMINAL are unused. */) | |||
| 507 | DEFUN ("ns-get-selection-internal", Fns_get_selection_internal, | 492 | DEFUN ("ns-get-selection-internal", Fns_get_selection_internal, |
| 508 | Sns_get_selection_internal, 1, 1, 0, | 493 | Sns_get_selection_internal, 1, 1, 0, |
| 509 | doc: /* Returns the value of SELECTION as a string. | 494 | doc: /* Returns the value of SELECTION as a string. |
| 510 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */) | 495 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */) |
| 511 | (Lisp_Object selection) | 496 | (Lisp_Object selection) |
| 512 | { | 497 | { |
| 513 | id pb; | 498 | id pb; |
| @@ -520,7 +505,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */) | |||
| 520 | DEFUN ("ns-store-selection-internal", Fns_store_selection_internal, | 505 | DEFUN ("ns-store-selection-internal", Fns_store_selection_internal, |
| 521 | Sns_store_selection_internal, 2, 2, 0, | 506 | Sns_store_selection_internal, 2, 2, 0, |
| 522 | doc: /* Sets the string value of SELECTION. | 507 | doc: /* Sets the string value of SELECTION. |
| 523 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */) | 508 | SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */) |
| 524 | (Lisp_Object selection, Lisp_Object string) | 509 | (Lisp_Object selection, Lisp_Object string) |
| 525 | { | 510 | { |
| 526 | id pb; | 511 | id pb; |
| @@ -546,11 +531,11 @@ syms_of_nsselect (void) | |||
| 546 | QTEXT = intern_c_string ("TEXT"); staticpro (&QTEXT); | 531 | QTEXT = intern_c_string ("TEXT"); staticpro (&QTEXT); |
| 547 | QFILE_NAME = intern_c_string ("FILE_NAME"); staticpro (&QFILE_NAME); | 532 | QFILE_NAME = intern_c_string ("FILE_NAME"); staticpro (&QFILE_NAME); |
| 548 | 533 | ||
| 549 | defsubr (&Sx_disown_selection_internal); | 534 | defsubr (&Sns_disown_selection_internal); |
| 550 | defsubr (&Sx_get_selection_internal); | 535 | defsubr (&Sx_get_selection_internal); |
| 551 | defsubr (&Sx_own_selection_internal); | 536 | defsubr (&Sns_own_selection_internal); |
| 552 | defsubr (&Sx_selection_exists_p); | 537 | defsubr (&Sx_selection_exists_p); |
| 553 | defsubr (&Sx_selection_owner_p); | 538 | defsubr (&Sns_selection_owner_p); |
| 554 | defsubr (&Sns_get_selection_internal); | 539 | defsubr (&Sns_get_selection_internal); |
| 555 | defsubr (&Sns_store_selection_internal); | 540 | defsubr (&Sns_store_selection_internal); |
| 556 | 541 | ||