aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2014-10-21 11:27:18 -0400
committerStefan Monnier2014-10-21 11:27:18 -0400
commita046b8dd48b0e26f9354e9a005113088c3bc04f9 (patch)
tree608344bb89046a967dcae461b2bde45900c28af5 /src
parente5b3b7d3f387c992e6507bef3885056c5235e9ee (diff)
downloademacs-a046b8dd48b0e26f9354e9a005113088c3bc04f9.tar.gz
emacs-a046b8dd48b0e26f9354e9a005113088c3bc04f9.zip
Get rid of backend-dependent selection-handling functions for kill/yank
and make it generic instead by relying on the lower-level selection management functions. * select.el (select-enable-clipboard): Rename from gui-select-enable-clipboard. (select-enable-primary): Move from x-win.el and rename from x-select-enable-primary. (gui-last-selected-text): Remove. (gui--last-selected-text-clipboard, gui--last-selected-text-primary): New vars. (gui-select-text): Rewrite, based on x-win.el's old x-select-text. (gui-select-text-alist, gui-selection-value-alist): Remove. (x-select-request-type): Move from x-win.el. (gui--selection-value-internal): New function, taken from x-win's x-selection-value-internal. (gui-selection-value): Rewrite, based on x-win.el's old x-selection-value. (gui-set-selection-alist): Rename from gui-own-selection-alist and extend it to handle a nil value as a "disown" request. (gui-disown-selection-alist): Remove. (xselect-convert-to-delete): Adjust accordingly. (gui-set-selection): Simplify accordingly as well. Use dotimes. * lisp/frame.el (gui-method): Use window-system rather than framep. (gui-method-declare): The tty case is now nil rather than t. (make-frame): Adjust accordingly. * lisp/term/x-win.el (x-last-selected-text-primary) (x-select-enable-primary): Remove (moved to select.el). (x-select-request-type): Move to select.el. (x-selection-value-internal, x--selection-value): Remove functions. (gui-selection-value, gui-select-text): Remove moethods. (gui-set-selection): Merge own and disown methods. * lisp/startup.el (command-line): Adjust now that `gui-method' expects nil for ttys. * lisp/term/ns-win.el (ns-get-pasteboard, ns-set-pasteboard) (ns-selection-value): Remove functions. (gui-select-text, gui-selection-value): Don't define method any more. (gui-set-selection): Merge the old own and disown methods. (gui-selection-exists-p, gui-get-selection): Adjust to new name of underlying C primitive. * lisp/term/pc-win.el (w16-get-selection-value): Add dummy argument and drop test of gui-select-enable-clipboard, to make it usable as a gui-get-selection method. (gui-selection-exists-p): Adjust to new name of C primitive. (gui-set-selection): Merge own and disown methods. (gui-select-text, gui-selection-value): Delete methods. (w16--select-text): Delete function. * lisp/term/w32-win.el (w32--select-text, w32--get-selection-value): Delete function (move functionality into w32--set-selection and w32--get-selection). (gui-select-text, gui-selection-value): Don't define methods. (w32--set-selection, w32--get-selection, w32--selection-owner-p): New functions. (gui-get-selection, gui-selection-owner-p, gui-selection-exists-p): Use them. (gui-selection-exists-p): Adjust to new name of C primitive. * src/nsselect.m (ns_get_local_selection): Signal error rather than `quit'. (Fns_own_selection_internal): Tighten scoping. (Fns_selection_exists_p): Rename from Fx_selection_exists_p. (Fns_get_selection): Rename from Fx_get_selection_internal. (Fns_get_selection_internal, Fns_store_selection_internal): Remove functions. (syms_of_nsselect): Adjust accordingly. * src/w16select.c (Fw16_selection_exists_p): Rename from Fx_selection_exists_p. (syms_of_win16select): Adjust accordingly. * src/w32select.c (Fw32_selection_exists_p): Rename from Fx_selection_exists_p. (syms_of_w32select): Adjust accordingly.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog18
-rw-r--r--src/nsselect.m77
-rw-r--r--src/w16select.c6
-rw-r--r--src/w32select.c10
4 files changed, 51 insertions, 60 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c7070c8000b..daa11d7f5c7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,21 @@
12014-10-21 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * w32select.c (Fw32_selection_exists_p): Rename from
4 Fx_selection_exists_p.
5 (syms_of_w32select): Adjust accordingly.
6
7 * w16select.c (Fw16_selection_exists_p): Rename from
8 Fx_selection_exists_p.
9 (syms_of_win16select): Adjust accordingly.
10
11 * nsselect.m (ns_get_local_selection): Signal error rather than `quit'.
12 (Fns_own_selection_internal): Tighten scoping.
13 (Fns_selection_exists_p): Rename from Fx_selection_exists_p.
14 (Fns_get_selection): Rename from Fx_get_selection_internal.
15 (Fns_get_selection_internal, Fns_store_selection_internal):
16 Remove functions.
17 (syms_of_nsselect): Adjust accordingly.
18
12014-10-21 Martin Rudalics <rudalics@gmx.at> 192014-10-21 Martin Rudalics <rudalics@gmx.at>
2 20
3 * w32fns.c (Fw32_frame_menu_bar_size): New function. 21 * w32fns.c (Fw32_frame_menu_bar_size): New function.
diff --git a/src/nsselect.m b/src/nsselect.m
index 3712ba064e7..8a2492127d8 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -26,7 +26,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
26*/ 26*/
27 27
28/* This should be the first include, as it may set up #defines affecting 28/* This should be the first include, as it may set up #defines affecting
29 interpretation of even the system includes. */ 29 interpretation of even the system includes. */
30#include <config.h> 30#include <config.h>
31 31
32#include "lisp.h" 32#include "lisp.h"
@@ -161,8 +161,10 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
161 length: SBYTES (str) 161 length: SBYTES (str)
162 encoding: NSUTF8StringEncoding 162 encoding: NSUTF8StringEncoding
163 freeWhenDone: NO]; 163 freeWhenDone: NO];
164 // FIXME: Why those 2 different code paths?
164 if (gtype == nil) 165 if (gtype == nil)
165 { 166 {
167 // Used for ns-store-selection-internal.
166 [pb declareTypes: ns_send_types owner: nil]; 168 [pb declareTypes: ns_send_types owner: nil];
167 tenum = [ns_send_types objectEnumerator]; 169 tenum = [ns_send_types objectEnumerator];
168 while ( (type = [tenum nextObject]) ) 170 while ( (type = [tenum nextObject]) )
@@ -170,6 +172,8 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
170 } 172 }
171 else 173 else
172 { 174 {
175 // Used for ns-own-selection-internal.
176 eassert (type == NSStringPboardType);
173 [pb setString: nsStr forType: gtype]; 177 [pb setString: nsStr forType: gtype];
174 } 178 }
175 [nsStr release]; 179 [nsStr release];
@@ -183,13 +187,12 @@ ns_get_local_selection (Lisp_Object selection_name,
183{ 187{
184 Lisp_Object local_value; 188 Lisp_Object local_value;
185 Lisp_Object handler_fn, value, check; 189 Lisp_Object handler_fn, value, check;
186 ptrdiff_t count; 190 ptrdiff_t count = specpdl_ptr - specpdl;
187 191
188 local_value = assq_no_quit (selection_name, Vselection_alist); 192 local_value = assq_no_quit (selection_name, Vselection_alist);
189 193
190 if (NILP (local_value)) return Qnil; 194 if (NILP (local_value)) return Qnil;
191 195
192 count = specpdl_ptr - specpdl;
193 specbind (Qinhibit_quit, Qt); 196 specbind (Qinhibit_quit, Qt);
194 CHECK_SYMBOL (target_type); 197 CHECK_SYMBOL (target_type);
195 handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist)); 198 handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist));
@@ -212,19 +215,16 @@ ns_get_local_selection (Lisp_Object selection_name,
212 215
213 if (CONSP (check) 216 if (CONSP (check)
214 && INTEGERP (XCAR (check)) 217 && INTEGERP (XCAR (check))
215 && (INTEGERP (XCDR (check))|| 218 && (INTEGERP (XCDR (check))
216 (CONSP (XCDR (check)) 219 || (CONSP (XCDR (check))
217 && INTEGERP (XCAR (XCDR (check))) 220 && INTEGERP (XCAR (XCDR (check)))
218 && NILP (XCDR (XCDR (check)))))) 221 && NILP (XCDR (XCDR (check))))))
219 return value; 222 return value;
220 223
221 // FIXME: Why `quit' rather than `error'? 224 Fsignal (Qerror,
222 Fsignal (Qquit,
223 list3 (build_string ("invalid data returned by" 225 list3 (build_string ("invalid data returned by"
224 " selection-conversion function"), 226 " selection-conversion function"),
225 handler_fn, value)); 227 handler_fn, value));
226 // FIXME: Beware, `quit' can return!!
227 return Qnil;
228} 228}
229 229
230 230
@@ -338,7 +338,6 @@ anything that the functions on `selection-converter-alist' know about. */)
338 (Lisp_Object selection, Lisp_Object value) 338 (Lisp_Object selection, Lisp_Object value)
339{ 339{
340 id pb; 340 id pb;
341 Lisp_Object old_value, new_value;
342 NSString *type; 341 NSString *type;
343 Lisp_Object successful_p = Qnil, rest; 342 Lisp_Object successful_p = Qnil, rest;
344 Lisp_Object target_symbol, data; 343 Lisp_Object target_symbol, data;
@@ -351,13 +350,15 @@ anything that the functions on `selection-converter-alist' know about. */)
351 if (pb == nil) return Qnil; 350 if (pb == nil) return Qnil;
352 351
353 ns_declare_pasteboard (pb); 352 ns_declare_pasteboard (pb);
354 old_value = assq_no_quit (selection, Vselection_alist); 353 {
355 new_value = list2 (selection, value); 354 Lisp_Object old_value = assq_no_quit (selection, Vselection_alist);
355 Lisp_Object new_value = list2 (selection, value);
356 356
357 if (NILP (old_value)) 357 if (NILP (old_value))
358 Vselection_alist = Fcons (new_value, Vselection_alist); 358 Vselection_alist = Fcons (new_value, Vselection_alist);
359 else 359 else
360 Fsetcdr (old_value, Fcdr (new_value)); 360 Fsetcdr (old_value, Fcdr (new_value));
361 }
361 362
362 /* We only support copy of text. */ 363 /* We only support copy of text. */
363 type = NSStringPboardType; 364 type = NSStringPboardType;
@@ -372,6 +373,7 @@ anything that the functions on `selection-converter-alist' know about. */)
372 373
373 if (!EQ (Vns_sent_selection_hooks, Qunbound)) 374 if (!EQ (Vns_sent_selection_hooks, Qunbound))
374 { 375 {
376 /* FIXME: Use run-hook-with-args! */
375 for (rest = Vns_sent_selection_hooks; CONSP (rest); rest = Fcdr (rest)) 377 for (rest = Vns_sent_selection_hooks; CONSP (rest); rest = Fcdr (rest))
376 call3 (Fcar (rest), selection, target_symbol, successful_p); 378 call3 (Fcar (rest), selection, target_symbol, successful_p);
377 } 379 }
@@ -397,7 +399,7 @@ Disowning it means there is no such selection. */)
397} 399}
398 400
399 401
400DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p, 402DEFUN ("ns-selection-exists-p", Fns_selection_exists_p, Sns_selection_exists_p,
401 0, 2, 0, doc: /* Whether there is an owner for the given X selection. 403 0, 2, 0, doc: /* Whether there is an owner for the given X selection.
402SELECTION should be the name of the selection in question, typically 404SELECTION should be the name of the selection in question, typically
403one of the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. (X expects 405one of the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. (X expects
@@ -452,8 +454,8 @@ On Nextstep, TERMINAL is unused. */)
452} 454}
453 455
454 456
455DEFUN ("x-get-selection-internal", Fx_get_selection_internal, 457DEFUN ("ns-get-selection", Fns_get_selection,
456 Sx_get_selection_internal, 2, 4, 0, 458 Sns_get_selection, 2, 4, 0,
457 doc: /* Return text selected from some X window. 459 doc: /* Return text selected from some X window.
458SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. 460SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
459\(Those are literal upper-case symbol names, since that's what X expects.) 461\(Those are literal upper-case symbol names, since that's what X expects.)
@@ -489,33 +491,6 @@ On Nextstep, TIME-STAMP and TERMINAL are unused. */)
489} 491}
490 492
491 493
492DEFUN ("ns-get-selection-internal", Fns_get_selection_internal,
493 Sns_get_selection_internal, 1, 1, 0,
494 doc: /* Returns the value of SELECTION as a string.
495SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
496 (Lisp_Object selection)
497{
498 id pb;
499 check_window_system (NULL);
500 pb = ns_symbol_to_pb (selection);
501 return pb != nil ? ns_string_from_pasteboard (pb) : Qnil;
502}
503
504
505DEFUN ("ns-store-selection-internal", Fns_store_selection_internal,
506 Sns_store_selection_internal, 2, 2, 0,
507 doc: /* Sets the string value of SELECTION.
508SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
509 (Lisp_Object selection, Lisp_Object string)
510{
511 id pb;
512 check_window_system (NULL);
513 pb = ns_symbol_to_pb (selection);
514 if (pb != nil) ns_string_to_pasteboard (pb, string);
515 return Qnil;
516}
517
518
519void 494void
520nxatoms_of_nsselect (void) 495nxatoms_of_nsselect (void)
521{ 496{
@@ -532,12 +507,10 @@ syms_of_nsselect (void)
532 QFILE_NAME = intern_c_string ("FILE_NAME"); staticpro (&QFILE_NAME); 507 QFILE_NAME = intern_c_string ("FILE_NAME"); staticpro (&QFILE_NAME);
533 508
534 defsubr (&Sns_disown_selection_internal); 509 defsubr (&Sns_disown_selection_internal);
535 defsubr (&Sx_get_selection_internal); 510 defsubr (&Sns_get_selection);
536 defsubr (&Sns_own_selection_internal); 511 defsubr (&Sns_own_selection_internal);
537 defsubr (&Sx_selection_exists_p); 512 defsubr (&Sns_selection_exists_p);
538 defsubr (&Sns_selection_owner_p); 513 defsubr (&Sns_selection_owner_p);
539 defsubr (&Sns_get_selection_internal);
540 defsubr (&Sns_store_selection_internal);
541 514
542 Vselection_alist = Qnil; 515 Vselection_alist = Qnil;
543 staticpro (&Vselection_alist); 516 staticpro (&Vselection_alist);
diff --git a/src/w16select.c b/src/w16select.c
index c229ba5816a..2403a9be1e0 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -625,9 +625,9 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat
625 return (ret); 625 return (ret);
626} 626}
627 627
628/* Support checking for a clipboard selection. */ 628/* Support checking for a clipboard selection. */
629 629
630DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p, 630DEFUN ("w16-selection-exists-p", Fw16_selection_exists_p, Sw16_selection_exists_p,
631 0, 2, 0, 631 0, 2, 0,
632 doc: /* Whether there is an owner for the given X selection. 632 doc: /* Whether there is an owner for the given X selection.
633SELECTION should be the name of the selection in question, typically 633SELECTION should be the name of the selection in question, typically
@@ -677,7 +677,7 @@ syms_of_win16select (void)
677{ 677{
678 defsubr (&Sw16_set_clipboard_data); 678 defsubr (&Sw16_set_clipboard_data);
679 defsubr (&Sw16_get_clipboard_data); 679 defsubr (&Sw16_get_clipboard_data);
680 defsubr (&Sx_selection_exists_p); 680 defsubr (&Sw16_selection_exists_p);
681 681
682 DEFVAR_LISP ("selection-coding-system", Vselection_coding_system, 682 DEFVAR_LISP ("selection-coding-system", Vselection_coding_system,
683 doc: /* Coding system for communicating with other programs. 683 doc: /* Coding system for communicating with other programs.
diff --git a/src/w32select.c b/src/w32select.c
index 9fa84ca5c54..b1419e52ac9 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -1013,9 +1013,9 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
1013 return (ret); 1013 return (ret);
1014} 1014}
1015 1015
1016/* Support checking for a clipboard selection. */ 1016/* Support checking for a clipboard selection. */
1017 1017
1018DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p, 1018DEFUN ("w32-selection-exists-p", Fw32_selection_exists_p, Sw32_selection_exists_p,
1019 0, 2, 0, 1019 0, 2, 0,
1020 doc: /* Whether there is an owner for the given X selection. 1020 doc: /* Whether there is an owner for the given X selection.
1021SELECTION should be the name of the selection in question, typically 1021SELECTION should be the name of the selection in question, typically
@@ -1031,7 +1031,7 @@ frame's display, or the first available X display. */)
1031 CHECK_SYMBOL (selection); 1031 CHECK_SYMBOL (selection);
1032 1032
1033 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check 1033 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check
1034 if the clipboard currently has valid text format contents. */ 1034 if the clipboard currently has valid text format contents. */
1035 1035
1036 if (EQ (selection, QCLIPBOARD)) 1036 if (EQ (selection, QCLIPBOARD))
1037 { 1037 {
@@ -1060,14 +1060,14 @@ frame's display, or the first available X display. */)
1060} 1060}
1061 1061
1062/* One-time init. Called in the un-dumped Emacs, but not in the 1062/* One-time init. Called in the un-dumped Emacs, but not in the
1063 dumped version. */ 1063 dumped version. */
1064 1064
1065void 1065void
1066syms_of_w32select (void) 1066syms_of_w32select (void)
1067{ 1067{
1068 defsubr (&Sw32_set_clipboard_data); 1068 defsubr (&Sw32_set_clipboard_data);
1069 defsubr (&Sw32_get_clipboard_data); 1069 defsubr (&Sw32_get_clipboard_data);
1070 defsubr (&Sx_selection_exists_p); 1070 defsubr (&Sw32_selection_exists_p);
1071 1071
1072 DEFVAR_LISP ("selection-coding-system", Vselection_coding_system, 1072 DEFVAR_LISP ("selection-coding-system", Vselection_coding_system,
1073 doc: /* Coding system for communicating with other programs. 1073 doc: /* Coding system for communicating with other programs.