comparison lisp/select.el @ 829:42a86787d173

[xemacs-hg @ 2002-05-07 15:58:46 by stephent] fix kill-ring bug <87elgoufss.fsf_-_@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Tue, 07 May 2002 15:59:03 +0000
parents 943eaba38521
children f46864126a0d
comparison
equal deleted inserted replaced
828:4ead1e0842f0 829:42a86787d173
73 (or clip (error "there is no clipboard selection")) 73 (or clip (error "there is no clipboard selection"))
74 (push-mark) 74 (push-mark)
75 (insert clip)))) 75 (insert clip))))
76 76
77 (defun get-clipboard () 77 (defun get-clipboard ()
78 "Return text pasted to the clipboard." 78 "Return text pasted to the clipboard.
79 See `interprogram-paste-function' for more information."
79 (get-selection 'CLIPBOARD)) 80 (get-selection 'CLIPBOARD))
80 81
81 (define-device-method get-cutbuffer 82 (define-device-method get-cutbuffer
82 "Return the value of one of the cut buffers. 83 "Return the value of one of the cut buffers.
83 This will do nothing under anything other than X.") 84 This will do nothing under anything other than X.")
88 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule) 89 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
89 says how to convert the data. Returns NIL if there is no selection." 90 says how to convert the data. Returns NIL if there is no selection."
90 (condition-case nil (get-selection type data-type) (t nil))) 91 (condition-case nil (get-selection type data-type) (t nil)))
91 92
92 (defun get-selection (&optional type data-type) 93 (defun get-selection (&optional type data-type)
93 "Return the value of a window-system selection. 94 "Return the value of a window-system selection, or nil if XEmacs owns it.
94 The argument TYPE (default `PRIMARY') says which selection, 95 The argument TYPE (default `PRIMARY') says which selection,
95 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule) 96 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule)
96 says how to convert the data. If there is no selection an error is signalled." 97 says how to convert the data. If there is no selection an error is signalled.
98 See `interprogram-paste-function' for more information."
97 (or type (setq type 'PRIMARY)) 99 (or type (setq type 'PRIMARY))
98 (or data-type (setq data-type selected-text-type)) 100 (or data-type (setq data-type selected-text-type))
99 (let ((text 101 (if (consp data-type)
100 (if (consp data-type) 102 (condition-case err
101 (condition-case err 103 (get-selection-internal type (car data-type))
102 (get-selection-internal type (car data-type)) 104 (selection-conversion-error
103 (selection-conversion-error 105 (if (cdr data-type)
104 (if (cdr data-type) 106 (get-selection type (cdr data-type))
105 (get-selection type (cdr data-type)) 107 (signal (car err) (cdr err)))))
106 (signal (car err) (cdr err))))) 108 (get-selection-internal type data-type)))
107 (get-selection-internal type data-type))))
108 text))
109 109
110 ;; FSFmacs calls this `x-set-selection', and reverses the 110 ;; FSFmacs calls this `x-set-selection', and reverses the
111 ;; first two arguments (duh ...). This order is more logical. 111 ;; first two arguments (duh ...). This order is more logical.
112 (defun own-selection (data &optional type how-to-add data-type) 112 (defun own-selection (data &optional type how-to-add data-type)
113 "Make a window-system selection of type TYPE and value DATA. 113 "Make a window-system selection of type TYPE and value DATA.