X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=lisp%2Fselect.el;h=b185dea27388e587421a9d364dc7407e1aa8e280;hp=479e548b4447106676f60c3556d091a3b1efaf55;hb=eeca41d3213b7a3b7efcf6508693e748c1590748;hpb=59eec5f21669e81977b5b1fe9bf717cab49cf7fb diff --git a/lisp/select.el b/lisp/select.el index 479e548..b185dea 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -20,7 +20,7 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with XEmacs; see the file COPYING. If not, write to the +;; along with XEmacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. @@ -28,7 +28,7 @@ ;;; Commentary: -;; This file is dumped with XEmacs +;; This file is dumped with XEmacs ;;; Code: @@ -40,7 +40,7 @@ COMPOUND_TEXT and STRING are the most commonly used data types. If a list is provided, the types are tried in sequence until there is a successful conversion.") -(defvar selection-sets-clipboard nil +(defvar selection-sets-clipboard nil "Controls the selection's relationship to the clipboard. When non-nil, any operation that sets the primary selection will also set the clipboard.") @@ -75,9 +75,15 @@ set the clipboard.") (insert clip)))) (defun get-clipboard () - "Return text pasted to the clipboard." + "Return text pasted to the clipboard. +Not suitable for `interprogram-paste-function', use `get-clipboard-foreign'." (get-selection 'CLIPBOARD)) +(defun get-clipboard-foreign () + "Return text pasted to the clipboard by another program. +See `interprogram-paste-function' for more information." + (get-selection-foreign 'CLIPBOARD)) + (define-device-method get-cutbuffer "Return the value of one of the cut buffers. This will do nothing under anything other than X.") @@ -86,26 +92,34 @@ This will do nothing under anything other than X.") "Return the value of a window-system selection. The argument TYPE (default `PRIMARY') says which selection, and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule) -says how to convert the data. Returns NIL if there is no selection" +says how to convert the data. Returns NIL if there is no selection." (condition-case nil (get-selection type data-type) (t nil))) (defun get-selection (&optional type data-type) "Return the value of a window-system selection. The argument TYPE (default `PRIMARY') says which selection, and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule) -says how to convert the data. If there is no selection an error is signalled." +says how to convert the data. If there is no selection an error is signalled. +Not suitable in a `interprogram-paste-function', q.v." (or type (setq type 'PRIMARY)) (or data-type (setq data-type selected-text-type)) - (let ((text - (if (consp data-type) - (condition-case err - (get-selection-internal type (car data-type)) - (selection-conversion-error - (if (cdr data-type) - (get-selection type (cdr data-type)) - (signal (car err) (cdr err))))) - (get-selection-internal type data-type)))) - text)) + (if (consp data-type) + (condition-case err + (get-selection-internal type (car data-type)) + (selection-conversion-error + (if (cdr data-type) + (get-selection type (cdr data-type)) + (signal (car err) (cdr err))))) + (get-selection-internal type data-type))) + +(defun get-selection-foreign (&optional type data-type) + "Return the value of a window-system selection, or nil if XEmacs owns it. +The argument TYPE (default `PRIMARY') says which selection, +and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule) +says how to convert the data. If there is no selection an error is signalled. +See `interprogram-paste-function' for more information." + (unless (selection-owner-p type) + (get-selection type data-type))) ;; FSFmacs calls this `x-set-selection', and reverses the ;; first two arguments (duh ...). This order is more logical. @@ -196,8 +210,9 @@ See `interprogram-cut-function' for more information." (own-selection string 'CLIPBOARD)) (defun disown-selection (&optional secondary-p) - "Assuming we own the selection, disown it. With an argument, discard the -secondary selection instead of the primary selection." + "Assuming we own the selection, disown it. +With an argument, discard the secondary selection instead of the +primary selection." (disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY)) (when (and selection-sets-clipboard (or (not secondary-p) @@ -623,7 +638,7 @@ nil if this is impossible, or a suitable representation otherwise." (defun select-convert-from-integer (selection type value) (cond ((integerp value) ; Integer value) - + ((and (consp value) ; (integer . integer) (integerp (car value)) (integerp (cdr value))) @@ -633,7 +648,7 @@ nil if this is impossible, or a suitable representation otherwise." (< (cdr value) 0)) (cdr value) value))) - + ((and (listp value) ; (integer integer) (eq (length value) 2) (integerp (car value)) @@ -644,21 +659,21 @@ nil if this is impossible, or a suitable representation otherwise." (< (cdr value) 0)) (- (cadr value)) (cons (car value) (cadr value))))) - + ((listp value) ; list (if (cdr value) (mapcar '(lambda (x) (select-convert-from-integer selection type x)) value) (select-convert-from-integer selection type (car value)))) - + ((vectorp value) ; vector (if (eq (length value) 1) (select-convert-from-integer selection type (aref value 0)) (mapvector '(lambda (x) (select-convert-from-integer selection type x)) value))) - + (t nil) )) @@ -740,7 +755,7 @@ nil if this is impossible, or a suitable representation otherwise." (defun select-buffer-killed-text (selection type value buffer) (select-buffer-killed-default selection type value buffer)) - + ;; Types listed in here can be selections of XEmacs (setq selection-converter-out-alist '((TEXT . select-convert-to-text)