aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/mouse.el
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1993-06-18 17:59:02 +0000
committerRichard M. Stallman <[email protected]>1993-06-18 17:59:02 +0000
commit230aaa738ffb8825fc1e6db933154dc5d92c1334 (patch)
tree64ea9550da81cc804b905c2015829402f0be93c6 /lisp/mouse.el
parent50f747444d3ab08689730d5b7b11b80108e2ab1c (diff)
(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.
Diffstat (limited to 'lisp/mouse.el')
-rw-r--r--lisp/mouse.el63
1 files changed, 35 insertions, 28 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 51f05e31b5..7a712e2093 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -274,15 +274,16 @@ Use \\[mouse-secondary-save-then-kill] to set the other end
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 @@ This must be bound to a mouse drag event."
(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 @@ which prepares for a second click to delete the text."
(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.