Mercurial > emacs
comparison lisp/mouse-sel.el @ 8225:c6a3a9b2ef3f
Many doc fixes.
(mouse-extend): Don't use existing region if EVENT is nil.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 12 Jul 1994 17:37:32 +0000 |
parents | bc5dccc5375f |
children | 9c7a3c5f887d |
comparison
equal
deleted
inserted
replaced
8224:1cc48bdd0c6b | 8225:c6a3a9b2ef3f |
---|---|
163 | 163 |
164 ;;=== User Variables ====================================================== | 164 ;;=== User Variables ====================================================== |
165 | 165 |
166 (defvar mouse-sel-leave-point-near-mouse t | 166 (defvar mouse-sel-leave-point-near-mouse t |
167 "*Leave point near last mouse position. | 167 "*Leave point near last mouse position. |
168 If non-nil, \\[mouse-select] and \\[mouse-extend] will leave point at the end | 168 If non-nil, \\[mouse-select] and \\[mouse-extend] leave point at the end |
169 of the region nearest to where the mouse last was. | 169 of the region nearest to where the mouse last was. |
170 If nil, point will always be placed at the beginning of the region.") | 170 If nil, point is always placed at the beginning of the region.") |
171 | 171 |
172 (defvar mouse-sel-retain-highlight nil | 172 (defvar mouse-sel-retain-highlight nil |
173 "*Retain highlight on mouse-drag-overlay. | 173 "*Retain highlight after dragging is finished. |
174 If non-nil, regions selected using \\[mouse-select] and \\[mouse-extend] will | 174 If non-nil, regions selected using \\[mouse-select] and \\[mouse-extend] will |
175 remain highlighted. | 175 remain highlighted. |
176 If nil, highlighting will be turned off when the mouse is lifted.") | 176 If nil, highlighting turns off when you release the mouse button.") |
177 | 177 |
178 (defvar mouse-sel-cycle-clicks t | 178 (defvar mouse-sel-cycle-clicks t |
179 "*If non-nil, \\[mouse-select] cycles the click-counts after 3 clicks. | 179 "*If non-nil, \\[mouse-select] cycles the click-counts after 3 clicks. |
180 Ie. 4 clicks = 1 click, 5 clicks = 2 clicks, etc.") | 180 Ie. 4 clicks = 1 click, 5 clicks = 2 clicks, etc.") |
181 | 181 |
206 | 206 |
207 (defvar mouse-sel-check-selection-function | 207 (defvar mouse-sel-check-selection-function |
208 (if (fboundp 'x-selection-owner-p) | 208 (if (fboundp 'x-selection-owner-p) |
209 'x-selection-owner-p | 209 'x-selection-owner-p |
210 nil) | 210 nil) |
211 "Function to check whether emacs still owns the selection. | 211 "Function to check whether Emacs still owns the selection. |
212 Called with no arguments.") | 212 Called with no arguments.") |
213 | 213 |
214 (defun mouse-sel-determine-selection-type (NCLICKS) | 214 (defun mouse-sel-determine-selection-type (NCLICKS) |
215 "Determine what `thing' `mouse-sel' should operate on. | 215 "Determine what \"thing\" `mouse-sel' should operate on. |
216 The first argument is NCLICKS, is the number of consecutive | 216 The first argument, NCLICKS, is the number of consecutive |
217 mouse clicks at the same position." | 217 mouse clicks at the same position." |
218 (let* ((next-char (char-after (point))) | 218 (let* ((next-char (char-after (point))) |
219 (char-syntax (if next-char (char-syntax next-char))) | 219 (char-syntax (if next-char (char-syntax next-char))) |
220 (nclicks (if mouse-sel-cycle-clicks (1+ (% (1- NCLICKS) 3)) NCLICKS))) | 220 (nclicks (if mouse-sel-cycle-clicks (1+ (% (1- NCLICKS) 3)) NCLICKS))) |
221 (cond | 221 (cond |
227 ((eq char-syntax ?w) 'word)))) | 227 ((eq char-syntax ?w) 'word)))) |
228 | 228 |
229 (defun mouse-select (EVENT) | 229 (defun mouse-select (EVENT) |
230 "Set region/selection using the mouse. | 230 "Set region/selection using the mouse. |
231 | 231 |
232 On click, point & mark are set to click position, and mark is disabled. | 232 Clicking sets point to click position, and deactivates the mark |
233 if you are in Transient Mark mode. | |
233 Dragging extends region/selection. | 234 Dragging extends region/selection. |
234 | 235 |
235 Double-clicking on word constituents selects words. | 236 Double-clicking on word constituents selects words. |
236 Double-clicking on symbol constituents selects symbols. | 237 Double-clicking on symbol constituents selects symbols. |
237 Double-clicking on quotes or parentheses selects sexps. | 238 Double-clicking on quotes or parentheses selects sexps. |
245 (interactive "e") | 246 (interactive "e") |
246 (mouse-set-point EVENT) | 247 (mouse-set-point EVENT) |
247 (setq mouse-sel-selection-type | 248 (setq mouse-sel-selection-type |
248 (mouse-sel-determine-selection-type (event-click-count EVENT))) | 249 (mouse-sel-determine-selection-type (event-click-count EVENT))) |
249 (let ((object-bounds (bounds-of-thing-at-point mouse-sel-selection-type))) | 250 (let ((object-bounds (bounds-of-thing-at-point mouse-sel-selection-type))) |
251 (setq foo object-bounds) | |
250 (if object-bounds | 252 (if object-bounds |
251 (progn | 253 (progn |
252 (setq mark-active t) | 254 (setq mark-active t) |
253 (goto-char (car object-bounds)) | 255 (goto-char (car object-bounds)) |
254 (set-mark (cdr object-bounds))) | 256 (set-mark (cdr object-bounds))) |
261 See documentation for mouse-select for more details. | 263 See documentation for mouse-select for more details. |
262 | 264 |
263 This should be bound to a down-mouse event." | 265 This should be bound to a down-mouse event." |
264 (interactive "e") | 266 (interactive "e") |
265 (if EVENT (select-window (posn-window (event-end EVENT)))) | 267 (if EVENT (select-window (posn-window (event-end EVENT)))) |
266 (let* ((min (if mark-active (region-beginning) (point))) | 268 (let* ((min (if (and EVENT mark-active) (region-beginning) (point))) |
267 (max (if mark-active (region-end) (point))) | 269 (max (if (and EVENT mark-active) (region-end) (point))) |
268 (orig-window (selected-window)) | 270 (orig-window (selected-window)) |
269 (orig-window-frame (window-frame orig-window)) | 271 (orig-window-frame (window-frame orig-window)) |
270 (top (nth 1 (window-edges orig-window))) | 272 (top (nth 1 (window-edges orig-window))) |
271 (bottom (nth 3 (window-edges orig-window))) | 273 (bottom (nth 3 (window-edges orig-window))) |
272 (orig-cursor-type | 274 (orig-cursor-type |
330 | 332 |
331 ;; In original window | 333 ;; In original window |
332 (t (goto-char (posn-point end))) | 334 (t (goto-char (posn-point end))) |
333 | 335 |
334 ) | 336 ) |
335 | 337 (setq foo1 (cons (list min max (point)) foo1)) |
336 ;; Determine direction of drag | 338 ;; Determine direction of drag |
337 (cond | 339 (cond |
338 ((and (not direction) (not (eq min max))) | 340 ((and (not direction) (not (eq min max))) |
339 (setq direction (if (< (point) (/ (+ min max) 2)) -1 1))) | 341 (setq direction (if (< (point) (/ (+ min max) 2)) -1 1))) |
340 ((and (not (eq direction -1)) (<= (point) min)) | 342 ((and (not (eq direction -1)) (<= (point) min)) |