1 ;;; select.el --- Lisp interface to windows selections.
3 ;; Copyright (C) 1998 Andy Piper.
4 ;; Copyright (C) 1990, 1997 Free Software Foundation, Inc.
5 ;; Copyright (C) 1995 Sun Microsystems.
7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: extensions, dumped
10 ;; This file is part of XEmacs.
12 ;; XEmacs is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; XEmacs is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
27 ;;; Synched up with: Not in FSF
31 ;; This file is dumped with XEmacs
35 (defvar selected-text-type
36 (if (featurep 'mule) '(COMPOUND_TEXT STRING) 'STRING)
37 "The type atom used to obtain selections from the X server.
38 Can be either a valid X selection data type, or a list of such types.
39 COMPOUND_TEXT and STRING are the most commonly used data types.
40 If a list is provided, the types are tried in sequence until
41 there is a successful conversion.")
43 (defvar selection-sets-clipboard nil
44 "Controls the selection's relationship to the clipboard.
45 When non-nil, any operation that sets the primary selection will also
48 (defun copy-primary-selection ()
49 "Copy the selection to the Clipboard and the kill ring."
51 (and (console-on-window-system-p)
52 (cut-copy-clear-internal 'copy)))
54 (defun kill-primary-selection ()
55 "Copy the selection to the Clipboard and the kill ring, then delete it."
57 (and (console-on-window-system-p)
58 (cut-copy-clear-internal 'cut)))
60 (defun delete-primary-selection ()
61 "Delete the selection without copying it to the Clipboard or the kill ring."
63 (and (console-on-window-system-p)
64 (cut-copy-clear-internal 'clear)))
66 (defun yank-clipboard-selection ()
67 "Insert the current Clipboard selection at point."
69 (when (console-on-window-system-p)
70 (setq last-command nil)
71 (setq this-command 'yank) ; so that yank-pop works.
72 (let ((clip (get-clipboard)))
73 (or clip (error "there is no clipboard selection"))
77 (defun get-clipboard ()
78 "Return text pasted to the clipboard.
79 Not suitable for `interprogram-paste-function', use `get-clipboard-foreign'."
80 (get-selection 'CLIPBOARD))
82 (defun get-clipboard-foreign ()
83 "Return text pasted to the clipboard by another program.
84 See `interprogram-paste-function' for more information."
85 (get-selection-foreign 'CLIPBOARD))
87 (define-device-method get-cutbuffer
88 "Return the value of one of the cut buffers.
89 This will do nothing under anything other than X.")
91 (defun get-selection-no-error (&optional type data-type)
92 "Return the value of a window-system selection.
93 The argument TYPE (default `PRIMARY') says which selection,
94 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
95 says how to convert the data. Returns NIL if there is no selection."
96 (condition-case nil (get-selection type data-type) (t nil)))
98 (defun get-selection (&optional type data-type)
99 "Return the value of a window-system selection.
100 The argument TYPE (default `PRIMARY') says which selection,
101 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
102 says how to convert the data. If there is no selection an error is signalled.
103 Not suitable in a `interprogram-paste-function', q.v."
104 (or type (setq type 'PRIMARY))
105 (or data-type (setq data-type selected-text-type))
106 (if (consp data-type)
108 (get-selection-internal type (car data-type))
109 (selection-conversion-error
111 (get-selection type (cdr data-type))
112 (signal (car err) (cdr err)))))
113 (get-selection-internal type data-type)))
115 (defun get-selection-foreign (&optional type data-type)
116 "Return the value of a window-system selection, or nil if XEmacs owns it.
117 The argument TYPE (default `PRIMARY') says which selection,
118 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
119 says how to convert the data. If there is no selection an error is signalled.
120 See `interprogram-paste-function' for more information."
121 (unless (selection-owner-p type)
122 (get-selection type data-type)))
124 ;; FSFmacs calls this `x-set-selection', and reverses the
125 ;; first two arguments (duh ...). This order is more logical.
126 (defun own-selection (data &optional type how-to-add data-type)
127 "Make a window-system selection of type TYPE and value DATA.
128 The argument TYPE (default `PRIMARY') says which selection,
129 and DATA specifies the contents. DATA may be any lisp data type
130 that can be converted using the function corresponding to DATA-TYPE
131 in `select-converter-alist'---strings are the usual choice, but
132 other types may be permissible depending on the DATA-TYPE parameter
133 (if DATA-TYPE is not supplied, the default behavior is window
134 system specific, but strings are always accepted).
135 HOW-TO-ADD may be any of the following:
137 'replace-all or nil -- replace all data in the selection.
138 'replace-existing -- replace data for specified DATA-TYPE only.
139 'append or t -- append data to existing DATA-TYPE data.
141 DATA-TYPE is the window-system specific data type identifier
142 (see `register-selection-data-type' for more information).
144 The selection may also be a cons of two markers pointing to the same buffer,
145 or an overlay. In these cases, the selection is considered to be the text
146 between the markers *at whatever time the selection is examined* (note
147 that the window system clipboard does not necessarily duplicate this
148 behavior - it doesn't on mswindows for example).
149 Thus, editing done in the buffer after you specify the selection
150 can alter the effective value of the selection.
152 The data may also be a vector of valid non-vector selection values.
154 Interactively, the text of the region is used as the selection value."
155 (interactive (if (not current-prefix-arg)
156 (list (read-string "Store text for pasting: "))
157 (list (substring (region-beginning) (region-end)))))
158 ;; calling own-selection-internal will mess this up, so preserve it.
159 (let ((zmacs-region-stays zmacs-region-stays))
160 ;FSFmacs huh?? It says:
161 ;; "This is for temporary compatibility with pre-release Emacs 19."
163 ; (setq type (intern type)))
164 (or type (setq type 'PRIMARY))
166 (disown-selection-internal type)
167 (own-selection-internal type data how-to-add data-type)
168 (when (and (eq type 'PRIMARY)
169 selection-sets-clipboard)
170 (own-selection-internal 'CLIPBOARD data how-to-add data-type)))
171 (cond ((eq type 'PRIMARY)
172 (setq primary-selection-extent
173 (select-make-extent-for-selection
174 data primary-selection-extent)))
175 ((eq type 'SECONDARY)
176 (setq secondary-selection-extent
177 (select-make-extent-for-selection
178 data secondary-selection-extent)))))
179 ;; zmacs-region-stays is for commands, not low-level functions.
180 ;; when behaving as the latter, we better not set it, or we will
181 ;; cause unwanted sticky-region behavior in kill-region and friends.
183 (setq zmacs-region-stays t))
186 (defun dehilight-selection (selection)
187 "for use as a value of `lost-selection-hooks'."
188 (cond ((eq selection 'PRIMARY)
189 (if primary-selection-extent
190 (let ((inhibit-quit t))
191 (if (consp primary-selection-extent)
192 (mapcar 'delete-extent primary-selection-extent)
193 (delete-extent primary-selection-extent))
194 (setq primary-selection-extent nil)))
195 (if zmacs-regions (zmacs-deactivate-region)))
196 ((eq selection 'SECONDARY)
197 (if secondary-selection-extent
198 (let ((inhibit-quit t))
199 (if (consp secondary-selection-extent)
200 (mapcar 'delete-extent secondary-selection-extent)
201 (delete-extent secondary-selection-extent))
202 (setq secondary-selection-extent nil)))))
205 (setq lost-selection-hooks 'dehilight-selection)
207 (defun own-clipboard (string &optional push)
208 "Paste the given string to the window system Clipboard.
209 See `interprogram-cut-function' for more information."
210 (own-selection string 'CLIPBOARD))
212 (defun disown-selection (&optional secondary-p)
213 "Assuming we own the selection, disown it. With an argument, discard the
214 secondary selection instead of the primary selection."
215 (disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY))
216 (when (and selection-sets-clipboard
217 (or (not secondary-p)
218 (eq secondary-p 'PRIMARY)
219 (eq secondary-p 'CLIPBOARD)))
220 (disown-selection-internal 'CLIPBOARD)))
223 ;; selections and active regions
225 ;; If and only if zmacs-regions is true:
227 ;; When a mark is pushed and the region goes into the "active" state, we
228 ;; assert it as the Primary selection. This causes it to be hilighted.
229 ;; When the region goes into the "inactive" state, we disown the Primary
230 ;; selection, causing the region to be dehilighted.
232 ;; Note that it is possible for the region to be in the "active" state
233 ;; and not be hilighted, if it is in the active state and then some other
234 ;; application asserts the selection. This is probably not a big deal.
236 (defun activate-region-as-selection ()
237 (if (marker-buffer (mark-marker t))
238 (own-selection (cons (point-marker t) (mark-marker t)))))
240 ; moved from x-select.el
241 (defvar primary-selection-extent nil
242 "The extent of the primary selection; don't use this.")
244 (defvar secondary-selection-extent nil
245 "The extent of the secondary selection; don't use this.")
247 (defun select-make-extent-for-selection (selection previous-extent)
248 ;; Given a selection, this makes an extent in the buffer which holds that
249 ;; selection, for highlighting purposes. If the selection isn't associated
250 ;; with a buffer, this does nothing.
252 (valid (and (extentp previous-extent)
253 (extent-object previous-extent)
254 (buffer-live-p (extent-object previous-extent))))
256 (cond ((stringp selection)
257 ;; if we're selecting a string, lose the previous extent used
258 ;; to highlight the selection.
261 (setq start (min (car selection) (cdr selection))
262 end (max (car selection) (cdr selection))
264 (eq (marker-buffer (car selection))
265 (extent-object previous-extent)))
266 buffer (marker-buffer (car selection))))
268 (setq start (extent-start-position selection)
269 end (extent-end-position selection)
271 (eq (extent-object selection)
272 (extent-object previous-extent)))
273 buffer (extent-object selection)))
275 (signal 'error (list "invalid selection" selection))))
280 (if (listp previous-extent)
281 (mapcar 'delete-extent previous-extent)
282 (delete-extent previous-extent))
290 (set-extent-endpoints previous-extent start end)
291 (setq previous-extent (make-extent start end buffer))
293 ;; Make the extent be closed on the right, which means that if
294 ;; characters are inserted exactly at the end of the extent, the
295 ;; extent will grow to cover them. This is important for shell
296 ;; buffers - suppose one makes a selection, and one end is at
297 ;; point-max. If the shell produces output, that marker will remain
298 ;; at point-max (its position will increase). So it's important that
299 ;; the extent exhibit the same behavior, lest the region covered by
300 ;; the extent (the visual indication), and the region between point
301 ;; and mark (the actual selection value) become different!
302 (set-extent-property previous-extent 'end-open nil)
305 (mouse-track-rectangle-p
306 (setq previous-extent (list previous-extent))
307 (default-mouse-track-next-move-rect start end previous-extent)
311 ;; moved from x-select.el
312 (defun valid-simple-selection-p (data)
313 "An obsolete function that tests whether something was a valid simple
314 selection using the old XEmacs selection support. You shouldn't use this
315 any more, because just about anything could be a valid selection now."
317 ;FSFmacs huh?? (symbolp data)
320 (integerp (car data))
321 (or (integerp (cdr data))
322 (and (consp (cdr data))
323 (integerp (car (cdr data))))))
328 (marker-buffer (car data))
329 (marker-buffer (cdr data))
330 (eq (marker-buffer (car data))
331 (marker-buffer (cdr data)))
332 (buffer-live-p (marker-buffer (car data)))
333 (buffer-live-p (marker-buffer (cdr data))))))
335 (defun cut-copy-clear-internal (mode)
336 (or (memq mode '(cut copy clear)) (error "unkown mode %S" mode))
337 (or (selection-owner-p)
338 (error "XEmacs does not own the primary selection"))
339 (setq last-command nil)
340 (or primary-selection-extent
341 (error "the primary selection is not an extent?"))
345 ((consp primary-selection-extent)
347 b (extent-object (car primary-selection-extent))
348 s (extent-start-position (car primary-selection-extent))
349 e (extent-end-position (car (reverse primary-selection-extent)))))
352 b (extent-object primary-selection-extent)
353 s (extent-start-position primary-selection-extent)
354 e (extent-end-position primary-selection-extent))))
356 (cond ((memq mode '(cut copy))
359 ;; why is killed-rectangle free? Is it used somewhere?
360 ;; should it be defvarred?
361 (setq killed-rectangle (extract-rectangle s e))
362 (kill-new (mapconcat #'identity killed-rectangle "\n")))
363 (copy-region-as-kill s e))
364 ;; Maybe killing doesn't own clipboard. Make sure it happens.
365 ;; This memq is kind of grody, because they might have done it
366 ;; some other way, but owning the clipboard twice in that case
367 ;; wouldn't actually hurt anything.
368 (or (and (consp kill-hooks) (memq 'own-clipboard kill-hooks))
369 (own-clipboard (car kill-ring)))))
370 (cond ((memq mode '(cut clear))
372 (delete-rectangle s e)
373 (delete-region s e))))
374 (disown-selection nil)
378 ;;; Functions to convert the selection into various other selection
381 ;; These next three functions get called by C code...
382 (defun select-convert-in (selection type value)
383 "Attempt to convert the specified external VALUE to the specified DATA-TYPE,
384 for the specified SELECTION. Return nil if this is impossible, or a
385 suitable internal representation otherwise."
387 (let ((handler-fn (cdr (assq type selection-converter-in-alist))))
389 (apply handler-fn (list selection type value))))))
391 (defun select-convert-out (selection type value)
392 "Attempt to convert the specified internal VALUE for the specified DATA-TYPE
393 and SELECTION. Return nil if this is impossible, or a suitable external
394 representation otherwise."
396 (let ((handler-fn (cdr (assq type selection-converter-out-alist))))
398 (apply handler-fn (list selection type value))))))
400 (defun select-coerce (selection type value)
401 "Attempt to convert the specified internal VALUE to a representation
402 suitable for return from `get-selection' in the specified DATA-TYPE. Return
403 nil if this is impossible, or a suitable representation otherwise."
405 (let ((handler-fn (cdr (assq type selection-coercion-alist))))
407 (apply handler-fn (list selection type value))))))
409 ;; The rest of the functions on this "page" are conversion handlers,
410 ;; append handlers and buffer-kill handlers.
411 (defun select-convert-to-text (selection type value)
412 (cond ((stringp value)
416 (set-buffer (extent-object value))
419 (buffer-substring (extent-start-position value)
420 (extent-end-position value)))))
422 (markerp (car value))
423 (markerp (cdr value)))
424 (or (eq (marker-buffer (car value)) (marker-buffer (cdr value)))
426 (list "markers must be in the same buffer"
427 (car value) (cdr value))))
429 (set-buffer (or (marker-buffer (car value))
430 (error "selection is in a killed buffer")))
433 (buffer-substring (car value) (cdr value)))))
436 (defun select-coerce-to-text (selection type value)
437 (select-convert-to-text selection type value))
439 (defun select-convert-from-text (selection type value)
440 (when (stringp value)
443 (defun select-convert-to-string (selection type value)
444 (let ((outval (select-convert-to-text selection type value)))
445 ;; force the string to be not in Compound Text format. This grubby
446 ;; hack will go soon, to be replaced by a more general mechanism.
448 (cons 'STRING outval)
451 (defun select-convert-to-compound-text (selection type value)
452 ;; converts to compound text automatically
453 (select-convert-to-text selection type value))
455 (defun select-convert-to-length (selection type value)
457 (cond ((stringp value)
460 (extent-length value))
462 (markerp (car value))
463 (markerp (cdr value)))
464 (or (eq (marker-buffer (car value))
465 (marker-buffer (cdr value)))
467 (list "markers must be in the same buffer"
468 (car value) (cdr value))))
469 (abs (- (car value) (cdr value)))))))
470 (if value ; force it to be in 32-bit format.
471 (cons (ash value -16) (logand value 65535))
474 (defun select-convert-from-length (selection type value)
475 (select-convert-to-length selection type value))
477 (defun select-convert-to-targets (selection type value)
478 ;; return a vector of atoms, but remove duplicates first.
479 (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
482 (cond ((memq (car rest) (cdr rest))
483 (setcdr rest (delq (car rest) (cdr rest))))
485 (setq rest (cdr rest)))))
486 (apply 'vector all)))
488 (defun select-convert-to-delete (selection type value)
489 (disown-selection-internal selection)
490 ;; A return value of nil means that we do not know how to do this conversion,
491 ;; and replies with an "error". A return value of NULL means that we have
492 ;; done the conversion (and any side-effects) but have no value to return.
495 (defun select-convert-to-filename (selection type value)
496 (cond ((extentp value)
497 (buffer-file-name (or (extent-object value)
498 (error "selection is in a killed buffer"))))
500 (markerp (car value))
501 (markerp (cdr value)))
502 (buffer-file-name (or (marker-buffer (car value))
503 (error "selection is in a killed buffer"))))
506 (defun select-convert-from-filename (selection type value)
507 (when (stringp value)
510 (defun select-convert-to-charpos (selection type value)
512 (cond ((cond ((extentp value)
513 (setq a (extent-start-position value)
514 b (extent-end-position value)))
516 (markerp (car value))
517 (markerp (cdr value)))
520 (setq a (1- a) b (1- b)) ; zero-based
521 (if (< b a) (setq tmp a a b b tmp))
523 (vector (cons (ash a -16) (logand a 65535))
524 (cons (ash b -16) (logand b 65535))))))))
526 (defun select-convert-to-lineno (selection type value)
528 (cond ((cond ((extentp value)
529 (setq buf (extent-object value)
530 a (extent-start-position value)
531 b (extent-end-position value)))
533 (markerp (car value))
534 (markerp (cdr value)))
535 (setq a (marker-position (car value))
536 b (marker-position (cdr value))
537 buf (marker-buffer (car value)))))
544 (setq a (1+ (count-lines 1 (point))))
547 (setq b (1+ (count-lines 1 (point))))))
548 (if (< b a) (setq tmp a a b b tmp))
550 (vector (cons (ash a -16) (logand a 65535))
551 (cons (ash b -16) (logand b 65535))))))))
553 (defun select-convert-to-colno (selection type value)
555 (cond ((cond ((extentp value)
556 (setq buf (extent-object value)
557 a (extent-start-position value)
558 b (extent-end-position value)))
560 (markerp (car value))
561 (markerp (cdr value)))
564 buf (marker-buffer a))))
568 (setq a (current-column))
570 (setq b (current-column)))
571 (if (< b a) (setq tmp a a b b tmp))
573 (vector (cons (ash a -16) (logand a 65535))
574 (cons (ash b -16) (logand b 65535))))))))
576 (defun select-convert-to-sourceloc (selection type value)
577 (let (a b buf file-name tmp)
578 (cond ((cond ((extentp value)
579 (setq buf (or (extent-object value)
580 (error "selection is in a killed buffer"))
581 a (extent-start-position value)
582 b (extent-end-position value)
583 file-name (buffer-file-name buf)))
585 (markerp (car value))
586 (markerp (cdr value)))
587 (setq a (marker-position (car value))
588 b (marker-position (cdr value))
589 buf (or (marker-buffer (car value))
590 (error "selection is in a killed buffer"))
591 file-name (buffer-file-name buf))))
598 (setq a (1+ (count-lines 1 (point))))
601 (setq b (1+ (count-lines 1 (point))))))
602 (if (< b a) (setq tmp a a b b tmp))
603 (format "%s:%d" file-name a)))))
605 (defun select-convert-to-os (selection type size)
606 (symbol-name system-type))
608 (defun select-convert-to-host (selection type size)
611 (defun select-convert-to-user (selection type size)
614 (defun select-convert-to-class (selection type size)
615 (symbol-value 'x-emacs-application-class))
617 ;; We do not try to determine the name Emacs was invoked with,
618 ;; because it is not clean for a program's behavior to depend on that.
619 (defun select-convert-to-name (selection type size)
623 (defun select-convert-to-integer (selection type value)
624 (and (integerp value)
625 (cons (ash value -16) (logand value 65535))))
627 ;; Can convert from the following integer representations
630 ;; (integer . integer)
632 ;; (list [integer|(integer . integer)]*)
633 ;; (vector [integer|(integer . integer)]*)
635 ;; Cons'd integers get cleaned up a little.
637 (defun select-convert-from-integer (selection type value)
638 (cond ((integerp value) ; Integer
641 ((and (consp value) ; (integer . integer)
642 (integerp (car value))
643 (integerp (cdr value)))
644 (if (eq (car value) 0)
646 (if (and (eq (car value) -1)
651 ((and (listp value) ; (integer integer)
652 (eq (length value) 2)
653 (integerp (car value))
654 (integerp (cadr value)))
655 (if (eq (car value) 0)
657 (if (and (eq (car value) -1)
660 (cons (car value) (cadr value)))))
662 ((listp value) ; list
665 (select-convert-from-integer selection type x))
667 (select-convert-from-integer selection type (car value))))
669 ((vectorp value) ; vector
670 (if (eq (length value) 1)
671 (select-convert-from-integer selection type (aref value 0))
672 (mapvector '(lambda (x)
673 (select-convert-from-integer selection type x))
679 (defun select-convert-to-atom (selection type value)
680 (and (symbolp value) value))
682 ;;; CF_xxx conversions
683 (defun select-convert-from-cf-text (selection type value)
684 (replace-in-string (if (string-match "\0" value)
685 (substring value 0 (match-beginning 0))
687 "\\(\r\n\\|\n\r\\)" "\n" t))
689 (defun select-convert-to-cf-text (selection type value)
690 (let ((text (select-convert-to-text selection type value)))
691 (concat (replace-in-string text "\n" "\r\n" t) "\0")))
694 (defun select-append-to-text (selection type value1 value2)
695 (let ((text1 (select-convert-to-text selection 'STRING value1))
696 (text2 (select-convert-to-text selection 'STRING value2)))
697 (if (and text1 text2)
701 (defun select-append-to-string (selection type value1 value2)
702 (select-append-to-text selection type value1 value2))
704 (defun select-append-to-compound-text (selection type value1 value2)
705 (select-append-to-text selection type value1 value2))
707 (defun select-append-to-cf-text (selection type value1 value2)
708 (let ((text1 (select-convert-from-cf-text selection 'CF_TEXT value1))
709 (text2 (select-convert-from-cf-text selection 'CF_TEXT value2)))
710 (if (and text1 text2)
711 (select-convert-to-cf-text selection type (concat text1 text2))
714 (defun select-append-default (selection type value1 value2)
715 ;; This appender gets used if the type is "nil" - i.e. default.
716 ;; It should probably have more cases implemented than it does - e.g.
717 ;; appending numbers to strings, etc...
718 (cond ((and (stringp value1) (stringp value2))
719 (select-append-to-string selection 'STRING value1 value2))
722 ;;; Buffer kill handlers
724 (defun select-buffer-killed-default (selection type value buffer)
725 ;; This handler gets used if the type is "nil".
726 (cond ((extentp value)
727 (if (eq (extent-object value) buffer)
728 ; If this selection is on the clipboard, grab it quick
729 (when (eq selection 'CLIPBOARD)
731 (set-buffer (extent-object value))
734 (buffer-substring (extent-start-position value)
735 (extent-end-position value)))))
738 (unless (eq (marker-buffer value) buffer)
741 (markerp (car value))
742 (markerp (cdr value)))
743 (if (or (eq (marker-buffer (car value)) buffer)
744 (eq (marker-buffer (cdr value)) buffer))
745 ; If this selection is on the clipboard, grab it quick
746 (when (eq selection 'CLIPBOARD)
748 (set-buffer (marker-buffer (car value)))
751 (buffer-substring (car value) (cdr value)))))
755 (defun select-buffer-killed-text (selection type value buffer)
756 (select-buffer-killed-default selection type value buffer))
758 ;; Types listed in here can be selections of XEmacs
759 (setq selection-converter-out-alist
760 '((TEXT . select-convert-to-text)
761 (STRING . select-convert-to-string)
762 (COMPOUND_TEXT . select-convert-to-compound-text)
763 (TARGETS . select-convert-to-targets)
764 (LENGTH . select-convert-to-length)
765 (DELETE . select-convert-to-delete)
766 (FILE_NAME . select-convert-to-filename)
767 (CHARACTER_POSITION . select-convert-to-charpos)
768 (SOURCE_LOC . select-convert-to-sourceloc)
769 (LINE_NUMBER . select-convert-to-lineno)
770 (COLUMN_NUMBER . select-convert-to-colno)
771 (OWNER_OS . select-convert-to-os)
772 (HOST_NAME . select-convert-to-host)
773 (USER . select-convert-to-user)
774 (CLASS . select-convert-to-class)
775 (NAME . select-convert-to-name)
776 (ATOM . select-convert-to-atom)
777 (INTEGER . select-convert-to-integer)
778 (CF_TEXT . select-convert-to-cf-text)
781 ;; Types listed here can be selections foreign to XEmacs
782 (setq selection-converter-in-alist
783 '(; Specific types that get handled by generic converters
784 (COMPOUND_TEXT . select-convert-from-text)
785 (SOURCE_LOC . select-convert-from-text)
786 (OWNER_OS . select-convert-from-text)
787 (HOST_NAME . select-convert-from-text)
788 (USER . select-convert-from-text)
789 (CLASS . select-convert-from-text)
790 (NAME . select-convert-from-text)
792 (INTEGER . select-convert-from-integer)
793 (TEXT . select-convert-from-text)
794 (STRING . select-convert-from-text)
795 (LENGTH . select-convert-from-length)
796 (FILE_NAME . select-convert-from-filename)
797 (CF_TEXT . select-convert-from-cf-text)
800 ;; Types listed here have special coercion functions that can munge
801 ;; other types. This can also be used to add special features - e.g.
802 ;; being able to pass a region or a cons of markers to own-selection,
803 ;; but getting the *current* text in the region back when calling
806 ;; Any function listed in here *will be called* whenever a value of
807 ;; its type is retrieved from the internal selection cache, or when
808 ;; no suitable values could be found in which case XEmacs looks for
809 ;; values with types listed in selection-coercible-types.
810 (setq selection-coercion-alist
811 '((TEXT . select-coerce-to-text)
812 (STRING . select-coerce-to-text)
813 (COMPOUND_TEXT . select-coerce-to-text)
814 (CF_TEXT . select-coerce-to-text)))
816 ;; Types listed here can be appended by own-selection
817 (setq selection-appender-alist
818 '((nil . select-append-default)
819 (TEXT . select-append-to-text)
820 (STRING . select-append-to-string)
821 (COMPOUND_TEXT . select-append-to-compound-text)
822 (CF_TEXT . select-append-to-cf-text)
825 ;; Types listed here have buffer-kill handlers
826 (setq selection-buffer-killed-alist
827 '((nil . select-buffer-killed-default)
828 (TEXT . select-buffer-killed-text)
829 (STRING . select-buffer-killed-text)
830 (COMPOUND_TEXT . select-buffer-killed-text)
831 (CF_TEXT . select-buffer-killed-text)))
833 ;; Lists of types that are coercible (can be converted to other types)
834 (setq selection-coercible-types '(TEXT STRING COMPOUND_TEXT))
836 ;;; select.el ends here