diff lisp/mouse.el @ 103893:c75839749e65

* simple.el (deactivate-mark): Optional argument FORCE. (set-mark): Use deactivate-mark. * info.el (Info-search): No need to check transient-mark-mode before calling deactivate-mark. * select.el (x-set-selection): Doc fix. (x-valid-simple-selection-p): Allow buffer values. (xselect--selection-bounds): Handle buffer values. Suggested by David De La Harpe Golden. * mouse.el (mouse-set-region, mouse-drag-track): Call copy-region-as-kill before setting the mark, to let select-active-regions work. * simple.el (deactivate-mark): If select-active-regions is non-nil, copy the selection data into a string. (activate-mark): If select-active-regions is non-nil, set the selection to the current buffer. (set-mark): Update selection if select-active-regions is non-nil. * select.el (x-valid-simple-selection-p): Allow buffer values.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 15 Jul 2009 01:25:32 +0000
parents c65ecdf80c27
children 37177e1f2fcb
line wrap: on
line diff
--- a/lisp/mouse.el	Tue Jul 14 19:57:58 2009 +0000
+++ b/lisp/mouse.el	Wed Jul 15 01:25:32 2009 +0000
@@ -681,26 +681,26 @@
 This should be bound to a mouse drag event."
   (interactive "e")
   (mouse-minibuffer-check click)
-  (let ((posn (event-start click))
-	(end (event-end click)))
-    (select-window (posn-window posn))
-    (if (numberp (posn-point posn))
-	(goto-char (posn-point posn)))
-    ;; If mark is highlighted, no need to bounce the cursor.
-    ;; On X, we highlight while dragging, thus once again no need to bounce.
+  (select-window (posn-window (event-start click)))
+  (let ((beg (posn-point (event-start click)))
+	(end (posn-point (event-end click))))
+    (and mouse-drag-copy-region (integerp beg) (integerp end)
+	 ;; Don't set this-command to `kill-region', so a following
+	 ;; C-w won't double the text in the kill ring.  Ignore
+	 ;; `last-command' so we don't append to a preceding kill.
+	 (let (this-command last-command deactivate-mark)
+	   (copy-region-as-kill beg end)))
+    (if (numberp beg) (goto-char beg))
+    ;; On a text terminal, bounce the cursor.
     (or transient-mark-mode
-	(memq (framep (selected-frame)) '(x pc w32 ns))
+	(window-system)
 	(sit-for 1))
     (push-mark)
+    ;; If `select-active-regions' is non-nil, `set-mark' sets the
+    ;; primary selection to the buffer's region, overriding the role
+    ;; of `copy-region-as-kill'; that's why we did the copy first.
     (set-mark (point))
-    (if (numberp (posn-point end))
-	(goto-char (posn-point end)))
-    ;; Don't set this-command to kill-region, so that a following
-    ;; C-w will not double the text in the kill ring.
-    ;; Ignore last-command so we don't append to a preceding kill.
-    (when mouse-drag-copy-region
-      (let (this-command last-command deactivate-mark)
-	(copy-region-as-kill (mark) (point))))
+    (if (numberp end) (goto-char end))
     (mouse-set-region-1)))
 
 (defun mouse-set-region-1 ()
@@ -1046,15 +1046,19 @@
 			      (overlay-start mouse-drag-overlay))
 			   region-termination))
 		       last-command this-command)
+		  ;; We copy the region before setting the mark so
+		  ;; that `select-active-regions' can override
+		  ;; `copy-region-as-kill'.
+		  (and mouse-drag-copy-region
+		       do-mouse-drag-region-post-process
+		       (let (deactivate-mark)
+			 (copy-region-as-kill region-commencement
+					      region-termination)))
 		  (push-mark region-commencement t t)
 		  (goto-char region-termination)
 		  (if (not do-mouse-drag-region-post-process)
 		      ;; Skip all post-event handling, return immediately.
 		      (delete-overlay mouse-drag-overlay)
-		    ;; Don't let copy-region-as-kill set deactivate-mark.
-		    (when mouse-drag-copy-region
-		      (let (deactivate-mark)
-			(copy-region-as-kill (point) (mark t))))
 		    (let ((buffer (current-buffer)))
 		      (mouse-show-mark)
 		      ;; mouse-show-mark can call read-event,
@@ -1697,9 +1701,7 @@
     (with-current-buffer (overlay-buffer mouse-secondary-overlay)
       (kill-region (overlay-start mouse-secondary-overlay)
 		   (overlay-end mouse-secondary-overlay))))
-  (delete-overlay mouse-secondary-overlay)
-;;;  (x-set-selection 'SECONDARY nil)
-  )
+  (delete-overlay mouse-secondary-overlay))
 
 (defun mouse-secondary-save-then-kill (click)
   "Save text to point in kill ring; the second time, kill the text.