I think I have fixed this to suit most people.
under mswindows the clipboard is only set/got when requested.
button2 pastes the clipboard as a fallback after primary selection and
cutbuffer.
you can optionally make the selection set the clipboard - but it is off by
default.
I will apply this to cvs.
andy
1999-06-10 Andy Piper <andy(a)xemacs.org>
* select-msw.c (mswindows_own_selection): only set the clipboard
if asked.
(mswindows_get_foreign_selection): only get the clipboard if
asked.
(mswindows_disown_selection): only disown the clipboard if asked.
1999-06-10 Andy Piper <andy(a)xemacs.org>
* select.el (get-selection): abstract out non error-signalling
part.
(get-selection-no-error): get-selection without signalling an
error.
(selection-is-clipboard-p): new variable. controls whether the
selection sets the clipboard.
(own-selection): use it.
* mouse.el (insert-selection): fallback to clipboard after trying
primary selection and cutbuffer.
1999-06-05 Andy Piper <andy(a)xemacs.org>
* x-select.el (xselect-kill-buffer-hook-1): use generalised
selection functions.
Index: lisp/select.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/select.el,v
retrieving revision 1.5.2.3
diff -u -r1.5.2.3 select.el
--- select.el 1999/05/22 23:02:59 1.5.2.3
+++ select.el 1999/06/10 11:59:39
@@ -40,6 +40,11 @@
If a list is provided, the types are tried in sequence until
there is a successful conversion.")
+(defvar selection-is-clipboard-p nil
+ "Controls the selection's relationship to the clipboard.
+When non-nil, any operation that sets the primary selection will also
+set the clipboard.")
+
(defun copy-primary-selection ()
"Copy the selection to the Clipboard and the kill ring."
(interactive)
@@ -73,8 +78,18 @@
(defun get-selection (&optional type data-type)
"Return the value of a Windows 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."
+ (let ((text (get-selection-no-error type data-type)))
+ (when (not (stringp text))
+ (error "Selection is not a string: %S" text))
+ text))
+
+(defun get-selection-no-error (&optional type data-type)
+ "Return the value of a Windows 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."
+says how to convert the data. Returns NIL if there is no selection"
(or type (setq type 'PRIMARY))
(or data-type (setq data-type selected-text-type))
(let ((text
@@ -88,8 +103,6 @@
(get-selection-internal type data-type))))
(when (and (consp text) (symbolp (car text)))
(setq text (cdr text)))
- (when (not (stringp text))
- (error "Selection is not a string: %S" text))
text))
;; FSFmacs calls this `x-set-selection', and reverses the
@@ -127,9 +140,12 @@
valid))
(signal 'error (list "invalid selection" data)))
(or type (setq type 'PRIMARY))
- (if data
- (own-selection-internal type data)
- (disown-selection-internal type))
+ (if (null data)
+ (disown-selection-internal type)
+ (own-selection-internal type data)
+ (when (and (eq type 'PRIMARY)
+ selection-is-clipboard-p)
+ (own-selection-internal 'CLIPBOARD data)))
(cond ((eq type 'PRIMARY)
(setq primary-selection-extent
(select-make-extent-for-selection
Index: lisp/mouse.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mouse.el,v
retrieving revision 1.19.2.4
diff -u -r1.19.2.4 mouse.el
--- mouse.el 1999/05/22 23:02:58 1.19.2.4
+++ mouse.el 1999/06/10 11:59:46
@@ -114,11 +114,14 @@
(defun insert-selection (&optional check-cutbuffer-p move-point-event)
"Insert the current selection into buffer at point."
(interactive "P")
+ ;; we fallback to the clipboard if the current selection is not existent
(let ((text (if check-cutbuffer-p
- (or (condition-case () (get-selection) (error ()))
+ (or (get-selection-no-error)
(get-cutbuffer)
- (error "No selection or cut buffer available"))
- (get-selection))))
+ (get-selection-no-error 'CLIPBOARD)
+ (error "No selection, clipboard or cut buffer available"))
+ (or (get-selection-no-error)
+ (get-selection 'CLIPBOARD)))))
(cond (move-point-event
(mouse-set-point move-point-event)
(push-mark (point)))
Index: src/select-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/select-msw.c,v
retrieving revision 1.7.2.1
diff -u -r1.7.2.1 select-msw.c
--- select-msw.c 1999/05/22 23:03:07 1.7.2.1
+++ select-msw.c 1999/06/10 11:59:46
@@ -101,7 +101,10 @@
Lisp_Object converted_value = get_local_selection (selection_name, QSTRING);
if (!NILP (converted_value) &&
CONSP (converted_value) &&
- EQ (XCAR (converted_value), QSTRING))
+ EQ (XCAR (converted_value), QSTRING) &&
+ /* pure mswindows behaviour only says we can own the selection
+ if it is the clipboard */
+ EQ (selection_name, QCLIPBOARD))
Fmswindows_set_clipboard (XCDR (converted_value));
return Qnil;
@@ -162,7 +165,10 @@
static Lisp_Object
mswindows_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
{
- return Fmswindows_get_clipboard ();
+ if (EQ (selection_symbol, QCLIPBOARD))
+ return Fmswindows_get_clipboard ();
+ else
+ return Qnil;
}
DEFUN ("mswindows-selection-exists-p", Fmswindows_selection_exists_p, 0, 0, 0, /*
@@ -184,7 +190,8 @@
static void
mswindows_disown_selection (Lisp_Object selection, Lisp_Object timeval)
{
- Fmswindows_delete_selection ();
+ if (EQ (selection, QCLIPBOARD))
+ Fmswindows_delete_selection ();
}
--------------------------------------------------------------
Dr Andy Piper
Senior Consultant Architect, BEA Systems Ltd