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 (get-selection 'CLIPBOARD))
81 (define-device-method get-cutbuffer
82 "Return the value of one of the cut buffers.
83 This will do nothing under anything other than X.")
85 (defun get-selection-no-error (&optional type data-type)
86 "Return the value of a window-system selection.
87 The argument TYPE (default `PRIMARY') says which selection,
88 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
89 says how to convert the data. Returns NIL if there is no selection."
90 (condition-case nil (get-selection type data-type) (t nil)))
92 (defun get-selection (&optional type data-type)
93 "Return the value of a window-system selection.
94 The argument TYPE (default `PRIMARY') says which selection,
95 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
96 says how to convert the data. If there is no selection an error is signalled."
97 (or type (setq type 'PRIMARY))
98 (or data-type (setq data-type selected-text-type))
100 (if (consp data-type)
102 (get-selection-internal type (car data-type))
103 (selection-conversion-error
105 (get-selection type (cdr data-type))
106 (signal (car err) (cdr err)))))
107 (get-selection-internal type data-type))))
110 ;; FSFmacs calls this `x-set-selection', and reverses the
111 ;; first two arguments (duh ...). This order is more logical.
112 (defun own-selection (data &optional type how-to-add data-type)
113 "Make a window-system selection of type TYPE and value DATA.
114 The argument TYPE (default `PRIMARY') says which selection,
115 and DATA specifies the contents. DATA may be any lisp data type
116 that can be converted using the function corresponding to DATA-TYPE
117 in `select-converter-alist'---strings are the usual choice, but
118 other types may be permissible depending on the DATA-TYPE parameter
119 (if DATA-TYPE is not supplied, the default behavior is window
120 system specific, but strings are always accepted).
121 HOW-TO-ADD may be any of the following:
123 'replace-all or nil -- replace all data in the selection.
124 'replace-existing -- replace data for specified DATA-TYPE only.
125 'append or t -- append data to existing DATA-TYPE data.
127 DATA-TYPE is the window-system specific data type identifier
128 (see `register-selection-data-type' for more information).
130 The selection may also be a cons of two markers pointing to the same buffer,
131 or an overlay. In these cases, the selection is considered to be the text
132 between the markers *at whatever time the selection is examined* (note
133 that the window system clipboard does not necessarily duplicate this
134 behavior - it doesn't on mswindows for example).
135 Thus, editing done in the buffer after you specify the selection
136 can alter the effective value of the selection.
138 The data may also be a vector of valid non-vector selection values.
140 Interactively, the text of the region is used as the selection value."
141 (interactive (if (not current-prefix-arg)
142 (list (read-string "Store text for pasting: "))
143 (list (substring (region-beginning) (region-end)))))
144 ;; calling own-selection-internal will mess this up, so preserve it.
145 (let ((zmacs-region-stays zmacs-region-stays))
146 ;FSFmacs huh?? It says:
147 ;; "This is for temporary compatibility with pre-release Emacs 19."
149 ; (setq type (intern type)))
150 (or type (setq type 'PRIMARY))
152 (disown-selection-internal type)
153 (own-selection-internal type data how-to-add data-type)
154 (when (and (eq type 'PRIMARY)
155 selection-sets-clipboard)
156 (own-selection-internal 'CLIPBOARD data how-to-add data-type)))
157 (cond ((eq type 'PRIMARY)
158 (setq primary-selection-extent
159 (select-make-extent-for-selection
160 data primary-selection-extent)))
161 ((eq type 'SECONDARY)
162 (setq secondary-selection-extent
163 (select-make-extent-for-selection
164 data secondary-selection-extent)))))
165 ;; zmacs-region-stays is for commands, not low-level functions.
166 ;; when behaving as the latter, we better not set it, or we will
167 ;; cause unwanted sticky-region behavior in kill-region and friends.
169 (setq zmacs-region-stays t))
172 (defun dehilight-selection (selection)
173 "for use as a value of `lost-selection-hooks'."
174 (cond ((eq selection 'PRIMARY)
175 (if primary-selection-extent
176 (let ((inhibit-quit t))
177 (if (consp primary-selection-extent)
178 (mapcar 'delete-extent primary-selection-extent)
179 (delete-extent primary-selection-extent))
180 (setq primary-selection-extent nil)))
181 (if zmacs-regions (zmacs-deactivate-region)))
182 ((eq selection 'SECONDARY)
183 (if secondary-selection-extent
184 (let ((inhibit-quit t))
185 (if (consp secondary-selection-extent)
186 (mapcar 'delete-extent secondary-selection-extent)
187 (delete-extent secondary-selection-extent))
188 (setq secondary-selection-extent nil)))))
191 (setq lost-selection-hooks 'dehilight-selection)
193 (defun own-clipboard (string &optional push)
194 "Paste the given string to the window system Clipboard.
195 See `interprogram-cut-function' for more information."
196 (own-selection string 'CLIPBOARD))
198 (defun disown-selection (&optional secondary-p)
199 "Assuming we own the selection, disown it. With an argument, discard the
200 secondary selection instead of the primary selection."
201 (disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY))
202 (when (and selection-sets-clipboard
203 (or (not secondary-p)
204 (eq secondary-p 'PRIMARY)
205 (eq secondary-p 'CLIPBOARD)))
206 (disown-selection-internal 'CLIPBOARD)))
209 ;; selections and active regions
211 ;; If and only if zmacs-regions is true:
213 ;; When a mark is pushed and the region goes into the "active" state, we
214 ;; assert it as the Primary selection. This causes it to be hilighted.
215 ;; When the region goes into the "inactive" state, we disown the Primary
216 ;; selection, causing the region to be dehilighted.
218 ;; Note that it is possible for the region to be in the "active" state
219 ;; and not be hilighted, if it is in the active state and then some other
220 ;; application asserts the selection. This is probably not a big deal.
222 (defun activate-region-as-selection ()
223 (if (marker-buffer (mark-marker t))
224 (own-selection (cons (point-marker t) (mark-marker t)))))
226 ; moved from x-select.el
227 (defvar primary-selection-extent nil
228 "The extent of the primary selection; don't use this.")
230 (defvar secondary-selection-extent nil
231 "The extent of the secondary selection; don't use this.")
233 (defun select-make-extent-for-selection (selection previous-extent)
234 ;; Given a selection, this makes an extent in the buffer which holds that
235 ;; selection, for highlighting purposes. If the selection isn't associated
236 ;; with a buffer, this does nothing.
238 (valid (and (extentp previous-extent)
239 (extent-object previous-extent)
240 (buffer-live-p (extent-object previous-extent))))
242 (cond ((stringp selection)
243 ;; if we're selecting a string, lose the previous extent used
244 ;; to highlight the selection.
247 (setq start (min (car selection) (cdr selection))
248 end (max (car selection) (cdr selection))
250 (eq (marker-buffer (car selection))
251 (extent-object previous-extent)))
252 buffer (marker-buffer (car selection))))
254 (setq start (extent-start-position selection)
255 end (extent-end-position selection)
257 (eq (extent-object selection)
258 (extent-object previous-extent)))
259 buffer (extent-object selection)))
261 (signal 'error (list "invalid selection" selection))))
266 (if (listp previous-extent)
267 (mapcar 'delete-extent previous-extent)
268 (delete-extent previous-extent))
276 (set-extent-endpoints previous-extent start end)
277 (setq previous-extent (make-extent start end buffer))
279 ;; Make the extent be closed on the right, which means that if
280 ;; characters are inserted exactly at the end of the extent, the
281 ;; extent will grow to cover them. This is important for shell
282 ;; buffers - suppose one makes a selection, and one end is at
283 ;; point-max. If the shell produces output, that marker will remain
284 ;; at point-max (its position will increase). So it's important that
285 ;; the extent exhibit the same behavior, lest the region covered by
286 ;; the extent (the visual indication), and the region between point
287 ;; and mark (the actual selection value) become different!
288 (set-extent-property previous-extent 'end-open nil)
291 (mouse-track-rectangle-p
292 (setq previous-extent (list previous-extent))
293 (default-mouse-track-next-move-rect start end previous-extent)
297 ;; moved from x-select.el
298 (defun valid-simple-selection-p (data)
299 "An obsolete function that tests whether something was a valid simple
300 selection using the old XEmacs selection support. You shouldn't use this
301 any more, because just about anything could be a valid selection now."
303 ;FSFmacs huh?? (symbolp data)
306 (integerp (car data))
307 (or (integerp (cdr data))
308 (and (consp (cdr data))
309 (integerp (car (cdr data))))))
314 (marker-buffer (car data))
315 (marker-buffer (cdr data))
316 (eq (marker-buffer (car data))
317 (marker-buffer (cdr data)))
318 (buffer-live-p (marker-buffer (car data)))
319 (buffer-live-p (marker-buffer (cdr data))))))
321 (defun cut-copy-clear-internal (mode)
322 (or (memq mode '(cut copy clear)) (error "unkown mode %S" mode))
323 (or (selection-owner-p)
324 (error "XEmacs does not own the primary selection"))
325 (setq last-command nil)
326 (or primary-selection-extent
327 (error "the primary selection is not an extent?"))
331 ((consp primary-selection-extent)
333 b (extent-object (car primary-selection-extent))
334 s (extent-start-position (car primary-selection-extent))
335 e (extent-end-position (car (reverse primary-selection-extent)))))
338 b (extent-object primary-selection-extent)
339 s (extent-start-position primary-selection-extent)
340 e (extent-end-position primary-selection-extent))))
342 (cond ((memq mode '(cut copy))
345 ;; why is killed-rectangle free? Is it used somewhere?
346 ;; should it be defvarred?
347 (setq killed-rectangle (extract-rectangle s e))
348 (kill-new (mapconcat #'identity killed-rectangle "\n")))
349 (copy-region-as-kill s e))
350 ;; Maybe killing doesn't own clipboard. Make sure it happens.
351 ;; This memq is kind of grody, because they might have done it
352 ;; some other way, but owning the clipboard twice in that case
353 ;; wouldn't actually hurt anything.
354 (or (and (consp kill-hooks) (memq 'own-clipboard kill-hooks))
355 (own-clipboard (car kill-ring)))))
356 (cond ((memq mode '(cut clear))
358 (delete-rectangle s e)
359 (delete-region s e))))
360 (disown-selection nil)
364 ;;; Functions to convert the selection into various other selection
367 ;; These next three functions get called by C code...
368 (defun select-convert-in (selection type value)
369 "Attempt to convert the specified external VALUE to the specified DATA-TYPE,
370 for the specified SELECTION. Return nil if this is impossible, or a
371 suitable internal representation otherwise."
373 (let ((handler-fn (cdr (assq type selection-converter-in-alist))))
375 (apply handler-fn (list selection type value))))))
377 (defun select-convert-out (selection type value)
378 "Attempt to convert the specified internal VALUE for the specified DATA-TYPE
379 and SELECTION. Return nil if this is impossible, or a suitable external
380 representation otherwise."
382 (let ((handler-fn (cdr (assq type selection-converter-out-alist))))
384 (apply handler-fn (list selection type value))))))
386 (defun select-coerce (selection type value)
387 "Attempt to convert the specified internal VALUE to a representation
388 suitable for return from `get-selection' in the specified DATA-TYPE. Return
389 nil if this is impossible, or a suitable representation otherwise."
391 (let ((handler-fn (cdr (assq type selection-coercion-alist))))
393 (apply handler-fn (list selection type value))))))
395 ;; The rest of the functions on this "page" are conversion handlers,
396 ;; append handlers and buffer-kill handlers.
397 (defun select-convert-to-text (selection type value)
398 (cond ((stringp value)
402 (set-buffer (extent-object value))
405 (buffer-substring (extent-start-position value)
406 (extent-end-position value)))))
408 (markerp (car value))
409 (markerp (cdr value)))
410 (or (eq (marker-buffer (car value)) (marker-buffer (cdr value)))
412 (list "markers must be in the same buffer"
413 (car value) (cdr value))))
415 (set-buffer (or (marker-buffer (car value))
416 (error "selection is in a killed buffer")))
419 (buffer-substring (car value) (cdr value)))))
422 (defun select-coerce-to-text (selection type value)
423 (select-convert-to-text selection type value))
425 (defun select-convert-from-text (selection type value)
426 (when (stringp value)
429 (defun select-convert-to-string (selection type value)
430 (let ((outval (select-convert-to-text selection type value)))
431 ;; force the string to be not in Compound Text format. This grubby
432 ;; hack will go soon, to be replaced by a more general mechanism.
434 (cons 'STRING outval)
437 (defun select-convert-to-compound-text (selection type value)
438 ;; converts to compound text automatically
439 (select-convert-to-text selection type value))
441 (defun select-convert-to-length (selection type value)
443 (cond ((stringp value)
446 (extent-length value))
448 (markerp (car value))
449 (markerp (cdr value)))
450 (or (eq (marker-buffer (car value))
451 (marker-buffer (cdr value)))
453 (list "markers must be in the same buffer"
454 (car value) (cdr value))))
455 (abs (- (car value) (cdr value)))))))
456 (if value ; force it to be in 32-bit format.
457 (cons (ash value -16) (logand value 65535))
460 (defun select-convert-from-length (selection type value)
461 (select-convert-to-length selection type value))
463 (defun select-convert-to-targets (selection type value)
464 ;; return a vector of atoms, but remove duplicates first.
465 (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
468 (cond ((memq (car rest) (cdr rest))
469 (setcdr rest (delq (car rest) (cdr rest))))
471 (setq rest (cdr rest)))))
472 (apply 'vector all)))
474 (defun select-convert-to-delete (selection type value)
475 (disown-selection-internal selection)
476 ;; A return value of nil means that we do not know how to do this conversion,
477 ;; and replies with an "error". A return value of NULL means that we have
478 ;; done the conversion (and any side-effects) but have no value to return.
481 (defun select-convert-to-filename (selection type value)
482 (cond ((extentp value)
483 (buffer-file-name (or (extent-object value)
484 (error "selection is in a killed buffer"))))
486 (markerp (car value))
487 (markerp (cdr value)))
488 (buffer-file-name (or (marker-buffer (car value))
489 (error "selection is in a killed buffer"))))
492 (defun select-convert-from-filename (selection type value)
493 (when (stringp value)
496 (defun select-convert-to-charpos (selection type value)
498 (cond ((cond ((extentp value)
499 (setq a (extent-start-position value)
500 b (extent-end-position value)))
502 (markerp (car value))
503 (markerp (cdr value)))
506 (setq a (1- a) b (1- b)) ; zero-based
507 (if (< b a) (setq tmp a a b b tmp))
509 (vector (cons (ash a -16) (logand a 65535))
510 (cons (ash b -16) (logand b 65535))))))))
512 (defun select-convert-to-lineno (selection type value)
514 (cond ((cond ((extentp value)
515 (setq buf (extent-object value)
516 a (extent-start-position value)
517 b (extent-end-position value)))
519 (markerp (car value))
520 (markerp (cdr value)))
521 (setq a (marker-position (car value))
522 b (marker-position (cdr value))
523 buf (marker-buffer (car value)))))
530 (setq a (1+ (count-lines 1 (point))))
533 (setq b (1+ (count-lines 1 (point))))))
534 (if (< b a) (setq tmp a a b b tmp))
536 (vector (cons (ash a -16) (logand a 65535))
537 (cons (ash b -16) (logand b 65535))))))))
539 (defun select-convert-to-colno (selection type value)
541 (cond ((cond ((extentp value)
542 (setq buf (extent-object value)
543 a (extent-start-position value)
544 b (extent-end-position value)))
546 (markerp (car value))
547 (markerp (cdr value)))
550 buf (marker-buffer a))))
554 (setq a (current-column))
556 (setq b (current-column)))
557 (if (< b a) (setq tmp a a b b tmp))
559 (vector (cons (ash a -16) (logand a 65535))
560 (cons (ash b -16) (logand b 65535))))))))
562 (defun select-convert-to-sourceloc (selection type value)
563 (let (a b buf file-name tmp)
564 (cond ((cond ((extentp value)
565 (setq buf (or (extent-object value)
566 (error "selection is in a killed buffer"))
567 a (extent-start-position value)
568 b (extent-end-position value)
569 file-name (buffer-file-name buf)))
571 (markerp (car value))
572 (markerp (cdr value)))
573 (setq a (marker-position (car value))
574 b (marker-position (cdr value))
575 buf (or (marker-buffer (car value))
576 (error "selection is in a killed buffer"))
577 file-name (buffer-file-name buf))))
584 (setq a (1+ (count-lines 1 (point))))
587 (setq b (1+ (count-lines 1 (point))))))
588 (if (< b a) (setq tmp a a b b tmp))
589 (format "%s:%d" file-name a)))))
591 (defun select-convert-to-os (selection type size)
592 (symbol-name system-type))
594 (defun select-convert-to-host (selection type size)
597 (defun select-convert-to-user (selection type size)
600 (defun select-convert-to-class (selection type size)
601 (symbol-value 'x-emacs-application-class))
603 ;; We do not try to determine the name Emacs was invoked with,
604 ;; because it is not clean for a program's behavior to depend on that.
605 (defun select-convert-to-name (selection type size)
609 (defun select-convert-to-integer (selection type value)
610 (and (integerp value)
611 (cons (ash value -16) (logand value 65535))))
613 ;; Can convert from the following integer representations
616 ;; (integer . integer)
618 ;; (list [integer|(integer . integer)]*)
619 ;; (vector [integer|(integer . integer)]*)
621 ;; Cons'd integers get cleaned up a little.
623 (defun select-convert-from-integer (selection type value)
624 (cond ((integerp value) ; Integer
627 ((and (consp value) ; (integer . integer)
628 (integerp (car value))
629 (integerp (cdr value)))
630 (if (eq (car value) 0)
632 (if (and (eq (car value) -1)
637 ((and (listp value) ; (integer integer)
638 (eq (length value) 2)
639 (integerp (car value))
640 (integerp (cadr value)))
641 (if (eq (car value) 0)
643 (if (and (eq (car value) -1)
646 (cons (car value) (cadr value)))))
648 ((listp value) ; list
651 (select-convert-from-integer selection type x))
653 (select-convert-from-integer selection type (car value))))
655 ((vectorp value) ; vector
656 (if (eq (length value) 1)
657 (select-convert-from-integer selection type (aref value 0))
658 (mapvector '(lambda (x)
659 (select-convert-from-integer selection type x))
665 (defun select-convert-to-atom (selection type value)
666 (and (symbolp value) value))
668 ;;; CF_xxx conversions
669 (defun select-convert-from-cf-text (selection type value)
670 (replace-in-string (if (string-match "\0" value)
671 (substring value 0 (match-beginning 0))
673 "\\(\r\n\\|\n\r\\)" "\n" t))
675 (defun select-convert-to-cf-text (selection type value)
676 (let ((text (select-convert-to-text selection type value)))
677 (concat (replace-in-string text "\n" "\r\n" t) "\0")))
680 (defun select-append-to-text (selection type value1 value2)
681 (let ((text1 (select-convert-to-text selection 'STRING value1))
682 (text2 (select-convert-to-text selection 'STRING value2)))
683 (if (and text1 text2)
687 (defun select-append-to-string (selection type value1 value2)
688 (select-append-to-text selection type value1 value2))
690 (defun select-append-to-compound-text (selection type value1 value2)
691 (select-append-to-text selection type value1 value2))
693 (defun select-append-to-cf-text (selection type value1 value2)
694 (let ((text1 (select-convert-from-cf-text selection 'CF_TEXT value1))
695 (text2 (select-convert-from-cf-text selection 'CF_TEXT value2)))
696 (if (and text1 text2)
697 (select-convert-to-cf-text selection type (concat text1 text2))
700 (defun select-append-default (selection type value1 value2)
701 ;; This appender gets used if the type is "nil" - i.e. default.
702 ;; It should probably have more cases implemented than it does - e.g.
703 ;; appending numbers to strings, etc...
704 (cond ((and (stringp value1) (stringp value2))
705 (select-append-to-string selection 'STRING value1 value2))
708 ;;; Buffer kill handlers
710 (defun select-buffer-killed-default (selection type value buffer)
711 ;; This handler gets used if the type is "nil".
712 (cond ((extentp value)
713 (if (eq (extent-object value) buffer)
714 ; If this selection is on the clipboard, grab it quick
715 (when (eq selection 'CLIPBOARD)
717 (set-buffer (extent-object value))
720 (buffer-substring (extent-start-position value)
721 (extent-end-position value)))))
724 (unless (eq (marker-buffer value) buffer)
727 (markerp (car value))
728 (markerp (cdr value)))
729 (if (or (eq (marker-buffer (car value)) buffer)
730 (eq (marker-buffer (cdr value)) buffer))
731 ; If this selection is on the clipboard, grab it quick
732 (when (eq selection 'CLIPBOARD)
734 (set-buffer (marker-buffer (car value)))
737 (buffer-substring (car value) (cdr value)))))
741 (defun select-buffer-killed-text (selection type value buffer)
742 (select-buffer-killed-default selection type value buffer))
744 ;; Types listed in here can be selections of XEmacs
745 (setq selection-converter-out-alist
746 '((TEXT . select-convert-to-text)
747 (STRING . select-convert-to-string)
748 (COMPOUND_TEXT . select-convert-to-compound-text)
749 (TARGETS . select-convert-to-targets)
750 (LENGTH . select-convert-to-length)
751 (DELETE . select-convert-to-delete)
752 (FILE_NAME . select-convert-to-filename)
753 (CHARACTER_POSITION . select-convert-to-charpos)
754 (SOURCE_LOC . select-convert-to-sourceloc)
755 (LINE_NUMBER . select-convert-to-lineno)
756 (COLUMN_NUMBER . select-convert-to-colno)
757 (OWNER_OS . select-convert-to-os)
758 (HOST_NAME . select-convert-to-host)
759 (USER . select-convert-to-user)
760 (CLASS . select-convert-to-class)
761 (NAME . select-convert-to-name)
762 (ATOM . select-convert-to-atom)
763 (INTEGER . select-convert-to-integer)
764 (CF_TEXT . select-convert-to-cf-text)
767 ;; Types listed here can be selections foreign to XEmacs
768 (setq selection-converter-in-alist
769 '(; Specific types that get handled by generic converters
770 (COMPOUND_TEXT . select-convert-from-text)
771 (SOURCE_LOC . select-convert-from-text)
772 (OWNER_OS . select-convert-from-text)
773 (HOST_NAME . select-convert-from-text)
774 (USER . select-convert-from-text)
775 (CLASS . select-convert-from-text)
776 (NAME . select-convert-from-text)
778 (INTEGER . select-convert-from-integer)
779 (TEXT . select-convert-from-text)
780 (STRING . select-convert-from-text)
781 (LENGTH . select-convert-from-length)
782 (FILE_NAME . select-convert-from-filename)
783 (CF_TEXT . select-convert-from-cf-text)
786 ;; Types listed here have special coercion functions that can munge
787 ;; other types. This can also be used to add special features - e.g.
788 ;; being able to pass a region or a cons of markers to own-selection,
789 ;; but getting the *current* text in the region back when calling
792 ;; Any function listed in here *will be called* whenever a value of
793 ;; its type is retrieved from the internal selection cache, or when
794 ;; no suitable values could be found in which case XEmacs looks for
795 ;; values with types listed in selection-coercible-types.
796 (setq selection-coercion-alist
797 '((TEXT . select-coerce-to-text)
798 (STRING . select-coerce-to-text)
799 (COMPOUND_TEXT . select-coerce-to-text)
800 (CF_TEXT . select-coerce-to-text)))
802 ;; Types listed here can be appended by own-selection
803 (setq selection-appender-alist
804 '((nil . select-append-default)
805 (TEXT . select-append-to-text)
806 (STRING . select-append-to-string)
807 (COMPOUND_TEXT . select-append-to-compound-text)
808 (CF_TEXT . select-append-to-cf-text)
811 ;; Types listed here have buffer-kill handlers
812 (setq selection-buffer-killed-alist
813 '((nil . select-buffer-killed-default)
814 (TEXT . select-buffer-killed-text)
815 (STRING . select-buffer-killed-text)
816 (COMPOUND_TEXT . select-buffer-killed-text)
817 (CF_TEXT . select-buffer-killed-text)))
819 ;; Lists of types that are coercible (can be converted to other types)
820 (setq selection-coercible-types '(TEXT STRING COMPOUND_TEXT))
822 ;;; select.el ends here