aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-02-12 04:51:42 +0000
committerRichard M. Stallman1995-02-12 04:51:42 +0000
commite6c2f5d4b9ccae65782af0042fef3b14f6bbac8b (patch)
tree84bef7736d481b309d99580951680a4fd5fd5aa2
parent273e08292b75d93ed25f74f1ba3cbdd873e30339 (diff)
downloademacs-e6c2f5d4b9ccae65782af0042fef3b14f6bbac8b.tar.gz
emacs-e6c2f5d4b9ccae65782af0042fef3b14f6bbac8b.zip
(mouse-drag-region): Delete the overlay before
calling the terminating event's command binding or making a region. (mouse-set-region-1): New function. (mouse-drag-region, mouse-set-region, mouse-save-then-kill): Call it. (mouse-region-match): New function.
-rw-r--r--lisp/mouse.el33
1 files changed, 29 insertions, 4 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 276d67da286..04cdeafea70 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -292,6 +292,17 @@ This should be bound to a mouse click event type."
292 (if (numberp (posn-point posn)) 292 (if (numberp (posn-point posn))
293 (goto-char (posn-point posn))))) 293 (goto-char (posn-point posn)))))
294 294
295(defvar mouse-last-region-beg nil)
296(defvar mouse-last-region-end nil)
297(defvar mouse-last-region-tick nil)
298
299(defun mouse-region-match ()
300 "Return non-nil if there's an active region that was set with the mouse."
301 (and (mark t) mark-active
302 (eq mouse-last-region-beg (region-beginning))
303 (eq mouse-last-region-end (region-end))
304 (eq mouse-last-region-tick (buffer-modified-tick))))
305
295(defun mouse-set-region (click) 306(defun mouse-set-region (click)
296 "Set the region to the text dragged over, and copy to kill ring. 307 "Set the region to the text dragged over, and copy to kill ring.
297This should be bound to a mouse drag event." 308This should be bound to a mouse drag event."
@@ -313,7 +324,13 @@ This should be bound to a mouse drag event."
313 ;; Don't set this-command to kill-region, so that a following 324 ;; Don't set this-command to kill-region, so that a following
314 ;; C-w will not double the text in the kill ring. 325 ;; C-w will not double the text in the kill ring.
315 (let (this-command) 326 (let (this-command)
316 (copy-region-as-kill (mark) (point))))) 327 (copy-region-as-kill (mark) (point)))
328 (mouse-set-region-1)))
329
330(defun mouse-set-region-1 ()
331 (setq mouse-last-region-beg (region-beginning))
332 (setq mouse-last-region-end (region-end))
333 (setq mouse-last-region-tick (buffer-modified-tick)))
317 334
318(defvar mouse-scroll-delay 0.25 335(defvar mouse-scroll-delay 0.25
319 "*The pause between scroll steps caused by mouse drags, in seconds. 336 "*The pause between scroll steps caused by mouse drags, in seconds.
@@ -420,16 +437,22 @@ release the mouse button. Otherwise, it does not."
420 (if (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun)) 437 (if (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun))
421 (progn 438 (progn
422 (setq this-command fun) 439 (setq this-command fun)
440 ;; Delete the overlay before calling the function,
441 ;; because delete-overlay increases buffer-modified-tick.
442 (delete-overlay mouse-drag-overlay)
423 (funcall fun event)) 443 (funcall fun event))
424 (if (not (= (overlay-start mouse-drag-overlay) 444 (if (not (= (overlay-start mouse-drag-overlay)
425 (overlay-end mouse-drag-overlay))) 445 (overlay-end mouse-drag-overlay)))
426 (let (last-command this-command) 446 (let (last-command this-command)
427 (push-mark (overlay-start mouse-drag-overlay) t t) 447 (push-mark (overlay-start mouse-drag-overlay) t t)
428 (goto-char (overlay-end mouse-drag-overlay)) 448 (goto-char (overlay-end mouse-drag-overlay))
429 (copy-region-as-kill (point) (mark t))) 449 (delete-overlay mouse-drag-overlay)
450 (copy-region-as-kill (point) (mark t))
451 (mouse-set-region-1))
430 (goto-char (overlay-end mouse-drag-overlay)) 452 (goto-char (overlay-end mouse-drag-overlay))
431 (setq this-command 'mouse-set-point))))) 453 (setq this-command 'mouse-set-point)
432 (delete-overlay mouse-drag-overlay)))) 454 (delete-overlay mouse-drag-overlay))))
455 (delete-overlay mouse-drag-overlay)))))
433 456
434;; Commands to handle xterm-style multiple clicks. 457;; Commands to handle xterm-style multiple clicks.
435 458
@@ -644,6 +667,7 @@ If you do this twice in the same position, the selection is killed."
644 ;; Replace it with the extended region. 667 ;; Replace it with the extended region.
645 ;; (It would be annoying to make a separate entry.) 668 ;; (It would be annoying to make a separate entry.)
646 (kill-new (buffer-substring (point) (mark t)) t) 669 (kill-new (buffer-substring (point) (mark t)) t)
670 (mouse-set-region-1)
647 ;; Arrange for a repeated mouse-3 to kill this region. 671 ;; Arrange for a repeated mouse-3 to kill this region.
648 (setq mouse-save-then-kill-posn 672 (setq mouse-save-then-kill-posn
649 (list (car kill-ring) (point) click-posn)) 673 (list (car kill-ring) (point) click-posn))
@@ -690,6 +714,7 @@ If you do this twice in the same position, the selection is killed."
690 (exchange-point-and-mark) 714 (exchange-point-and-mark)
691 (kill-ring-save (point) (mark t))) 715 (kill-ring-save (point) (mark t)))
692 (mouse-show-mark) 716 (mouse-show-mark)
717 (mouse-set-region-1)
693 (setq mouse-save-then-kill-posn 718 (setq mouse-save-then-kill-posn
694 (list (car kill-ring) (point) click-posn))))))) 719 (list (car kill-ring) (point) click-posn)))))))
695 720