aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1993-05-15 19:52:01 +0000
committerRichard M. Stallman1993-05-15 19:52:01 +0000
commitfcfc3c637992ad1b315dd95f71a78d70214b73fb (patch)
treedcfb06f39468532764b47f1ffb41de407797ce0a /lisp
parent6e8d0db7e232ba187d5b3e9c548f1fe312b7fa99 (diff)
downloademacs-fcfc3c637992ad1b315dd95f71a78d70214b73fb.tar.gz
emacs-fcfc3c637992ad1b315dd95f71a78d70214b73fb.zip
(mouse-drag-region): New command, on down-mouse-1.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mouse.el56
1 files changed, 51 insertions, 5 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index e8658c68e6c..779d4fa5b67 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -99,18 +99,65 @@ This must be bound to a mouse click."
99 99
100(defun mouse-set-region (click) 100(defun mouse-set-region (click)
101 "Set the region to the text that the mouse is dragged over. 101 "Set the region to the text that the mouse is dragged over.
102This must be bound to a mouse click." 102This must be bound to a mouse drag event."
103 (interactive "e") 103 (interactive "e")
104 (let ((posn (event-start click)) 104 (let ((posn (event-start click))
105 (end (event-end click))) 105 (end (event-end click)))
106 (select-window (posn-window posn)) 106 (select-window (posn-window posn))
107 (if (numberp (posn-point posn)) 107 (if (numberp (posn-point posn))
108 (goto-char (posn-point posn))) 108 (goto-char (posn-point posn)))
109 (sit-for 1) 109 ;; If mark is highlighted, no need to bounce the cursor.
110 (or (and transient-mark-mode
111 (eq (framep (selected-frame)) 'x))
112 (sit-for 1))
110 (push-mark) 113 (push-mark)
111 (if (numberp (posn-point end)) 114 (if (numberp (posn-point end))
112 (goto-char (posn-point end))))) 115 (goto-char (posn-point end)))))
113 116
117(defun mouse-drag-region (click)
118 "Set the region to the text that the mouse is dragged over.
119This must be bound to a button-down mouse event."
120 (interactive "e")
121 (let ((posn (event-start click))
122 done event (mark-active nil))
123 (select-window (posn-window posn))
124 ;; Set point temporarily, so user sees where it is.
125 (if (numberp (posn-point posn))
126 (goto-char (posn-point posn)))
127 ;; Turn off the old mark when we set up an empty region.
128 (setq deactivate-mark t)))
129
130;;;Nice hack, but too slow.
131;;;(defun mouse-drag-region-1 (click)
132;;; "Set the region to the text that the mouse is dragged over.
133;;;This must be bound to a button-down mouse event."
134;;; (interactive "e")
135;;; (let (newmark)
136;;; (let ((posn (event-start click))
137;;; done event omark (mark-active t))
138;;; (select-window (posn-window posn))
139;;; (setq omark (and mark-active (mark)))
140;;; (if (numberp (posn-point posn))
141;;; (goto-char (posn-point posn)))
142;;; ;; Set mark temporarily, so highlighting does what we want.
143;;; (set-marker (mark-marker) (point))
144;;; (track-mouse
145;;; (while (not done)
146;;; (setq event (read-event))
147;;; (if (eq (car-safe event) 'mouse-movement)
148;;; (goto-char (posn-point (event-start event)))
149;;; ;; Exit when we get the drag event; ignore that event.
150;;; (setq done t))))
151;;; (if (/= (mark) (point))
152;;; (setq newmark (mark)))
153;;; ;; Restore previous mark status.
154;;; (if omark (set-marker (mark-marker) omark)))
155;;; ;; Now, if we dragged, set the mark at the proper place.
156;;; (if newmark
157;;; (push-mark newmark t)
158;;; ;; Turn off the old mark when we set up an empty region.
159;;; (setq deactivate-mark t))))
160
114(defun mouse-set-mark (click) 161(defun mouse-set-mark (click)
115 "Set mark at the position clicked on with the mouse. 162 "Set mark at the position clicked on with the mouse.
116Display cursor at that position for a second. 163Display cursor at that position for a second.
@@ -603,11 +650,10 @@ and selects that window."
603 650
604;;; Bindings for mouse commands. 651;;; Bindings for mouse commands.
605 652
606;; This won't be needed once the drag and down events 653(define-key global-map [down-mouse-1] 'mouse-drag-region)
607;; are properly implemented.
608(global-set-key [mouse-1] 'mouse-set-point) 654(global-set-key [mouse-1] 'mouse-set-point)
609
610(global-set-key [drag-mouse-1] 'mouse-set-region) 655(global-set-key [drag-mouse-1] 'mouse-set-region)
656
611(global-set-key [mouse-2] 'mouse-yank-at-click) 657(global-set-key [mouse-2] 'mouse-yank-at-click)
612(global-set-key [mouse-3] 'mouse-save-then-kill) 658(global-set-key [mouse-3] 'mouse-save-then-kill)
613 659