aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ.D. Smith2006-01-03 17:08:51 +0000
committerJ.D. Smith2006-01-03 17:08:51 +0000
commitf1c4f757fd012902543941c40988fe33a4f33292 (patch)
tree411d6ef9db799af5803bb27d2d364d662eae1abc
parent1c360af385c24ff34a1adb217e3d134cb8285782 (diff)
downloademacs-f1c4f757fd012902543941c40988fe33a4f33292.tar.gz
emacs-f1c4f757fd012902543941c40988fe33a4f33292.zip
(mouse-drag-track): Renamed, from `mouse-drag-region-1'. Includes
optional argument required to enable post-drag event processing (e.g. delete region keys). Can be used without this argument to track a mouse region and operate on it as soon as the drag completes. (mouse-drag-region): Use `mouse-drag-track'.
-rw-r--r--lisp/mouse.el93
1 files changed, 52 insertions, 41 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index ef655ba836f..e772858b3c7 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -765,7 +765,7 @@ If the click is in the echo area, display the `*Messages*' buffer."
765 (display-buffer (current-buffer))) 765 (display-buffer (current-buffer)))
766 ;; Give temporary modes such as isearch a chance to turn off. 766 ;; Give temporary modes such as isearch a chance to turn off.
767 (run-hooks 'mouse-leave-buffer-hook) 767 (run-hooks 'mouse-leave-buffer-hook)
768 (mouse-drag-region-1 start-event)))) 768 (mouse-drag-track start-event t))))
769 769
770 770
771(defun mouse-on-link-p (pos) 771(defun mouse-on-link-p (pos)
@@ -865,7 +865,12 @@ at the same position."
865 (let ((range (mouse-start-end start end mode))) 865 (let ((range (mouse-start-end start end mode)))
866 (move-overlay ol (car range) (nth 1 range)))) 866 (move-overlay ol (car range) (nth 1 range))))
867 867
868(defun mouse-drag-region-1 (start-event) 868(defun mouse-drag-track (start-event &optional
869 do-mouse-drag-region-post-process)
870 "Track mouse drags by highlighting area between point and cursor.
871The region will be defined with mark and point, and the overlay
872will be deleted after return. DO-MOUSE-DRAG-REGION-POST-PROCESS
873should only be used by mouse-drag-region."
869 (mouse-minibuffer-check start-event) 874 (mouse-minibuffer-check start-event)
870 (setq mouse-selection-click-count-buffer (current-buffer)) 875 (setq mouse-selection-click-count-buffer (current-buffer))
871 (let* ((original-window (selected-window)) 876 (let* ((original-window (selected-window))
@@ -949,12 +954,15 @@ at the same position."
949 (integer-or-marker-p end-point)) 954 (integer-or-marker-p end-point))
950 (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count)) 955 (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count))
951 956
957 ;; Handle the terminating event
952 (if (consp event) 958 (if (consp event)
953 (let* ((fun (key-binding (vector (car event)))) 959 (let* ((fun (key-binding (vector (car event))))
954 (do-multi-click (and (> (event-click-count event) 0) 960 (do-multi-click (and (> (event-click-count event) 0)
955 (functionp fun) 961 (functionp fun)
956 (not (memq fun '(mouse-set-point mouse-set-region)))))) 962 (not (memq fun
957 ;; Run the binding of the terminating up-event, if possible. 963 '(mouse-set-point
964 mouse-set-region))))))
965 ;; Run the binding of the terminating up-event, if possible.
958 (if (and (not (= (overlay-start mouse-drag-overlay) 966 (if (and (not (= (overlay-start mouse-drag-overlay)
959 (overlay-end mouse-drag-overlay))) 967 (overlay-end mouse-drag-overlay)))
960 (not do-multi-click)) 968 (not do-multi-click))
@@ -965,31 +973,34 @@ at the same position."
965 ;; The end that comes from where we ended the drag. 973 ;; The end that comes from where we ended the drag.
966 ;; Point goes here. 974 ;; Point goes here.
967 (region-termination 975 (region-termination
968 (if (and stop-point (< stop-point start-point)) 976 (if (and stop-point (< stop-point start-point))
969 (overlay-start mouse-drag-overlay) 977 (overlay-start mouse-drag-overlay)
970 (overlay-end mouse-drag-overlay))) 978 (overlay-end mouse-drag-overlay)))
971 ;; The end that comes from where we started the drag. 979 ;; The end that comes from where we started the drag.
972 ;; Mark goes there. 980 ;; Mark goes there.
973 (region-commencement 981 (region-commencement
974 (- (+ (overlay-end mouse-drag-overlay) 982 (- (+ (overlay-end mouse-drag-overlay)
975 (overlay-start mouse-drag-overlay)) 983 (overlay-start mouse-drag-overlay))
976 region-termination)) 984 region-termination))
977 last-command this-command) 985 last-command this-command)
978 (push-mark region-commencement t t) 986 (push-mark region-commencement t t)
979 (goto-char region-termination) 987 (goto-char region-termination)
980 ;; Don't let copy-region-as-kill set deactivate-mark. 988 (if (not do-mouse-drag-region-post-process)
981 (when mouse-drag-copy-region 989 ;; Skip all post-event handling, return immediately.
982 (let (deactivate-mark) 990 (delete-overlay mouse-drag-overlay)
983 (copy-region-as-kill (point) (mark t)))) 991 ;; Don't let copy-region-as-kill set deactivate-mark.
984 (let ((buffer (current-buffer))) 992 (when mouse-drag-copy-region
985 (mouse-show-mark) 993 (let (deactivate-mark)
986 ;; mouse-show-mark can call read-event, 994 (copy-region-as-kill (point) (mark t))))
987 ;; and that means the Emacs server could switch buffers 995 (let ((buffer (current-buffer)))
988 ;; under us. If that happened, 996 (mouse-show-mark)
989 ;; avoid trying to use the region. 997 ;; mouse-show-mark can call read-event,
990 (and (mark t) mark-active 998 ;; and that means the Emacs server could switch buffers
991 (eq buffer (current-buffer)) 999 ;; under us. If that happened,
992 (mouse-set-region-1)))) 1000 ;; avoid trying to use the region.
1001 (and (mark t) mark-active
1002 (eq buffer (current-buffer))
1003 (mouse-set-region-1)))))
993 ;; Run the binding of the terminating up-event. 1004 ;; Run the binding of the terminating up-event.
994 ;; If a multiple click is not bound to mouse-set-point, 1005 ;; If a multiple click is not bound to mouse-set-point,
995 ;; cancel the effects of mouse-move-drag-overlay to 1006 ;; cancel the effects of mouse-move-drag-overlay to
@@ -997,18 +1008,18 @@ at the same position."
997 (if do-multi-click (goto-char start-point)) 1008 (if do-multi-click (goto-char start-point))
998 (delete-overlay mouse-drag-overlay) 1009 (delete-overlay mouse-drag-overlay)
999 (when (and (functionp fun) 1010 (when (and (functionp fun)
1000 (= start-hscroll (window-hscroll start-window)) 1011 (= start-hscroll (window-hscroll start-window))
1001 ;; Don't run the up-event handler if the 1012 ;; Don't run the up-event handler if the
1002 ;; window start changed in a redisplay after 1013 ;; window start changed in a redisplay after
1003 ;; the mouse-set-point for the down-mouse 1014 ;; the mouse-set-point for the down-mouse
1004 ;; event at the beginning of this function. 1015 ;; event at the beginning of this function.
1005 ;; When the window start has changed, the 1016 ;; When the window start has changed, the
1006 ;; up-mouse event will contain a different 1017 ;; up-mouse event will contain a different
1007 ;; position due to the new window contents, 1018 ;; position due to the new window contents,
1008 ;; and point is set again. 1019 ;; and point is set again.
1009 (or end-point 1020 (or end-point
1010 (= (window-start start-window) 1021 (= (window-start start-window)
1011 start-window-start))) 1022 start-window-start)))
1012 (when (and on-link 1023 (when (and on-link
1013 (or (not end-point) (= end-point start-point)) 1024 (or (not end-point) (= end-point start-point))
1014 (consp event) 1025 (consp event)