annotate lisp/x11/x-select.el @ 186:24ac94803b48

Added tag r20-3b19 for changeset 3d6bfa290dbd
author cvs
date Mon, 13 Aug 2007 09:55:30 +0200
parents 8eaf7971accc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; x-select.el --- Elisp interface to X Selections.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1990 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 Sun Microsystems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
18 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
20 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; The selection code requires us to use certain symbols whose names are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; all upper-case; this may seem tasteless, but it makes there be a 1:1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; correspondence between these symbols and X Atoms (which are upcased).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Synched up with: FSF 19.30 (select.el).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
30 (defvar x-selected-text-type
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
31 (if (featurep 'mule) '(COMPOUND_TEXT STRING) 'STRING)
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
32 "The type atom used to obtain selections from the X server.
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
33 Can be either a valid X selection data type, or a list of such types.
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
34 COMPOUND_TEXT and STRING are the most commonly used data types.
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
35 If a list is provided, the types are tried in sequence until
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
36 there is a successful conversion.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defun x-get-selection (&optional type data-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "Return the value of an X Windows selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 The argument TYPE (default `PRIMARY') says which selection,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
41 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
42 says how to convert the data."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (or type (setq type 'PRIMARY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (or data-type (setq data-type x-selected-text-type))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
45 (let ((text
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
46 (if (consp data-type)
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
47 (condition-case err
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
48 (x-get-selection-internal type (car data-type))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
49 (selection-conversion-error
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
50 (if (cdr data-type)
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
51 (x-get-selection type (cdr data-type))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
52 (signal (car err) (cdr err)))))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
53 (x-get-selection-internal type data-type))))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
54 (when (and (consp text) (symbolp (car text)))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
55 (setq text (cdr text)))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
56 (when (not (stringp text))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
57 (error "Selection is not a string: %S" text))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
58 text))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defun x-get-secondary-selection ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "Return text selected from some X window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (x-get-selection 'SECONDARY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defun x-get-clipboard ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 "Return text pasted to the clipboard."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (x-get-selection 'CLIPBOARD))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvar primary-selection-extent nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "The extent of the primary selection; don't use this.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defvar secondary-selection-extent nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 "The extent of the secondary selection; don't use this.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defun x-select-make-extent-for-selection (selection previous-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; Given a selection, this makes an extent in the buffer which holds that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; selection, for highlighting purposes. If the selection isn't associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; with a buffer, this does nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (let ((buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (valid (and (extentp previous-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (extent-object previous-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (buffer-live-p (extent-object previous-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (cond ((stringp selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; if we're selecting a string, lose the previous extent used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; to highlight the selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (setq valid nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ((consp selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (setq start (min (car selection) (cdr selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 end (max (car selection) (cdr selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 valid (and valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (eq (marker-buffer (car selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (extent-object previous-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 buffer (marker-buffer (car selection))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ((extentp selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (setq start (extent-start-position selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 end (extent-end-position selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 valid (and valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (eq (extent-object selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (extent-object previous-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 buffer (extent-object selection)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (signal 'error (list "invalid selection" selection))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (if (listp previous-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (mapcar 'delete-extent previous-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (delete-extent previous-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (if (not buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; string case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; normal case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (if valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (set-extent-endpoints previous-extent start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq previous-extent (make-extent start end buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; Make the extent be closed on the right, which means that if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; characters are inserted exactly at the end of the extent, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; extent will grow to cover them. This is important for shell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; buffers - suppose one makes a selection, and one end is at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; point-max. If the shell produces output, that marker will remain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; at point-max (its position will increase). So it's important that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; the extent exhibit the same behavior, lest the region covered by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; the extent (the visual indication), and the region between point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; and mark (the actual selection value) become different!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (set-extent-property previous-extent 'end-open nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (mouse-track-rectangle-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq previous-extent (list previous-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (default-mouse-track-next-move-rect start end previous-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 previous-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; FSFmacs calls this `x-set-selection', and reverses the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; arguments (duh ...). This order is more logical.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (defun x-own-selection (data &optional type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "Make an X Windows selection of type TYPE and value DATA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 The argument TYPE (default `PRIMARY') says which selection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 and DATA specifies the contents. DATA may be a string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 a symbol, an integer (or a cons of two integers or list of two integers).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 The selection may also be a cons of two markers pointing to the same buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 or an overlay. In these cases, the selection is considered to be the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 between the markers *at whatever time the selection is examined*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Thus, editing done in the buffer after you specify the selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 can alter the effective value of the selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 The data may also be a vector of valid non-vector selection values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 Interactively, the text of the region is used as the selection value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (interactive (if (not current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (list (read-string "Store text for pasting: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (list (substring (region-beginning) (region-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;FSFmacs huh?? It says:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; "This is for temporary compatibility with pre-release Emacs 19."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;(if (stringp type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ; (setq type (intern type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (or (x-valid-simple-selection-p data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (and (vectorp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (let ((valid t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (i (1- (length data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (while (>= i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (or (x-valid-simple-selection-p (aref data i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (setq valid nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq i (1- i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 valid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (signal 'error (list "invalid selection" data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (or type (setq type 'PRIMARY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (if data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (x-own-selection-internal type data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (x-disown-selection-internal type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (cond ((eq type 'PRIMARY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq primary-selection-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (x-select-make-extent-for-selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 data primary-selection-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ((eq type 'SECONDARY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (setq secondary-selection-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (x-select-make-extent-for-selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 data secondary-selection-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (setq zmacs-region-stays t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun x-valid-simple-selection-p (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (or (stringp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;FSFmacs huh?? (symbolp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (integerp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (and (consp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (integerp (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (or (integerp (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (and (consp (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (integerp (car (cdr data))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (extentp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (and (consp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (markerp (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (markerp (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (marker-buffer (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (marker-buffer (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (eq (marker-buffer (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (marker-buffer (cdr data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (buffer-live-p (marker-buffer (car data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (buffer-live-p (marker-buffer (cdr data))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defun x-own-secondary-selection (selection &optional type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "Make a secondary X Selection of the given argument. The argument may be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 string or a cons of two markers (in which case the selection is considered to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 be the text between those markers)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (interactive (if (not current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (list (read-string "Store text for pasting: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (list (cons ;; these need not be ordered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (copy-marker (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (copy-marker (mark-marker))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (x-own-selection selection 'SECONDARY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun x-own-clipboard (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "Paste the given string to the X Clipboard."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (x-own-selection string 'CLIPBOARD))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defun x-disown-selection (&optional secondary-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "Assuming we own the selection, disown it. With an argument, discard the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 secondary selection instead of the primary selection."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (x-disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defun x-dehilight-selection (selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 "for use as a value of `x-lost-selection-hooks'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (cond ((eq selection 'PRIMARY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if primary-selection-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (if (consp primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (mapcar 'delete-extent primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (delete-extent primary-selection-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (setq primary-selection-extent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (if zmacs-regions (zmacs-deactivate-region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ((eq selection 'SECONDARY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (if secondary-selection-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (consp secondary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (mapcar 'delete-extent secondary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (delete-extent secondary-selection-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq secondary-selection-extent nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (setq x-lost-selection-hooks 'x-dehilight-selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (defun x-notice-selection-requests (selection type successful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 "for possible use as the value of x-sent-selection-hooks."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (if (not successful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (message "Selection request failed to convert %s to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 selection type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (message "Sent selection %s as %s" selection type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (defun x-notice-selection-failures (selection type successful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 "for possible use as the value of x-sent-selection-hooks."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (or successful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (message "Selection request failed to convert %s to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 selection type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;(setq x-sent-selection-hooks 'x-notice-selection-requests)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;(setq x-sent-selection-hooks 'x-notice-selection-failures)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;; Selections in killed buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;;; this function is called by kill-buffer as if it were on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;;; kill-buffer-hook (though it isn't really).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (defun xselect-kill-buffer-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; Probably the right thing is to write a C function to return a list
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
275 ;; of the selections which emacs owns, since it could conceivably own
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; a user-defined selection type that we've never heard of.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (xselect-kill-buffer-hook-1 'PRIMARY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (xselect-kill-buffer-hook-1 'SECONDARY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (xselect-kill-buffer-hook-1 'CLIPBOARD))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defun xselect-kill-buffer-hook-1 (selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (let (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (if (and (x-selection-owner-p selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq value (x-get-selection-internal selection '_EMACS_INTERNAL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; The _EMACS_INTERNAL selection type has a converter registered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; for it that does no translation. This only works if emacs is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; requesting the selection from itself. We could have done this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; by writing a C function to return the raw selection data, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; that might be the right way to do this, but this was easy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (or (and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (eq (current-buffer) (marker-buffer (car value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (and (extent-live-p value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (eq (current-buffer) (extent-object value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (and (extentp value) (not (extent-live-p value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (x-disown-selection-internal selection))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;; Cut Buffer support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;;; FSF name x-get-cut-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defun x-get-cutbuffer (&optional which-one)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "Returns the value of one of the 8 X server cut buffers. Optional arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 WHICH-ONE should be a number from 0 to 7, defaulting to 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 Cut buffers are considered obsolete\; you should use selections instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 This function does nothing if support for cut buffers was not compiled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 into Emacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (and (fboundp 'x-get-cutbuffer-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (x-get-cutbuffer-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (if which-one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (aref [CUT_BUFFER0 CUT_BUFFER1 CUT_BUFFER2 CUT_BUFFER3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 CUT_BUFFER4 CUT_BUFFER5 CUT_BUFFER6 CUT_BUFFER7]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 which-one)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 'CUT_BUFFER0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;;; FSF name x-set-cut-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun x-store-cutbuffer (string &optional push)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "Store STRING into the X server's primary cut buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 If PUSH is non-nil, also rotate the cut buffers:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 this means the previous value of the primary cut buffer moves the second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 cut buffer, and the second to the third, and so on (there are 8 buffers.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 Cut buffers are considered obsolete; you should use selections instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 This function does nothing if support for cut buffers was not compiled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 into Emacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (and (fboundp 'x-store-cutbuffer-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; Check the data type of STRING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (substring string 0 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if push
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (x-rotate-cutbuffers-internal 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (x-store-cutbuffer-internal 'CUT_BUFFER0 string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;;; Random utility functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (defun x-cut-copy-clear-internal (mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (or (memq mode '(cut copy clear)) (error "unkown mode %S" mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (or (x-selection-owner-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (error "emacs does not own the primary selection"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (setq last-command nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (or primary-selection-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (error "the primary selection is not an extent?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (let (rect-p b s e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ((consp primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (setq rect-p t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 b (extent-object (car primary-selection-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 s (extent-start-position (car primary-selection-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 e (extent-end-position (car (reverse primary-selection-extent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq rect-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 b (extent-object primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 s (extent-start-position primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 e (extent-end-position primary-selection-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (set-buffer b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (cond ((memq mode '(cut copy))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (if rect-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; why is killed-rectangle free? Is it used somewhere?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;; should it be defvarred?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (setq killed-rectangle (extract-rectangle s e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (kill-new (mapconcat 'identity killed-rectangle "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (copy-region-as-kill s e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; Maybe killing doesn't own clipboard. Make sure it happens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; This memq is kind of grody, because they might have done it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; some other way, but owning the clipboard twice in that case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; wouldn't actually hurt anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (or (and (consp kill-hooks) (memq 'x-own-clipboard kill-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (x-own-clipboard (car kill-ring)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (cond ((memq mode '(cut clear))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (if rect-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (delete-rectangle s e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (delete-region s e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (x-disown-selection nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defun x-copy-primary-selection ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 "Copy the selection to the Clipboard and the kill ring."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (x-cut-copy-clear-internal 'copy))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defun x-kill-primary-selection ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "Copy the selection to the Clipboard and the kill ring, then delete it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (interactive "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (x-cut-copy-clear-internal 'cut))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defun x-delete-primary-selection ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "Delete the selection without copying it to the Clipboard or the kill ring."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (interactive "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (x-cut-copy-clear-internal 'clear))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defun x-yank-clipboard-selection ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Insert the current Clipboard selection at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (interactive "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (setq last-command nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (setq this-command 'yank) ; so that yank-pop works.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (let ((clip (x-get-clipboard)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (or clip (error "there is no clipboard selection"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (insert clip)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;;; Functions to convert the selection into various other selection types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;;; Every selection type that emacs handles is implemented this way, except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;;; for TIMESTAMP, which is a special case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (defun xselect-convert-to-text (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (cond ((stringp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ((extentp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (set-buffer (extent-object value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (buffer-substring (extent-start-position value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (extent-end-position value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ((and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (markerp (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (or (eq (marker-buffer (car value)) (marker-buffer (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (signal 'error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (list "markers must be in the same buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (car value) (cdr value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (set-buffer (or (marker-buffer (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (error "selection is in a killed buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (buffer-substring (car value) (cdr value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (defun xselect-convert-to-string (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((outval (xselect-convert-to-text selection type value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; force the string to be not in Compound Text format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (if (stringp outval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (cons 'STRING outval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 outval)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
439 (defun xselect-convert-to-compound-text (selection type value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
440 ;; converts to compound text automatically
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
441 (xselect-convert-to-text selection type value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
442
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (defun xselect-convert-to-length (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (let ((value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (cond ((stringp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (length value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ((extentp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (extent-length value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ((and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (markerp (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (or (eq (marker-buffer (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (marker-buffer (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (signal 'error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (list "markers must be in the same buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (car value) (cdr value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (abs (- (car value) (cdr value)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if value ; force it to be in 32-bit format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (cons (ash value -16) (logand value 65535))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun xselect-convert-to-targets (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ;; return a vector of atoms, but remove duplicates first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (rest all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (cond ((memq (car rest) (cdr rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (setcdr rest (delq (car rest) (cdr rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ((eq (car (cdr rest)) '_EMACS_INTERNAL) ; shh, it's a secret
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (setcdr rest (cdr (cdr rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (setq rest (cdr rest)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (apply 'vector all)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun xselect-convert-to-delete (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (x-disown-selection-internal selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; A return value of nil means that we do not know how to do this conversion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; and replies with an "error". A return value of NULL means that we have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;; done the conversion (and any side-effects) but have no value to return.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 'NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (defun xselect-convert-to-filename (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (cond ((extentp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (buffer-file-name (or (extent-object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (error "selection is in a killed buffer"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ((and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (markerp (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (buffer-file-name (or (marker-buffer (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (error "selection is in a killed buffer"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (defun xselect-convert-to-charpos (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (let (a b tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (cond ((cond ((extentp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (setq a (extent-start-position value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 b (extent-end-position value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ((and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (markerp (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (setq a (car value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 b (cdr value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (setq a (1- a) b (1- b)) ; zero-based
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if (< b a) (setq tmp a a b b tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (cons 'SPAN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (vector (cons (ash a -16) (logand a 65535))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (cons (ash b -16) (logand b 65535))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (defun xselect-convert-to-lineno (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (let (a b buf tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (cond ((cond ((extentp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (setq buf (extent-object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 a (extent-start-position value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 b (extent-end-position value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ((and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (markerp (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (setq a (marker-position (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 b (marker-position (cdr value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 buf (marker-buffer (car value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (goto-char a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (setq a (1+ (count-lines 1 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (goto-char b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (setq b (1+ (count-lines 1 (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (if (< b a) (setq tmp a a b b tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (cons 'SPAN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (vector (cons (ash a -16) (logand a 65535))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (cons (ash b -16) (logand b 65535))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (defun xselect-convert-to-colno (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (let (a b buf tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (cond ((cond ((extentp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (setq buf (extent-object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 a (extent-start-position value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 b (extent-end-position value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ((and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (markerp (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (setq a (car value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 b (cdr value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 buf (marker-buffer a))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (goto-char a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (setq a (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (goto-char b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (setq b (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (if (< b a) (setq tmp a a b b tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (cons 'SPAN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (vector (cons (ash a -16) (logand a 65535))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (cons (ash b -16) (logand b 65535))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (defun xselect-convert-to-sourceloc (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let (a b buf file-name tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (cond ((cond ((extentp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (setq buf (or (extent-object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (error "selection is in a killed buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 a (extent-start-position value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 b (extent-end-position value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 file-name (buffer-file-name buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ((and (consp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (markerp (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (markerp (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (setq a (marker-position (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 b (marker-position (cdr value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 buf (or (marker-buffer (car value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (error "selection is in a killed buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 file-name (buffer-file-name buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (goto-char a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (setq a (1+ (count-lines 1 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (goto-char b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (setq b (1+ (count-lines 1 (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (if (< b a) (setq tmp a a b b tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (format "%s:%d" file-name a)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (defun xselect-convert-to-os (selection type size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (symbol-name system-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun xselect-convert-to-host (selection type size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (system-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun xselect-convert-to-user (selection type size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (user-full-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun xselect-convert-to-class (selection type size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 x-emacs-application-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;; We do not try to determine the name Emacs was invoked with,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; because it is not clean for a program's behavior to depend on that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (defun xselect-convert-to-name (selection type size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;invocation-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 "xemacs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (defun xselect-convert-to-integer (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (and (integerp value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (cons (ash value -16) (logand value 65535))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (defun xselect-convert-to-atom (selection type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (and (symbolp value) value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (defun xselect-convert-to-identity (selection type value) ; used internally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (vector value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (setq selection-converter-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 '((TEXT . xselect-convert-to-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (STRING . xselect-convert-to-string)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
619 (COMPOUND_TEXT . xselect-convert-to-compound-text)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (TARGETS . xselect-convert-to-targets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (LENGTH . xselect-convert-to-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (DELETE . xselect-convert-to-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (FILE_NAME . xselect-convert-to-filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (CHARACTER_POSITION . xselect-convert-to-charpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (SOURCE_LOC . xselect-convert-to-sourceloc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (LINE_NUMBER . xselect-convert-to-lineno)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (COLUMN_NUMBER . xselect-convert-to-colno)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (OWNER_OS . xselect-convert-to-os)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (HOST_NAME . xselect-convert-to-host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (USER . xselect-convert-to-user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (CLASS . xselect-convert-to-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (NAME . xselect-convert-to-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (ATOM . xselect-convert-to-atom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (INTEGER . xselect-convert-to-integer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (_EMACS_INTERNAL . xselect-convert-to-identity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;FSFmacs (provide 'select)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ;;; x-select.el ends here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641