comparison lisp/select.el @ 49514:10a6fd9d8e9c

(x-set-cut-buffer): Fix docstring. Check type with `stringp' instead of `substring'.
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 29 Jan 2003 09:19:46 +0000
parents f7c325954eca
children 16b245345247 d7ddb3e565de
comparison
equal deleted inserted replaced
49513:f5454a11fe12 49514:10a6fd9d8e9c
29 29
30 ;; This is for temporary compatibility with pre-release Emacs 19. 30 ;; This is for temporary compatibility with pre-release Emacs 19.
31 (defalias 'x-selection 'x-get-selection) 31 (defalias 'x-selection 'x-get-selection)
32 (defun x-get-selection (&optional type data-type) 32 (defun x-get-selection (&optional type data-type)
33 "Return the value of an X Windows selection. 33 "Return the value of an X Windows selection.
34 The argument TYPE (default `PRIMARY') says which selection, 34 The argument TYPE (default `PRIMARY') says which selection,
35 and the argument DATA-TYPE (default `STRING') says 35 and the argument DATA-TYPE (default `STRING') says
36 how to convert the data. 36 how to convert the data.
37 37
38 TYPE may be `SECONDARY' or `CLIPBOARD', in addition to `PRIMARY'. 38 TYPE may be `SECONDARY' or `CLIPBOARD', in addition to `PRIMARY'.
39 DATA-TYPE is usually `STRING', but can also be one of the symbols 39 DATA-TYPE is usually `STRING', but can also be one of the symbols
44 "Return text pasted to the clipboard." 44 "Return text pasted to the clipboard."
45 (x-get-selection-internal 'CLIPBOARD 'STRING)) 45 (x-get-selection-internal 'CLIPBOARD 'STRING))
46 46
47 (defun x-set-selection (type data) 47 (defun x-set-selection (type data)
48 "Make an X Windows selection of type TYPE and value DATA. 48 "Make an X Windows selection of type TYPE and value DATA.
49 The argument TYPE (default `PRIMARY') says which selection, 49 The argument TYPE (default `PRIMARY') says which selection,
50 and DATA specifies the contents. DATA may be a string, 50 and DATA specifies the contents. DATA may be a string,
51 a symbol, an integer (or a cons of two integers or list of two integers). 51 a symbol, an integer (or a cons of two integers or list of two integers).
52 52
53 The selection may also be a cons of two markers pointing to the same buffer, 53 The selection may also be a cons of two markers pointing to the same buffer,
54 or an overlay. In these cases, the selection is considered to be the text 54 or an overlay. In these cases, the selection is considered to be the text
55 between the markers *at whatever time the selection is examined*. 55 between the markers *at whatever time the selection is examined*.
56 Thus, editing done in the buffer after you specify the selection 56 Thus, editing done in the buffer after you specify the selection
57 can alter the effective value of the selection. 57 can alter the effective value of the selection.
58 58
59 The data may also be a vector of valid non-vector selection values. 59 The data may also be a vector of valid non-vector selection values.
116 'CUT_BUFFER0))) 116 'CUT_BUFFER0)))
117 117
118 (defun x-set-cut-buffer (string &optional push) 118 (defun x-set-cut-buffer (string &optional push)
119 "Store STRING into the X server's primary cut buffer. 119 "Store STRING into the X server's primary cut buffer.
120 If PUSH is non-nil, also rotate the cut buffers: 120 If PUSH is non-nil, also rotate the cut buffers:
121 this means the previous value of the primary cut buffer moves the second 121 this means the previous value of the primary cut buffer moves to the second
122 cut buffer, and the second to the third, and so on (there are 8 buffers.) 122 cut buffer, and the second to the third, and so on (there are 8 buffers.)
123 Cut buffers are considered obsolete; you should use selections instead." 123 Cut buffers are considered obsolete; you should use selections instead."
124 ;; Check the data type of STRING. 124 (or (stringp string) (signal 'wrong-type-argument (list 'string string)))
125 (substring string 0 0)
126 (if push 125 (if push
127 (x-rotate-cut-buffers-internal 1)) 126 (x-rotate-cut-buffers-internal 1))
128 (x-store-cut-buffer-internal 'CUT_BUFFER0 string)) 127 (x-store-cut-buffer-internal 'CUT_BUFFER0 string))
129 128
130 129
189 compound-text-with-extensions)) 188 compound-text-with-extensions))
190 'COMPOUND_TEXT 189 'COMPOUND_TEXT
191 'STRING)) 190 'STRING))
192 (setq type 'STRING 191 (setq type 'STRING
193 str (encode-coding-string str 'iso-latin-1)))))) 192 str (encode-coding-string str 'iso-latin-1))))))
194 193
195 ((eq type 'COMPOUND_TEXT) 194 ((eq type 'COMPOUND_TEXT)
196 (setq str (encode-coding-string str coding))) 195 (setq str (encode-coding-string str coding)))
197 196
198 ((eq type 'STRING) 197 ((eq type 'STRING)
199 (if (memq coding '(compound-text 198 (if (memq coding '(compound-text