aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-06-18 17:59:02 +0000
committerRichard M. Stallman1993-06-18 17:59:02 +0000
commit230aaa738ffb8825fc1e6db933154dc5d92c1334 (patch)
tree64ea9550da81cc804b905c2015829402f0be93c6
parent50f747444d3ab08689730d5b7b11b80108e2ab1c (diff)
downloademacs-230aaa738ffb8825fc1e6db933154dc5d92c1334.tar.gz
emacs-230aaa738ffb8825fc1e6db933154dc5d92c1334.zip
(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.
-rw-r--r--lisp/mouse.el63
1 files changed, 35 insertions, 28 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 51f05e31b5d..7a712e20930 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -274,15 +274,16 @@ Use \\[mouse-secondary-save-then-kill] to set the other end
274and complete the secondary selection." 274and complete the secondary selection."
275 (interactive "e") 275 (interactive "e")
276 (let ((posn (event-start click))) 276 (let ((posn (event-start click)))
277 (select-window (posn-window posn)) 277 (save-excursion
278 ;; Cancel any preexisting secondary selection. 278 (set-buffer (window-buffer (posn-window posn)))
279 (if mouse-secondary-overlay 279 ;; Cancel any preexisting secondary selection.
280 (delete-overlay mouse-secondary-overlay)) 280 (if mouse-secondary-overlay
281 (if (numberp (posn-point posn)) 281 (delete-overlay mouse-secondary-overlay))
282 (progn 282 (if (numberp (posn-point posn))
283 (or mouse-secondary-start 283 (progn
284 (setq mouse-secondary-start (make-marker))) 284 (or mouse-secondary-start
285 (move-marker mouse-secondary-start (posn-point posn)))))) 285 (setq mouse-secondary-start (make-marker)))
286 (move-marker mouse-secondary-start (posn-point posn)))))))
286 287
287(defun mouse-set-secondary (click) 288(defun mouse-set-secondary (click)
288 "Set the secondary selection to the text that the mouse is dragged over. 289 "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."
291 (let ((posn (event-start click)) 292 (let ((posn (event-start click))
292 beg 293 beg
293 (end (event-end click))) 294 (end (event-end click)))
294 (select-window (posn-window posn)) 295 (save-excursion
295 (if (numberp (posn-point posn)) 296 (set-buffer (window-buffer (posn-window posn)))
296 (setq beg (posn-point posn))) 297 (if (numberp (posn-point posn))
297 (if mouse-secondary-overlay 298 (setq beg (posn-point posn)))
298 (move-overlay mouse-secondary-overlay beg (posn-point end)) 299 (if mouse-secondary-overlay
299 (setq mouse-secondary-overlay (make-overlay beg (posn-point end)))) 300 (move-overlay mouse-secondary-overlay beg (posn-point end))
300 (overlay-put mouse-secondary-overlay 'face 'secondary-selection))) 301 (setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
302 (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
301 303
302(defun mouse-drag-secondary (click) 304(defun mouse-drag-secondary (click)
303 "Set the secondary selection to the text that the mouse is dragged over. 305 "Set the secondary selection to the text that the mouse is dragged over.
304This must be bound to a button-down mouse event." 306This must be bound to a button-down mouse event."
305 (interactive "e") 307 (interactive "e")
306 (let ((posn (event-start click))) 308 (let ((posn (event-start click)))
307 (select-window (posn-window posn)) 309 (save-window-excursion
308 ;; Set point temporarily, so user sees where it is. 310 (select-window (posn-window posn))
309 (if (numberp (posn-point posn)) 311 ;; Set point temporarily, so user sees where it is.
310 (goto-char (posn-point posn))))) 312 (save-excursion
313 (if (numberp (posn-point posn))
314 (goto-char (posn-point posn)))
315 (setq unread-command-events
316 (cons (read-event) unread-command-events))))))
311 317
312(defun mouse-kill-secondary () 318(defun mouse-kill-secondary ()
313 "Kill the text in the secondary selection." 319 "Kill the text in the secondary selection."
@@ -346,14 +352,15 @@ which prepares for a second click to delete the text."
346 (cons (cons (car kill-ring) start) 352 (cons (cons (car kill-ring) start)
347 buffer-undo-list)))) 353 buffer-undo-list))))
348 ;; Otherwise, save this region. 354 ;; Otherwise, save this region.
349 (select-window (posn-window (event-start click))) 355 (save-excursion
350 (kill-ring-save start click-posn) 356 (set-buffer (window-buffer (posn-window (event-start click))))
351 (if mouse-secondary-overlay 357 (kill-ring-save start click-posn)
352 (move-overlay mouse-secondary-overlay start click-posn) 358 (if mouse-secondary-overlay
353 (setq mouse-secondary-overlay (make-overlay start click-posn))) 359 (move-overlay mouse-secondary-overlay start click-posn)
354 (overlay-put mouse-secondary-overlay 'face 'secondary-selection) 360 (setq mouse-secondary-overlay (make-overlay start click-posn)))
355 (setq mouse-save-then-kill-posn 361 (overlay-put mouse-secondary-overlay 'face 'secondary-selection)
356 (list (car kill-ring) start click-posn))))) 362 (setq mouse-save-then-kill-posn
363 (list (car kill-ring) start click-posn))))))
357 364
358(defun mouse-buffer-menu (event) 365(defun mouse-buffer-menu (event)
359 "Pop up a menu of buffers for selection with the mouse. 366 "Pop up a menu of buffers for selection with the mouse.