comparison lisp/mouse.el @ 4490:8362b57424dc

(mouse-set-point): Error if click in inactive minibuffer. (mouse-drag-region): Use mouse-set-point. Don't set a mark if final event wasn't suitable for setting point.
author Richard M. Stallman <rms@gnu.org>
date Sun, 08 Aug 1993 19:16:42 +0000
parents 951f354907d8
children c2afed091afb
comparison
equal deleted inserted replaced
4489:f1fa60176c8d 4490:8362b57424dc
94 (defun mouse-set-point (click) 94 (defun mouse-set-point (click)
95 "Move point to the position clicked on with the mouse. 95 "Move point to the position clicked on with the mouse.
96 This must be bound to a mouse click." 96 This must be bound to a mouse click."
97 (interactive "e") 97 (interactive "e")
98 (let ((posn (event-start click))) 98 (let ((posn (event-start click)))
99 (and (window-minibuffer-p (posn-window posn))
100 (not (minibuffer-window-active-p (posn-window posn)))
101 (error "Minibuffer window is not active"))
99 (select-window (posn-window posn)) 102 (select-window (posn-window posn))
100 (if (numberp (posn-point posn)) 103 (if (numberp (posn-point posn))
101 (goto-char (posn-point posn))))) 104 (goto-char (posn-point posn)))))
102 105
103 (defun mouse-set-region (click) 106 (defun mouse-set-region (click)
166 (top (nth 1 bounds)) 169 (top (nth 1 bounds))
167 (bottom (if (window-minibuffer-p start-window) 170 (bottom (if (window-minibuffer-p start-window)
168 (nth 3 bounds) 171 (nth 3 bounds)
169 ;; Don't count the mode line. 172 ;; Don't count the mode line.
170 (1- (nth 3 bounds))))) 173 (1- (nth 3 bounds)))))
171 (select-window start-window) 174 (mouse-set-point start-event)
172 (goto-char start-point)
173 (move-overlay mouse-drag-overlay 175 (move-overlay mouse-drag-overlay
174 start-point start-point 176 start-point start-point
175 (window-buffer start-window)) 177 (window-buffer start-window))
176 (deactivate-mark) 178 (deactivate-mark)
177 (let (event end end-point) 179 (let (event end end-point)
217 (t))))) 219 (t)))))
218 220
219 (if (and (eq (get (event-basic-type event) 'event-kind) 'mouse-click) 221 (if (and (eq (get (event-basic-type event) 'event-kind) 'mouse-click)
220 (eq (posn-window (event-end event)) start-window) 222 (eq (posn-window (event-end event)) start-window)
221 (numberp (posn-point (event-end event)))) 223 (numberp (posn-point (event-end event))))
222 (goto-char (posn-point (event-end event)))) 224 (progn
223 (if (= (point) start-point) 225 (mouse-set-point event)
224 (deactivate-mark) 226 (if (= (point) start-point)
225 (set-mark start-point)) 227 (deactivate-mark)
228 (set-mark start-point))))
226 (delete-overlay mouse-drag-overlay)))) 229 (delete-overlay mouse-drag-overlay))))
227 230
228 ;;;! (defun mouse-drag-region (click) 231 ;;;! (defun mouse-drag-region (click)
229 ;;;! "Set the region to the text that the mouse is dragged over. 232 ;;;! "Set the region to the text that the mouse is dragged over.
230 ;;;! This must be bound to a button-down mouse event." 233 ;;;! This must be bound to a button-down mouse event."