changeset 3823:7747dabf897f

(mouse-secondary-save-then-kill): Don't switch windows. Just set-buffer, and put save-excursion around it. (mouse-set-secondary, mouse-start-secondary): Likewise. (mouse-drag-secondary): Switch windows and move point just temporarily.
author Richard M. Stallman <rms@gnu.org>
date Fri, 18 Jun 1993 17:59:02 +0000
parents 242b72c42f33
children d7069bd44885
files lisp/mouse.el
diffstat 1 files changed, 35 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mouse.el	Fri Jun 18 17:55:42 1993 +0000
+++ b/lisp/mouse.el	Fri Jun 18 17:59:02 1993 +0000
@@ -274,15 +274,16 @@
 and complete the secondary selection."
   (interactive "e")
   (let ((posn (event-start click)))
-    (select-window (posn-window posn))
-    ;; Cancel any preexisting secondary selection.
-    (if mouse-secondary-overlay
-	(delete-overlay mouse-secondary-overlay))
-    (if (numberp (posn-point posn))
-	(progn
-	  (or mouse-secondary-start
-	      (setq mouse-secondary-start (make-marker)))
-	  (move-marker mouse-secondary-start (posn-point posn))))))
+    (save-excursion
+      (set-buffer (window-buffer (posn-window posn)))
+      ;; Cancel any preexisting secondary selection.
+      (if mouse-secondary-overlay
+	  (delete-overlay mouse-secondary-overlay))
+      (if (numberp (posn-point posn))
+	  (progn
+	    (or mouse-secondary-start
+		(setq mouse-secondary-start (make-marker)))
+	    (move-marker mouse-secondary-start (posn-point posn)))))))
 
 (defun mouse-set-secondary (click)
   "Set the secondary selection to the text that the mouse is dragged over.
@@ -291,23 +292,28 @@
   (let ((posn (event-start click))
 	beg
 	(end (event-end click)))
-    (select-window (posn-window posn))
-    (if (numberp (posn-point posn))
-	(setq beg (posn-point posn)))
-    (if mouse-secondary-overlay
-	(move-overlay mouse-secondary-overlay beg (posn-point end))
-      (setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
-    (overlay-put mouse-secondary-overlay 'face 'secondary-selection)))
+    (save-excursion
+      (set-buffer (window-buffer (posn-window posn)))
+      (if (numberp (posn-point posn))
+	  (setq beg (posn-point posn)))
+      (if mouse-secondary-overlay
+	  (move-overlay mouse-secondary-overlay beg (posn-point end))
+	(setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
+      (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
 
 (defun mouse-drag-secondary (click)
   "Set the secondary selection to the text that the mouse is dragged over.
 This must be bound to a button-down mouse event."
   (interactive "e")
   (let ((posn (event-start click)))
-    (select-window (posn-window posn))
-    ;; Set point temporarily, so user sees where it is.
-    (if (numberp (posn-point posn))
-	(goto-char (posn-point posn)))))
+    (save-window-excursion
+      (select-window (posn-window posn))
+      ;; Set point temporarily, so user sees where it is.
+      (save-excursion
+	(if (numberp (posn-point posn))
+	    (goto-char (posn-point posn)))
+	(setq unread-command-events
+	      (cons (read-event) unread-command-events))))))
 
 (defun mouse-kill-secondary ()
   "Kill the text in the secondary selection."
@@ -346,14 +352,15 @@
 		    (cons (cons (car kill-ring) start)
 			  buffer-undo-list))))
       ;; Otherwise, save this region.
-      (select-window (posn-window (event-start click)))
-      (kill-ring-save start click-posn)
-      (if mouse-secondary-overlay
-	  (move-overlay mouse-secondary-overlay start click-posn)
-	(setq mouse-secondary-overlay (make-overlay start click-posn)))
-      (overlay-put mouse-secondary-overlay 'face 'secondary-selection)
-      (setq mouse-save-then-kill-posn
-	    (list (car kill-ring) start click-posn)))))
+      (save-excursion
+	(set-buffer (window-buffer (posn-window (event-start click))))
+	(kill-ring-save start click-posn)
+	(if mouse-secondary-overlay
+	    (move-overlay mouse-secondary-overlay start click-posn)
+	  (setq mouse-secondary-overlay (make-overlay start click-posn)))
+	(overlay-put mouse-secondary-overlay 'face 'secondary-selection)
+	(setq mouse-save-then-kill-posn
+	      (list (car kill-ring) start click-posn))))))
 
 (defun mouse-buffer-menu (event)
   "Pop up a menu of buffers for selection with the mouse.