changeset 41033:0701d564260d

(mouse-show-mark): Either move point to the mark or use highlighting, never both. (mouse-buffer-menu): If WINDOW is a frame, select its selected window.
author Richard M. Stallman <rms@gnu.org>
date Wed, 14 Nov 2001 02:48:17 +0000
parents ef8a5e50dbe8
children edd3baa8e385
files lisp/mouse.el
diffstat 1 files changed, 54 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mouse.el	Wed Nov 14 00:09:27 2001 +0000
+++ b/lisp/mouse.el	Wed Nov 14 02:48:17 2001 +0000
@@ -953,56 +953,57 @@
 (defun mouse-show-mark ()
   (if transient-mark-mode
       (delete-overlay mouse-drag-overlay)
-    (let ((inhibit-quit t)
-	  (echo-keystrokes 0)
-	  event events key ignore
-	  x-lost-selection-hooks)
-      (add-hook 'x-lost-selection-hooks
-		(lambda (seltype)
-		  (if (eq seltype 'PRIMARY)
-		      (progn (setq ignore t)
-			     (throw 'mouse-show-mark t)))))
-      (move-overlay mouse-drag-overlay (point) (mark t))
-      (catch 'mouse-show-mark
-	;; In this loop, execute scroll bar and switch-frame events.
-	;; Also ignore down-events that are undefined.
-	(while (progn (setq event (read-event))
-		      (setq events (append events (list event)))
-		      (setq key (apply 'vector events))
-		      (or (and (consp event)
-			       (eq (car event) 'switch-frame))
-			  (and (consp event)
-			       (eq (posn-point (event-end event))
-				   'vertical-scroll-bar))
-			  (and (memq 'down (event-modifiers event))
-			       (not (key-binding key))
-			       (not (mouse-undouble-last-event events))
-			       (not (member key mouse-region-delete-keys)))))
-	  (and (consp event)
-	       (or (eq (car event) 'switch-frame)
-		   (eq (posn-point (event-end event))
-		       'vertical-scroll-bar))
-	       (let ((keys (vector 'vertical-scroll-bar event)))
-		 (and (key-binding keys)
-		      (progn
-			(call-interactively (key-binding keys)
-					    nil keys)
-			(setq events nil)))))))
-      ;; If we lost the selection, just turn off the highlighting.
-      (if ignore
-	  nil
-	;; For certain special keys, delete the region.
-	(if (member key mouse-region-delete-keys)
-	    (delete-region (overlay-start mouse-drag-overlay)
-			   (overlay-end mouse-drag-overlay))
-	  ;; Otherwise, unread the key so it gets executed normally.
-	  (setq unread-command-events
-		(nconc events unread-command-events))))
-      (setq quit-flag nil)
-      (delete-overlay mouse-drag-overlay))
-    (save-excursion
-      (goto-char (mark t))
-      (sit-for 1))))
+    (if (not (display-graphic-p))
+	(save-excursion
+	  (goto-char (mark t))
+	  (sit-for 1))
+      (let ((inhibit-quit t)
+	    (echo-keystrokes 0)
+	    event events key ignore
+	    x-lost-selection-hooks)
+	(add-hook 'x-lost-selection-hooks
+		  (lambda (seltype)
+		    (if (eq seltype 'PRIMARY)
+			(progn (setq ignore t)
+			       (throw 'mouse-show-mark t)))))
+	(move-overlay mouse-drag-overlay (point) (mark t))
+	(catch 'mouse-show-mark
+	  ;; In this loop, execute scroll bar and switch-frame events.
+	  ;; Also ignore down-events that are undefined.
+	  (while (progn (setq event (read-event))
+			(setq events (append events (list event)))
+			(setq key (apply 'vector events))
+			(or (and (consp event)
+				 (eq (car event) 'switch-frame))
+			    (and (consp event)
+				 (eq (posn-point (event-end event))
+				     'vertical-scroll-bar))
+			    (and (memq 'down (event-modifiers event))
+				 (not (key-binding key))
+				 (not (mouse-undouble-last-event events))
+				 (not (member key mouse-region-delete-keys)))))
+	    (and (consp event)
+		 (or (eq (car event) 'switch-frame)
+		     (eq (posn-point (event-end event))
+			 'vertical-scroll-bar))
+		 (let ((keys (vector 'vertical-scroll-bar event)))
+		   (and (key-binding keys)
+			(progn
+			  (call-interactively (key-binding keys)
+					      nil keys)
+			  (setq events nil)))))))
+	;; If we lost the selection, just turn off the highlighting.
+	(if ignore
+	    nil
+	  ;; For certain special keys, delete the region.
+	  (if (member key mouse-region-delete-keys)
+	      (delete-region (overlay-start mouse-drag-overlay)
+			     (overlay-end mouse-drag-overlay))
+	    ;; Otherwise, unread the key so it gets executed normally.
+	    (setq unread-command-events
+		  (nconc events unread-command-events))))
+	(setq quit-flag nil)
+	(delete-overlay mouse-drag-overlay)))))
 
 (defun mouse-set-mark (click)
   "Set mark at the position clicked on with the mouse.
@@ -1606,7 +1607,9 @@
     (let ((buf (x-popup-menu event menu))
 	  (window (posn-window (event-start event))))
       (when buf
-	    (or (framep window) (select-window window))
+	(select-window
+	 (if (framep window) (frame-selected-window window)
+	   window))
 	(switch-to-buffer buf)))))
 
 (defun mouse-buffer-menu-alist (buffers)