annotate lisp/select.el @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 2f8bb876ab1d
children 697ef44129c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
1 ;;; select.el --- Lisp interface to windows selections.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
2
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
3 ;; Copyright (C) 1998 Andy Piper.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
4 ;; Copyright (C) 1990, 1997 Free Software Foundation, Inc.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
5 ;; Copyright (C) 1995 Sun Microsystems.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
6
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
8 ;; Keywords: extensions, dumped
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
9
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
11
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
15 ;; any later version.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
16
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
20 ;; General Public License for more details.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
21
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
26
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
27 ;;; Synched up with: Not in FSF
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
28
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
29 ;;; Commentary:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
30
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
31 ;; This file is dumped with XEmacs
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
32
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
33 ;;; Code:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
34
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
35 (defvar selected-text-type
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
36 (if (featurep 'mule) '(COMPOUND_TEXT STRING) 'STRING)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
37 "The type atom used to obtain selections from the X server.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
38 Can be either a valid X selection data type, or a list of such types.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
39 COMPOUND_TEXT and STRING are the most commonly used data types.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
40 If a list is provided, the types are tried in sequence until
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
41 there is a successful conversion.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
42
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
43 (defvar selection-sets-clipboard nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
44 "Controls the selection's relationship to the clipboard.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
45 When non-nil, any operation that sets the primary selection will also
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
46 set the clipboard.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
47
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
48 (defun copy-primary-selection ()
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
49 "Copy the selection to the Clipboard and the kill ring."
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
50 (interactive)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
51 (and (console-on-window-system-p)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
52 (cut-copy-clear-internal 'copy)))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
53
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
54 (defun kill-primary-selection ()
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
55 "Copy the selection to the Clipboard and the kill ring, then delete it."
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
56 (interactive "*")
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
57 (and (console-on-window-system-p)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
58 (cut-copy-clear-internal 'cut)))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
59
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
60 (defun delete-primary-selection ()
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
61 "Delete the selection without copying it to the Clipboard or the kill ring."
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
62 (interactive "*")
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
63 (and (console-on-window-system-p)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
64 (cut-copy-clear-internal 'clear)))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
65
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
66 (defun yank-clipboard-selection ()
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
67 "Insert the current Clipboard selection at point."
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
68 (interactive "*")
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
69 (when (console-on-window-system-p)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
70 (setq last-command nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
71 (setq this-command 'yank) ; so that yank-pop works.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
72 (let ((clip (get-clipboard)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
73 (or clip (error "there is no clipboard selection"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
74 (push-mark)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
75 (insert clip))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
76
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
77 (defun get-clipboard ()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
78 "Return text pasted to the clipboard."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
79 (get-selection 'CLIPBOARD))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
80
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
81 (define-device-method get-cutbuffer
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
82 "Return the value of one of the cut buffers.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
83 This will do nothing under anything other than X.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
84
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
85 (defun get-selection-no-error (&optional type data-type)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
86 "Return the value of a window-system selection.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
87 The argument TYPE (default `PRIMARY') says which selection,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
88 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
89 says how to convert the data. Returns NIL if there is no selection"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
90 (condition-case err (get-selection type data-type) (t nil)))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
91
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
92 (defun get-selection (&optional type data-type)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
93 "Return the value of a window-system selection.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
94 The argument TYPE (default `PRIMARY') says which selection,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
95 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
96 says how to convert the data. If there is no selection an error is signalled."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
97 (or type (setq type 'PRIMARY))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
98 (or data-type (setq data-type selected-text-type))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
99 (let ((text
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
100 (if (consp data-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
101 (condition-case err
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
102 (get-selection-internal type (car data-type))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
103 (selection-conversion-error
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
104 (if (cdr data-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
105 (get-selection type (cdr data-type))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
106 (signal (car err) (cdr err)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
107 (get-selection-internal type data-type))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
108 text))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
109
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
110 ;; FSFmacs calls this `x-set-selection', and reverses the
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
111 ;; first two arguments (duh ...). This order is more logical.
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
112 (defun own-selection (data &optional type how-to-add data-type)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
113 "Make a window-system selection of type TYPE and value DATA.
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
114 The argument TYPE (default `PRIMARY') says which selection,
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
115 and DATA specifies the contents. DATA may be any lisp data type
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
116 that can be converted using the function corresponding to DATA-TYPE
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
117 in `select-converter-alist'---strings are the usual choice, but
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
118 other types may be permissible depending on the DATA-TYPE parameter
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
119 (if DATA-TYPE is not supplied, the default behaviour is window
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
120 system specific, but strings are always accepted).
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
121 HOW-TO-ADD may be any of the following:
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
122
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
123 'replace-all or nil -- replace all data in the selection.
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
124 'replace-existing -- replace data for specified DATA-TYPE only.
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
125 'append or t -- append data to existing DATA-TYPE data.
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
126
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
127 DATA-TYPE is the window-system specific data type identifier
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
128 (see `register-selection-data-type' for more information).
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
129
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
130 The selection may also be a cons of two markers pointing to the same buffer,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
131 or an overlay. In these cases, the selection is considered to be the text
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
132 between the markers *at whatever time the selection is examined* (note
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
133 that the window system clipboard does not necessarily duplicate this
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
134 behaviour - it doesn't on mswindows for example).
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
135 Thus, editing done in the buffer after you specify the selection
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
136 can alter the effective value of the selection.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
137
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
138 The data may also be a vector of valid non-vector selection values.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
139
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
140 Interactively, the text of the region is used as the selection value."
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
141 (interactive (if (not current-prefix-arg)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
142 (list (read-string "Store text for pasting: "))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
143 (list (substring (region-beginning) (region-end)))))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
144 ;; calling own-selection-internal will mess this up, so preserve it.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
145 (let ((zmacs-region-stays zmacs-region-stays))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
146 ;FSFmacs huh?? It says:
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
147 ;; "This is for temporary compatibility with pre-release Emacs 19."
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
148 ;(if (stringp type)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
149 ; (setq type (intern type)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
150 (or type (setq type 'PRIMARY))
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
151 (if (null data)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
152 (disown-selection-internal type)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
153 (own-selection-internal type data how-to-add data-type)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
154 (when (and (eq type 'PRIMARY)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
155 selection-sets-clipboard)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
156 (own-selection-internal 'CLIPBOARD data how-to-add data-type)))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
157 (cond ((eq type 'PRIMARY)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
158 (setq primary-selection-extent
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
159 (select-make-extent-for-selection
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
160 data primary-selection-extent)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
161 ((eq type 'SECONDARY)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
162 (setq secondary-selection-extent
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
163 (select-make-extent-for-selection
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
164 data secondary-selection-extent)))))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
165 ;; zmacs-region-stays is for commands, not low-level functions.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
166 ;; when behaving as the latter, we better not set it, or we will
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
167 ;; cause unwanted sticky-region behavior in kill-region and friends.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
168 (if (interactive-p)
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
169 (setq zmacs-region-stays t))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
170 data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
171
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
172 (defun dehilight-selection (selection)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
173 "for use as a value of `lost-selection-hooks'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
174 (cond ((eq selection 'PRIMARY)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
175 (if primary-selection-extent
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
176 (let ((inhibit-quit t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
177 (if (consp primary-selection-extent)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
178 (mapcar 'delete-extent primary-selection-extent)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
179 (delete-extent primary-selection-extent))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
180 (setq primary-selection-extent nil)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
181 (if zmacs-regions (zmacs-deactivate-region)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
182 ((eq selection 'SECONDARY)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
183 (if secondary-selection-extent
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
184 (let ((inhibit-quit t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
185 (if (consp secondary-selection-extent)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
186 (mapcar 'delete-extent secondary-selection-extent)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
187 (delete-extent secondary-selection-extent))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
188 (setq secondary-selection-extent nil)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
189 nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
190
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
191 (setq lost-selection-hooks 'dehilight-selection)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
192
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
193 (defun own-clipboard (string &optional push)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
194 "Paste the given string to the window system Clipboard.
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
195 See `interprogram-cut-function' for more information."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
196 (own-selection string 'CLIPBOARD))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
197
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
198 (defun disown-selection (&optional secondary-p)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
199 "Assuming we own the selection, disown it. With an argument, discard the
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
200 secondary selection instead of the primary selection."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
201 (disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
202 (when (and selection-sets-clipboard
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
203 (or (not secondary-p)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
204 (eq secondary-p 'PRIMARY)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
205 (eq secondary-p 'CLIPBOARD)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
206 (disown-selection-internal 'CLIPBOARD)))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
207
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
208 ;; from x-init.el
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
209 ;; selections and active regions
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
210
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
211 ;; If and only if zmacs-regions is true:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
212
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
213 ;; When a mark is pushed and the region goes into the "active" state, we
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
214 ;; assert it as the Primary selection. This causes it to be hilighted.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
215 ;; When the region goes into the "inactive" state, we disown the Primary
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
216 ;; selection, causing the region to be dehilighted.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
217
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
218 ;; Note that it is possible for the region to be in the "active" state
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
219 ;; and not be hilighted, if it is in the active state and then some other
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
220 ;; application asserts the selection. This is probably not a big deal.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
221
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
222 (defun activate-region-as-selection ()
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
223 (if (marker-buffer (mark-marker t))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
224 (own-selection (cons (point-marker t) (mark-marker t)))))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
225
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
226 ; moved from x-select.el
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
227 (defvar primary-selection-extent nil
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
228 "The extent of the primary selection; don't use this.")
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
229
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
230 (defvar secondary-selection-extent nil
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
231 "The extent of the secondary selection; don't use this.")
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
232
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
233 (defun select-make-extent-for-selection (selection previous-extent)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
234 ;; Given a selection, this makes an extent in the buffer which holds that
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
235 ;; selection, for highlighting purposes. If the selection isn't associated
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
236 ;; with a buffer, this does nothing.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
237 (let ((buffer nil)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
238 (valid (and (extentp previous-extent)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
239 (extent-object previous-extent)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
240 (buffer-live-p (extent-object previous-extent))))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
241 start end)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
242 (cond ((stringp selection)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
243 ;; if we're selecting a string, lose the previous extent used
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
244 ;; to highlight the selection.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
245 (setq valid nil))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
246 ((consp selection)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
247 (setq start (min (car selection) (cdr selection))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
248 end (max (car selection) (cdr selection))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
249 valid (and valid
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
250 (eq (marker-buffer (car selection))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
251 (extent-object previous-extent)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
252 buffer (marker-buffer (car selection))))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
253 ((extentp selection)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
254 (setq start (extent-start-position selection)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
255 end (extent-end-position selection)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
256 valid (and valid
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
257 (eq (extent-object selection)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
258 (extent-object previous-extent)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
259 buffer (extent-object selection)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
260 (t
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
261 (signal 'error (list "invalid selection" selection))))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
262
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
263 (if valid
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
264 nil
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
265 (condition-case ()
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
266 (if (listp previous-extent)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
267 (mapcar 'delete-extent previous-extent)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
268 (delete-extent previous-extent))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
269 (error nil)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
270
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
271 (if (not buffer)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
272 ;; string case
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
273 nil
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
274 ;; normal case
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
275 (if valid
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
276 (set-extent-endpoints previous-extent start end)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
277 (setq previous-extent (make-extent start end buffer))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
278
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
279 ;; Make the extent be closed on the right, which means that if
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
280 ;; characters are inserted exactly at the end of the extent, the
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
281 ;; extent will grow to cover them. This is important for shell
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
282 ;; buffers - suppose one makes a selection, and one end is at
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
283 ;; point-max. If the shell produces output, that marker will remain
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
284 ;; at point-max (its position will increase). So it's important that
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
285 ;; the extent exhibit the same behavior, lest the region covered by
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
286 ;; the extent (the visual indication), and the region between point
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
287 ;; and mark (the actual selection value) become different!
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
288 (set-extent-property previous-extent 'end-open nil)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
289
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
290 (cond
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
291 (mouse-track-rectangle-p
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
292 (setq previous-extent (list previous-extent))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
293 (default-mouse-track-next-move-rect start end previous-extent)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
294 ))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
295 previous-extent))))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
296
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
297 ;; moved from x-select.el
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
298 (defun valid-simple-selection-p (data)
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
299 "An obsolete function that tests whether something was a valid simple
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
300 selection using the old XEmacs selection support. You shouldn't use this
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
301 any more, because just about anything could be a valid selection now."
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
302 (or (stringp data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
303 ;FSFmacs huh?? (symbolp data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
304 (integerp data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
305 (and (consp data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
306 (integerp (car data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
307 (or (integerp (cdr data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
308 (and (consp (cdr data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
309 (integerp (car (cdr data))))))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
310 (extentp data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
311 (and (consp data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
312 (markerp (car data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
313 (markerp (cdr data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
314 (marker-buffer (car data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
315 (marker-buffer (cdr data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
316 (eq (marker-buffer (car data))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
317 (marker-buffer (cdr data)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
318 (buffer-live-p (marker-buffer (car data)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
319 (buffer-live-p (marker-buffer (cdr data))))))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
320
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
321 (defun cut-copy-clear-internal (mode)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
322 (or (memq mode '(cut copy clear)) (error "unkown mode %S" mode))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
323 (or (selection-owner-p)
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 380
diff changeset
324 (error "XEmacs does not own the primary selection"))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
325 (setq last-command nil)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
326 (or primary-selection-extent
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
327 (error "the primary selection is not an extent?"))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
328 (save-excursion
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
329 (let (rect-p b s e)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
330 (cond
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
331 ((consp primary-selection-extent)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
332 (setq rect-p t
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
333 b (extent-object (car primary-selection-extent))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
334 s (extent-start-position (car primary-selection-extent))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
335 e (extent-end-position (car (reverse primary-selection-extent)))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
336 (t
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
337 (setq rect-p nil
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
338 b (extent-object primary-selection-extent)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
339 s (extent-start-position primary-selection-extent)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
340 e (extent-end-position primary-selection-extent))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
341 (set-buffer b)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
342 (cond ((memq mode '(cut copy))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
343 (if rect-p
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
344 (progn
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
345 ;; why is killed-rectangle free? Is it used somewhere?
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
346 ;; should it be defvarred?
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
347 (setq killed-rectangle (extract-rectangle s e))
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
348 (kill-new (mapconcat #'identity killed-rectangle "\n")))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
349 (copy-region-as-kill s e))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
350 ;; Maybe killing doesn't own clipboard. Make sure it happens.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
351 ;; This memq is kind of grody, because they might have done it
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
352 ;; some other way, but owning the clipboard twice in that case
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
353 ;; wouldn't actually hurt anything.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
354 (or (and (consp kill-hooks) (memq 'own-clipboard kill-hooks))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
355 (own-clipboard (car kill-ring)))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
356 (cond ((memq mode '(cut clear))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
357 (if rect-p
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
358 (delete-rectangle s e)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
359 (delete-region s e))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
360 (disown-selection nil)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
361 )))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
362
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
363
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
364 ;;; Functions to convert the selection into various other selection
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
365 ;;; types.
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
366
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
367 ;; These two functions get called by C code...
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
368 (defun select-convert-in (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
369 "Attempt to convert the specified external VALUE to the specified DATA-TYPE,
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
370 for the specified SELECTION. Return nil if this is impossible, or a
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
371 suitable internal representation otherwise."
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
372 (when value
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
373 (let ((handler-fn (cdr (assq type selection-converter-in-alist))))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
374 (when handler-fn
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
375 (apply handler-fn (list selection type value))))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
376
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
377 (defun select-convert-out (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
378 "Attempt to convert the specified internal VALUE for the specified DATA-TYPE
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
379 and SELECTION. Return nil if this is impossible, or a suitable external
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
380 representation otherwise."
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
381 (when value
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
382 (let ((handler-fn (cdr (assq type selection-converter-out-alist))))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
383 (when handler-fn
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
384 (apply handler-fn (list selection type value))))))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
385
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
386 ;; The rest of the functions on this "page" are conversion handlers,
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
387 ;; append handlers and buffer-kill handlers.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
388 (defun select-convert-to-text (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
389 (cond ((stringp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
390 value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
391 ((extentp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
392 (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
393 (set-buffer (extent-object value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
394 (save-restriction
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
395 (widen)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
396 (buffer-substring (extent-start-position value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
397 (extent-end-position value)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
398 ((and (consp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
399 (markerp (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
400 (markerp (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
401 (or (eq (marker-buffer (car value)) (marker-buffer (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
402 (signal 'error
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
403 (list "markers must be in the same buffer"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
404 (car value) (cdr value))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
405 (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
406 (set-buffer (or (marker-buffer (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
407 (error "selection is in a killed buffer")))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
408 (save-restriction
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
409 (widen)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
410 (buffer-substring (car value) (cdr value)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
411 (t nil)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
412
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
413 (defun select-convert-from-text (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
414 (when (stringp value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
415 value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
416
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
417 (defun select-convert-to-string (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
418 (let ((outval (select-convert-to-text selection type value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
419 ;; force the string to be not in Compound Text format.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
420 (if (stringp outval)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
421 (cons 'STRING outval)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
422 outval)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
423
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
424 (defun select-convert-to-compound-text (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
425 ;; converts to compound text automatically
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
426 (select-convert-to-text selection type value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
427
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
428 (defun select-convert-to-length (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
429 (let ((value
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
430 (cond ((stringp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
431 (length value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
432 ((extentp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
433 (extent-length value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
434 ((and (consp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
435 (markerp (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
436 (markerp (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
437 (or (eq (marker-buffer (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
438 (marker-buffer (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
439 (signal 'error
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
440 (list "markers must be in the same buffer"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
441 (car value) (cdr value))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
442 (abs (- (car value) (cdr value)))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
443 (if value ; force it to be in 32-bit format.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
444 (cons (ash value -16) (logand value 65535))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
445 nil)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
446
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
447 (defun select-convert-from-length (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
448 (select-convert-to-length selection type value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
449
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
450 (defun select-convert-to-targets (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
451 ;; return a vector of atoms, but remove duplicates first.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
452 (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
453 (rest all))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
454 (while rest
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
455 (cond ((memq (car rest) (cdr rest))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
456 (setcdr rest (delq (car rest) (cdr rest))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
457 (t
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
458 (setq rest (cdr rest)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
459 (apply 'vector all)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
460
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
461 (defun select-convert-to-delete (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
462 (disown-selection-internal selection)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
463 ;; A return value of nil means that we do not know how to do this conversion,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
464 ;; and replies with an "error". A return value of NULL means that we have
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
465 ;; done the conversion (and any side-effects) but have no value to return.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
466 'NULL)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
467
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
468 (defun select-convert-to-filename (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
469 (cond ((extentp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
470 (buffer-file-name (or (extent-object value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
471 (error "selection is in a killed buffer"))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
472 ((and (consp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
473 (markerp (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
474 (markerp (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
475 (buffer-file-name (or (marker-buffer (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
476 (error "selection is in a killed buffer"))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
477 (t nil)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
478
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
479 (defun select-convert-from-filename (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
480 (when (stringp value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
481 value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
482
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
483 (defun select-convert-to-charpos (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
484 (let (a b tmp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
485 (cond ((cond ((extentp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
486 (setq a (extent-start-position value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
487 b (extent-end-position value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
488 ((and (consp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
489 (markerp (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
490 (markerp (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
491 (setq a (car value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
492 b (cdr value))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
493 (setq a (1- a) b (1- b)) ; zero-based
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
494 (if (< b a) (setq tmp a a b b tmp))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
495 (cons 'SPAN
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
496 (vector (cons (ash a -16) (logand a 65535))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
497 (cons (ash b -16) (logand b 65535))))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
498
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
499 (defun select-convert-to-lineno (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
500 (let (a b buf tmp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
501 (cond ((cond ((extentp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
502 (setq buf (extent-object value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
503 a (extent-start-position value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
504 b (extent-end-position value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
505 ((and (consp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
506 (markerp (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
507 (markerp (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
508 (setq a (marker-position (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
509 b (marker-position (cdr value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
510 buf (marker-buffer (car value)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
511 (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
512 (set-buffer buf)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
513 (save-restriction
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
514 (widen)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
515 (goto-char a)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
516 (beginning-of-line)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
517 (setq a (1+ (count-lines 1 (point))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
518 (goto-char b)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
519 (beginning-of-line)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
520 (setq b (1+ (count-lines 1 (point))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
521 (if (< b a) (setq tmp a a b b tmp))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
522 (cons 'SPAN
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
523 (vector (cons (ash a -16) (logand a 65535))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
524 (cons (ash b -16) (logand b 65535))))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
525
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
526 (defun select-convert-to-colno (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
527 (let (a b buf tmp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
528 (cond ((cond ((extentp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
529 (setq buf (extent-object value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
530 a (extent-start-position value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
531 b (extent-end-position value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
532 ((and (consp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
533 (markerp (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
534 (markerp (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
535 (setq a (car value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
536 b (cdr value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
537 buf (marker-buffer a))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
538 (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
539 (set-buffer buf)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
540 (goto-char a)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
541 (setq a (current-column))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
542 (goto-char b)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
543 (setq b (current-column)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
544 (if (< b a) (setq tmp a a b b tmp))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
545 (cons 'SPAN
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
546 (vector (cons (ash a -16) (logand a 65535))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
547 (cons (ash b -16) (logand b 65535))))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
548
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
549 (defun select-convert-to-sourceloc (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
550 (let (a b buf file-name tmp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
551 (cond ((cond ((extentp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
552 (setq buf (or (extent-object value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
553 (error "selection is in a killed buffer"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
554 a (extent-start-position value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
555 b (extent-end-position value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
556 file-name (buffer-file-name buf)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
557 ((and (consp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
558 (markerp (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
559 (markerp (cdr value)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
560 (setq a (marker-position (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
561 b (marker-position (cdr value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
562 buf (or (marker-buffer (car value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
563 (error "selection is in a killed buffer"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
564 file-name (buffer-file-name buf))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
565 (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
566 (set-buffer buf)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
567 (save-restriction
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
568 (widen)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
569 (goto-char a)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
570 (beginning-of-line)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
571 (setq a (1+ (count-lines 1 (point))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
572 (goto-char b)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
573 (beginning-of-line)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
574 (setq b (1+ (count-lines 1 (point))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
575 (if (< b a) (setq tmp a a b b tmp))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
576 (format "%s:%d" file-name a)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
577
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
578 (defun select-convert-to-os (selection type size)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
579 (symbol-name system-type))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
580
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
581 (defun select-convert-to-host (selection type size)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
582 (system-name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
583
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
584 (defun select-convert-to-user (selection type size)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
585 (user-full-name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
586
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
587 (defun select-convert-to-class (selection type size)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
588 x-emacs-application-class)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
589
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
590 ;; We do not try to determine the name Emacs was invoked with,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
591 ;; because it is not clean for a program's behavior to depend on that.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
592 (defun select-convert-to-name (selection type size)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
593 ;invocation-name
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
594 "xemacs")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
595
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
596 (defun select-convert-to-integer (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
597 (and (integerp value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
598 (cons (ash value -16) (logand value 65535))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
599
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
600 ;; Can convert from the following integer representations
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
601 ;;
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
602 ;; integer
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
603 ;; (integer . integer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
604 ;; (integer integer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
605 ;; (list [integer|(integer . integer)]*)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
606 ;; (vector [integer|(integer . integer)]*)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
607 ;;
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
608 ;; Cons'd integers get cleaned up a little.
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
609
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
610 (defun select-convert-from-integer (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
611 (cond ((integerp value) ; Integer
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
612 value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
613
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
614 ((and (consp value) ; (integer . integer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
615 (integerp (car value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
616 (integerp (cdr value)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
617 (if (eq (car value) 0)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
618 (cdr value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
619 (if (and (eq (car value) -1)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
620 (< (cdr value) 0))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
621 (cdr value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
622 value)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
623
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
624 ((and (listp value) ; (integer integer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
625 (eq (length value) 2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
626 (integerp (car value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
627 (integerp (cadr value)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
628 (if (eq (car value) 0)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
629 (cadr value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
630 (if (and (eq (car value) -1)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
631 (< (cdr value) 0))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
632 (- (cadr value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
633 (cons (car value) (cadr value)))))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
634
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
635 ((listp value) ; list
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
636 (if (cdr value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
637 (mapcar '(lambda (x)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
638 (select-convert-from-integer selection type x))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
639 value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
640 (select-convert-from-integer selection type (car value))))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
641
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
642 ((vectorp value) ; vector
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
643 (if (eq (length value) 1)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
644 (select-convert-from-integer selection type (aref value 0))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
645 (mapvector '(lambda (x)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
646 (select-convert-from-integer selection type x))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
647 value)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
648
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
649 (t nil)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
650 ))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
651
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
652 (defun select-convert-to-atom (selection type value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
653 (and (symbolp value) value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
654
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
655 ;;; CF_xxx conversions
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
656 (defun select-convert-from-cf-text (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
657 (replace-in-string (if (string-match "\0" value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
658 (substring value 0 (match-beginning 0))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
659 value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
660 "\\(\r\n\\|\n\r\\)" "\n" t))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
661
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
662 (defun select-convert-to-cf-text (selection type value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
663 (let ((text (select-convert-to-text selection type value)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
664 (concat (replace-in-string text "\n" "\r\n" t) "\0")))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
665
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
666 ;;; Appenders
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
667 (defun select-append-to-text (selection type value1 value2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
668 (let ((text1 (select-convert-to-text selection 'STRING value1))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
669 (text2 (select-convert-to-text selection 'STRING value2)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
670 (if (and text1 text2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
671 (concat text1 text2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
672 nil)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
673
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
674 (defun select-append-to-string (selection type value1 value2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
675 (select-append-to-text selection type value1 value2))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
676
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
677 (defun select-append-to-compound-text (selection type value1 value2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
678 (select-append-to-text selection type value1 value2))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
679
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
680 (defun select-append-to-cf-text (selection type value1 value2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
681 (let ((text1 (select-convert-from-cf-text selection 'CF_TEXT value1))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
682 (text2 (select-convert-from-cf-text selection 'CF_TEXT value2)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
683 (if (and text1 text2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
684 (select-convert-to-cf-text selection type (concat text1 text2))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
685 nil)))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
686
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
687 (defun select-append-default (selection type value1 value2)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
688 ;; This appender gets used if the type is "nil" - i.e. default.
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
689 ;; It should probably have more cases implemented than it does - e.g.
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
690 ;; appending numbers to strings, etc...
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
691 (cond ((and (stringp value1) (stringp value2))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
692 (select-append-to-string selection 'STRING value1 value2))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
693 (t nil)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
694
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
695 ;;; Buffer kill handlers
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
696
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
697 ;; #### Should this function take the text *out* of the buffer that's
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
698 ;; being killed? Or should it do what the original code did and just
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
699 ;; destroy the selection?
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
700 (defun select-buffer-killed-default (selection type value buffer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
701 ;; This handler gets used if the type is "nil".
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
702 (cond ((extentp value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
703 (unless (eq (extent-object value) buffer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
704 value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
705 ((markerp value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
706 (unless (eq (marker-buffer value) buffer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
707 value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
708 ((and (consp value)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
709 (markerp (car value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
710 (markerp (cdr value)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
711 (unless (or (eq (marker-buffer (car value)) buffer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
712 (eq (marker-buffer (cdr value)) buffer))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
713 value))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
714 (t value)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
715
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
716 (defun select-buffer-killed-text (selection type value buffer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
717 (select-buffer-killed-default selection type value buffer))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
718
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
719 ;; Types listed in here can be selections of XEmacs
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
720 (setq selection-converter-out-alist
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
721 '((TEXT . select-convert-to-text)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
722 (STRING . select-convert-to-string)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
723 (COMPOUND_TEXT . select-convert-to-compound-text)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
724 (TARGETS . select-convert-to-targets)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
725 (LENGTH . select-convert-to-length)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
726 (DELETE . select-convert-to-delete)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
727 (FILE_NAME . select-convert-to-filename)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
728 (CHARACTER_POSITION . select-convert-to-charpos)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
729 (SOURCE_LOC . select-convert-to-sourceloc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
730 (LINE_NUMBER . select-convert-to-lineno)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
731 (COLUMN_NUMBER . select-convert-to-colno)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
732 (OWNER_OS . select-convert-to-os)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
733 (HOST_NAME . select-convert-to-host)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
734 (USER . select-convert-to-user)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
735 (CLASS . select-convert-to-class)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
736 (NAME . select-convert-to-name)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
737 (ATOM . select-convert-to-atom)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
738 (INTEGER . select-convert-to-integer)
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
739 (CF_TEXT . select-convert-to-cf-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
740 ))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
741
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
742 ;; Types listed here can be selections foreign to XEmacs
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
743 (setq selection-converter-in-alist
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
744 '(; Specific types that get handled by generic converters
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
745 (COMPOUND_TEXT . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
746 (SOURCE_LOC . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
747 (OWNER_OS . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
748 (HOST_NAME . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
749 (USER . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
750 (CLASS . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
751 (NAME . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
752 ; Generic types
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
753 (INTEGER . select-convert-from-integer)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
754 (TEXT . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
755 (STRING . select-convert-from-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
756 (LENGTH . select-convert-from-length)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
757 (FILE_NAME . select-convert-from-filename)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
758 (CF_TEXT . select-convert-from-cf-text)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
759 ))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
760
410
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
761 ;; Types listed here can be appended by own-selection
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
762 (setq selection-appender-alist
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
763 '((nil . select-append-default)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
764 (TEXT . select-append-to-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
765 (STRING . select-append-to-string)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
766 (COMPOUND_TEXT . select-append-to-compound-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
767 (CF_TEXT . select-append-to-cf-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
768 ))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
769
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
770 ;; Types listed here have buffer-kill handlers
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
771 (setq selection-buffer-killed-alist
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
772 '((nil . select-buffer-killed-default)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
773 (TEXT . select-buffer-killed-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
774 (STRING . select-buffer-killed-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
775 (COMPOUND_TEXT . select-buffer-killed-text)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
776 (CF_TEXT . select-buffer-killed-text)))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
777
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
778 ;; Lists of types that are coercible (can be converted to other types)
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
779 (setq selection-coercible-types '(TEXT STRING COMPOUND_TEXT))
de805c49cfc1 Import from CVS: tag r21-2-35
cvs
parents: 404
diff changeset
780
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents:
diff changeset
781 ;;; select.el ends here