>>>> "Mike" == Mike Alexander
<mta(a)arbortext.com> writes:
Mike> I also don't understand why get-selection-internal returns
Mike> nil if and only if select-coerce doesn't change the
Mike> selection get-selection-internal found in the local cache.
If it changes, we can't ignore it; in principle select-coerce could do
things like apply `string-to-int' or even `read' to the selection text.
[...]
Mike> That makes get-selection and get-clipboard both return nil
Mike> which makes yank-clipboard-selection fail.
Sounds to me like get-clipboard is broken, then, in the sense that
what we need it to do here doesn't conform to the definition of
interprogram-paste-function.
Yup; this patch works for me on X11, and simply adding
(setq interprogram-paste-function 'get-clipboard)
to the init file reverts to old broken-on-X11 behavior in case this
doesn't quite do it for you somehow. Please let me know if you have
problems, but this is good enough for 21.4.8.
Index: lisp/simple.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/simple.el,v
retrieving revision 1.31.2.1
diff -u -u -r1.31.2.1 simple.el
--- lisp/simple.el 2001/05/09 09:53:52 1.31.2.1
+++ lisp/simple.el 2002/05/09 07:06:46
@@ -1222,7 +1222,9 @@
The first argument, TEXT, is a string containing
the text which should be made available.
The second, PUSH, if non-nil means this is a \"new\" kill;
-nil means appending to an \"old\" kill."
+nil means appending to an \"old\" kill.
+
+One reasonable choice is `own-clipboard' (the default)."
:type '(radio (function-item :tag "Send to Clipboard"
:format "%t\n"
own-clipboard)
@@ -1230,7 +1232,7 @@
(function :tag "Other"))
:group 'killing)
-(defcustom interprogram-paste-function 'get-clipboard
+(defcustom interprogram-paste-function 'get-clipboard-foreign
"Function to call to get text cut from other programs.
Most window systems provide some sort of facility for cutting and
@@ -1248,10 +1250,13 @@
most recent string, the function should return nil. If it is
difficult to tell whether Emacs or some other program provided the
current string, it is probably good enough to return nil if the string
-is equal (according to `string=') to the last text Emacs provided."
+is equal (according to `string=') to the last text Emacs provided.
+
+Reasonable choices include `get-clipboard-foreign' (the default), and
+functions calling `get-selection-foreign' (q.v.)."
:type '(radio (function-item :tag "Get from Clipboard"
:format "%t\n"
- get-clipboard)
+ get-clipboard-foreign)
(const :tag "None" nil)
(function :tag "Other"))
:group 'killing)
Index: lisp/select.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/select.el,v
retrieving revision 1.7
diff -u -u -r1.7 select.el
--- lisp/select.el 2001/04/12 18:21:35 1.7
+++ lisp/select.el 2002/05/09 07:06:46
@@ -69,15 +69,23 @@
(when (console-on-window-system-p)
(setq last-command nil)
(setq this-command 'yank) ; so that yank-pop works.
- (let ((clip (get-clipboard)))
- (or clip (error "there is no clipboard selection"))
+ (let ((clip (cond ((selection-owner-p 'CLIPBOARD)
+ (current-kill 0))
+ ((get-clipboard))
+ (t (error "there is no clipboard selection")))))
(push-mark)
(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.")
@@ -93,19 +101,27 @@
"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 as `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.
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
My nostalgia for Icon makes me forget about any of the bad things. I don't
have much nostalgia for Perl, so its faults I remember. Scott Gilbert c.l.py