Commit | Line | Data |
---|---|---|
6594deb0 | 1 | ;;; mouse.el --- window system-independent mouse support. |
84176303 | 2 | |
9a408b1d | 3 | ;;; Copyright (C) 1993 Free Software Foundation, Inc. |
eea8d4ef | 4 | |
84176303 | 5 | ;; Maintainer: FSF |
84176303 ER |
6 | ;; Keywords: hardware |
7 | ||
cc0a8174 | 8 | ;;; This file is part of GNU Emacs. |
72ea54a4 | 9 | |
cc0a8174 JB |
10 | ;;; GNU Emacs is free software; you can redistribute it and/or modify |
11 | ;;; it under the terms of the GNU General Public License as published by | |
87ef29fd | 12 | ;;; the Free Software Foundation; either version 2, or (at your option) |
cc0a8174 | 13 | ;;; any later version. |
72ea54a4 | 14 | |
cc0a8174 JB |
15 | ;;; GNU Emacs is distributed in the hope that it will be useful, |
16 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;;; GNU General Public License for more details. | |
72ea54a4 | 19 | |
cc0a8174 JB |
20 | ;;; You should have received a copy of the GNU General Public License |
21 | ;;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 | ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
72ea54a4 | 23 | |
edbd2f74 ER |
24 | ;;; Commentary: |
25 | ||
26 | ;; This package provides various useful commands (including help | |
27 | ;; system access) through the mouse. All this code assumes that mouse | |
28 | ;; interpretation has been abstracted into Emacs input events. | |
29 | ;; | |
30 | ;; The code is rather X-dependent. | |
31 | ||
aae56ea7 ER |
32 | ;;; Code: |
33 | ||
cc0a8174 | 34 | ;;; Utility functions. |
72ea54a4 | 35 | |
cc0a8174 JB |
36 | ;;; Indent track-mouse like progn. |
37 | (put 'track-mouse 'lisp-indent-function 0) | |
72ea54a4 | 38 | |
cc0a8174 JB |
39 | \f |
40 | (defun mouse-delete-window (click) | |
947da0c4 | 41 | "Delete the window you click on. |
cc0a8174 | 42 | This must be bound to a mouse click." |
ec558adc | 43 | (interactive "e") |
b5370f03 | 44 | (delete-window (posn-window (event-start click)))) |
cc0a8174 | 45 | |
b0f3a26b JB |
46 | (defun mouse-tear-off-window (click) |
47 | "Delete the window clicked on, and create a new frame displaying its buffer." | |
48 | (interactive "e") | |
49 | (let* ((window (posn-window (event-start click))) | |
50 | (buf (window-buffer window)) | |
51 | (frame (new-frame))) | |
52 | (select-frame frame) | |
53 | (switch-to-buffer buf) | |
54 | (delete-window window))) | |
55 | ||
b5370f03 | 56 | (defun mouse-delete-other-windows () |
947da0c4 | 57 | "Delete all window except the one you click on." |
b5370f03 | 58 | (interactive "@") |
cc0a8174 | 59 | (delete-other-windows)) |
72ea54a4 | 60 | |
cc0a8174 JB |
61 | (defun mouse-split-window-vertically (click) |
62 | "Select Emacs window mouse is on, then split it vertically in half. | |
63 | The window is split at the line clicked on. | |
64 | This command must be bound to a mouse click." | |
947da0c4 | 65 | (interactive "@e") |
b5370f03 JB |
66 | (let ((start (event-start click))) |
67 | (select-window (posn-window start)) | |
3f26b32a RS |
68 | (let ((new-height (if (eq (posn-point start) 'vertical-scroll-bar) |
69 | (scroll-bar-scale (posn-col-row start) | |
70 | (1- (window-height))) | |
71 | (1+ (cdr (posn-col-row (event-end click)))))) | |
5ba2dc3f JB |
72 | (first-line window-min-height) |
73 | (last-line (- (window-height) window-min-height))) | |
74 | (if (< last-line first-line) | |
75 | (error "window too short to split") | |
76 | (split-window-vertically | |
77 | (min (max new-height first-line) last-line)))))) | |
cc0a8174 | 78 | |
947da0c4 RS |
79 | (defun mouse-split-window-horizontally (click) |
80 | "Select Emacs window mouse is on, then split it horizontally in half. | |
81 | The window is split at the column clicked on. | |
82 | This command must be bound to a mouse click." | |
83 | (interactive "@e") | |
5ba2dc3f JB |
84 | (let ((start (event-start click))) |
85 | (select-window (posn-window start)) | |
86 | (let ((new-width (1+ (car (posn-col-row (event-end click))))) | |
87 | (first-col window-min-width) | |
88 | (last-col (- (window-width) window-min-width))) | |
89 | (if (< last-col first-col) | |
90 | (error "window too narrow to split") | |
91 | (split-window-horizontally | |
92 | (min (max new-width first-col) last-col)))))) | |
947da0c4 | 93 | |
cc0a8174 JB |
94 | (defun mouse-set-point (click) |
95 | "Move point to the position clicked on with the mouse. | |
96 | This must be bound to a mouse click." | |
ec558adc | 97 | (interactive "e") |
b5370f03 JB |
98 | (let ((posn (event-start click))) |
99 | (select-window (posn-window posn)) | |
100 | (if (numberp (posn-point posn)) | |
101 | (goto-char (posn-point posn))))) | |
cc0a8174 | 102 | |
652ccd35 RS |
103 | (defun mouse-set-region (click) |
104 | "Set the region to the text that the mouse is dragged over. | |
fcfc3c63 | 105 | This must be bound to a mouse drag event." |
652ccd35 RS |
106 | (interactive "e") |
107 | (let ((posn (event-start click)) | |
108 | (end (event-end click))) | |
109 | (select-window (posn-window posn)) | |
110 | (if (numberp (posn-point posn)) | |
111 | (goto-char (posn-point posn))) | |
fcfc3c63 RS |
112 | ;; If mark is highlighted, no need to bounce the cursor. |
113 | (or (and transient-mark-mode | |
114 | (eq (framep (selected-frame)) 'x)) | |
115 | (sit-for 1)) | |
652ccd35 | 116 | (push-mark) |
1cc8a3f4 | 117 | (set-mark (point)) |
652ccd35 RS |
118 | (if (numberp (posn-point end)) |
119 | (goto-char (posn-point end))))) | |
120 | ||
600c6e3a JB |
121 | (defvar mouse-scroll-delay 0.25 |
122 | "*The pause between scroll steps caused by mouse drags, in seconds. | |
123 | If you drag the mouse beyond the edge of a window, Emacs scrolls the | |
124 | window to bring the text beyond that edge into view, with a delay of | |
125 | this many seconds between scroll steps. Scrolling stops when you move | |
126 | the mouse back into the window, or release the button. | |
127 | This variable's value may be non-integral. | |
128 | Setting this to zero causes Emacs to scroll as fast as it can.") | |
129 | ||
130 | (defun mouse-scroll-subr (jump &optional overlay start) | |
131 | "Scroll the selected window JUMP lines at a time, until new input arrives. | |
132 | If OVERLAY is an overlay, let it stretch from START to the far edge of | |
133 | the newly visible text. | |
134 | Upon exit, point is at the far edge of the newly visible text." | |
135 | (while (progn | |
136 | (goto-char (window-start)) | |
137 | (if (not (zerop (vertical-motion jump))) | |
138 | (progn | |
139 | (set-window-start (selected-window) (point)) | |
140 | (if (natnump jump) | |
141 | (progn | |
142 | (goto-char (window-end (selected-window))) | |
143 | ;; window-end doesn't reflect the window's new | |
144 | ;; start position until the next redisplay. Hurrah. | |
145 | (vertical-motion (1- jump))) | |
146 | (goto-char (window-start (selected-window)))) | |
147 | (if overlay | |
148 | (move-overlay overlay start (point))) | |
149 | (if (not (eobp)) | |
150 | (sit-for mouse-scroll-delay)))))) | |
151 | (point)) | |
fcfc3c63 | 152 | |
600c6e3a JB |
153 | (defvar mouse-drag-overlay (make-overlay 1 1)) |
154 | (overlay-put mouse-drag-overlay 'face 'region) | |
155 | ||
156 | (defun mouse-drag-region (start-event) | |
bcd5aef1 | 157 | "Set the region to the text that the mouse is dragged over. |
600c6e3a | 158 | Highlight the drag area as the user moves the mouse. |
bcd5aef1 RS |
159 | This must be bound to a button-down mouse event." |
160 | (interactive "e") | |
600c6e3a JB |
161 | (let* ((start-posn (event-start start-event)) |
162 | (start-point (posn-point start-posn)) | |
163 | (start-window (posn-window start-posn)) | |
b846d039 | 164 | (start-frame (window-frame start-window)) |
600c6e3a JB |
165 | (bounds (window-edges start-window)) |
166 | (top (nth 1 bounds)) | |
167 | (bottom (if (window-minibuffer-p start-window) | |
168 | (nth 3 bounds) | |
169 | ;; Don't count the mode line. | |
170 | (1- (nth 3 bounds))))) | |
171 | (select-window start-window) | |
172 | (goto-char start-point) | |
173 | (move-overlay mouse-drag-overlay | |
174 | start-point start-point | |
175 | (window-buffer start-window)) | |
f767385c | 176 | (deactivate-mark) |
600c6e3a | 177 | (let (event end end-point) |
bcd5aef1 | 178 | (track-mouse |
600c6e3a | 179 | (while (progn |
b846d039 JB |
180 | (setq event (read-event)) |
181 | (or (mouse-movement-p event) | |
182 | (eq (car-safe event) 'switch-frame))) | |
183 | ||
184 | (if (eq (car-safe event) 'switch-frame) | |
185 | nil | |
186 | (setq end (event-end event) | |
187 | end-point (posn-point end)) | |
188 | ||
189 | (cond | |
190 | ||
191 | ;; Ignore switch-frame events. | |
192 | ((eq (car-safe event) 'switch-frame)) | |
193 | ||
194 | ;; Are we moving within the original window? | |
195 | ((and (eq (posn-window end) start-window) | |
196 | (integer-or-marker-p end-point)) | |
197 | (goto-char end-point) | |
198 | (move-overlay mouse-drag-overlay | |
199 | start-point (point))) | |
200 | ||
201 | ;; Are we moving on a different window on the same frame? | |
202 | ((and (windowp (posn-window end)) | |
203 | (eq (window-frame (posn-window end)) start-frame)) | |
204 | (let ((mouse-row | |
205 | (+ (nth 1 (window-edges (posn-window end))) | |
206 | (cdr (posn-col-row end))))) | |
207 | (cond | |
208 | ((< mouse-row top) | |
209 | (mouse-scroll-subr | |
210 | (- mouse-row top) mouse-drag-overlay start-point)) | |
211 | ((and (not (eobp)) | |
212 | (>= mouse-row bottom)) | |
213 | (mouse-scroll-subr (1+ (- mouse-row bottom)) | |
214 | mouse-drag-overlay start-point))))) | |
215 | ||
216 | ;; Otherwise, we have no idea where the mouse is. | |
217 | (t))))) | |
218 | ||
600c6e3a JB |
219 | (if (and (eq (get (event-basic-type event) 'event-kind) 'mouse-click) |
220 | (eq (posn-window (event-end event)) start-window) | |
221 | (numberp (posn-point (event-end event)))) | |
222 | (goto-char (posn-point (event-end event)))) | |
223 | (if (= (point) start-point) | |
f767385c | 224 | (deactivate-mark) |
600c6e3a JB |
225 | (set-mark start-point)) |
226 | (delete-overlay mouse-drag-overlay)))) | |
227 | ||
228 | ;;;! (defun mouse-drag-region (click) | |
229 | ;;;! "Set the region to the text that the mouse is dragged over. | |
230 | ;;;! This must be bound to a button-down mouse event." | |
231 | ;;;! (interactive "e") | |
232 | ;;;! (let ((posn (event-start click)) | |
233 | ;;;! done event (mark-active nil)) | |
234 | ;;;! (select-window (posn-window posn)) | |
235 | ;;;! ;; Set point temporarily, so user sees where it is. | |
236 | ;;;! (if (numberp (posn-point posn)) | |
237 | ;;;! (goto-char (posn-point posn))) | |
238 | ;;;! ;; Turn off the old mark when we set up an empty region. | |
239 | ;;;! (setq deactivate-mark t))) | |
240 | ;;;! | |
241 | ;;;! ;;;Nice hack, but too slow, so not normally in use. | |
242 | ;;;! (defun mouse-drag-region-1 (click) | |
243 | ;;;! "Set the region to the text that the mouse is dragged over. | |
244 | ;;;! This must be bound to a button-down mouse event." | |
245 | ;;;! (interactive "e") | |
246 | ;;;! (let (newmark) | |
247 | ;;;! (let ((posn (event-start click)) | |
248 | ;;;! done event omark (mark-active t)) | |
249 | ;;;! (select-window (posn-window posn)) | |
250 | ;;;! (setq omark (and mark-active (mark))) | |
251 | ;;;! (if (numberp (posn-point posn)) | |
252 | ;;;! (goto-char (posn-point posn))) | |
253 | ;;;! ;; Set mark temporarily, so highlighting does what we want. | |
254 | ;;;! (set-marker (mark-marker) (point)) | |
255 | ;;;! (track-mouse | |
256 | ;;;! (while (not done) | |
257 | ;;;! (setq event (read-event)) | |
258 | ;;;! (if (eq (car-safe event) 'mouse-movement) | |
259 | ;;;! (goto-char (posn-point (event-start event))) | |
260 | ;;;! ;; Exit when we get the drag event; ignore that event. | |
261 | ;;;! (setq done t)))) | |
262 | ;;;! (if (/= (mark) (point)) | |
263 | ;;;! (setq newmark (mark))) | |
264 | ;;;! ;; Restore previous mark status. | |
265 | ;;;! (if omark (set-marker (mark-marker) omark))) | |
266 | ;;;! ;; Now, if we dragged, set the mark at the proper place. | |
267 | ;;;! (if newmark | |
268 | ;;;! (push-mark newmark t t) | |
269 | ;;;! ;; Turn off the old mark when we set up an empty region. | |
270 | ;;;! (setq deactivate-mark t)))) | |
e66feb07 | 271 | \f |
3f26b32a RS |
272 | ;; Subroutine: set the mark where CLICK happened, |
273 | ;; but don't do anything else. | |
274 | (defun mouse-set-mark-fast (click) | |
275 | (let ((posn (event-start click))) | |
276 | (select-window (posn-window posn)) | |
277 | (if (numberp (posn-point posn)) | |
278 | (push-mark (posn-point posn) t t)))) | |
279 | ||
280 | ;; Momentarily show where the mark is, if highlighting doesn't show it. | |
281 | (defun mouse-show-mark () | |
282 | (or transient-mark-mode | |
283 | (save-excursion | |
284 | (goto-char (mark t)) | |
285 | (sit-for 1)))) | |
286 | ||
cc0a8174 JB |
287 | (defun mouse-set-mark (click) |
288 | "Set mark at the position clicked on with the mouse. | |
289 | Display cursor at that position for a second. | |
290 | This must be bound to a mouse click." | |
ec558adc | 291 | (interactive "e") |
72ea54a4 RS |
292 | (let ((point-save (point))) |
293 | (unwind-protect | |
cc0a8174 | 294 | (progn (mouse-set-point click) |
897897e3 RS |
295 | (push-mark nil t t) |
296 | (or transient-mark-mode | |
297 | (sit-for 1))) | |
72ea54a4 RS |
298 | (goto-char point-save)))) |
299 | ||
cc0a8174 JB |
300 | (defun mouse-kill (click) |
301 | "Kill the region between point and the mouse click. | |
302 | The text is saved in the kill ring, as with \\[kill-region]." | |
ec558adc | 303 | (interactive "e") |
40a45a9f | 304 | (let ((click-posn (posn-point (event-start click)))) |
bd307392 JB |
305 | (if (numberp click-posn) |
306 | (kill-region (min (point) click-posn) | |
307 | (max (point) click-posn))))) | |
72ea54a4 | 308 | |
87ef29fd JB |
309 | (defun mouse-yank-at-click (click arg) |
310 | "Insert the last stretch of killed text at the position clicked on. | |
311 | Prefix arguments are interpreted as with \\[yank]." | |
ec558adc | 312 | (interactive "e\nP") |
87ef29fd JB |
313 | (mouse-set-point click) |
314 | (yank arg)) | |
315 | ||
316 | (defun mouse-kill-ring-save (click) | |
cc0a8174 JB |
317 | "Copy the region between point and the mouse click in the kill ring. |
318 | This does not delete the region; it acts like \\[kill-ring-save]." | |
ec558adc | 319 | (interactive "e") |
3f26b32a RS |
320 | (mouse-set-mark-fast click) |
321 | (kill-ring-save (point) (mark t)) | |
322 | (mouse-show-mark)) | |
72ea54a4 | 323 | |
dbc4e1c1 JB |
324 | ;;; This function used to delete the text between point and the mouse |
325 | ;;; whenever it was equal to the front of the kill ring, but some | |
326 | ;;; people found that confusing. | |
327 | ||
328 | ;;; A list (TEXT START END), describing the text and position of the last | |
329 | ;;; invocation of mouse-save-then-kill. | |
330 | (defvar mouse-save-then-kill-posn nil) | |
331 | ||
947da0c4 | 332 | (defun mouse-save-then-kill (click) |
40a45a9f RS |
333 | "Save text to point in kill ring; the second time, kill the text. |
334 | If the text between point and the mouse is the same as what's | |
335 | at the front of the kill ring, this deletes the text. | |
336 | Otherwise, it adds the text to the kill ring, like \\[kill-ring-save], | |
337 | which prepares for a second click to delete the text." | |
947da0c4 | 338 | (interactive "e") |
3f26b32a RS |
339 | (let ((click-posn (posn-point (event-start click))) |
340 | ;; Don't let a subsequent kill command append to this one: | |
341 | ;; prevent setting this-command to kill-region. | |
342 | (this-command this-command)) | |
343 | (if (and (eq last-command 'mouse-save-then-kill) | |
dbc4e1c1 JB |
344 | mouse-save-then-kill-posn |
345 | (eq (car mouse-save-then-kill-posn) (car kill-ring)) | |
346 | (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn))) | |
347 | ;; If this is the second time we've called | |
348 | ;; mouse-save-then-kill, delete the text from the buffer. | |
40a45a9f RS |
349 | (progn |
350 | (let ((buffer-undo-list t)) | |
351 | (delete-region (point) (mark))) | |
352 | ;; Make the undo list by hand so it is shared. | |
dbc4e1c1 JB |
353 | (if (not (eq buffer-undo-list t)) |
354 | (setq buffer-undo-list | |
355 | (cons (cons (car kill-ring) (point)) buffer-undo-list)))) | |
40a45a9f | 356 | ;; Otherwise, save this region. |
3f26b32a | 357 | (mouse-set-mark-fast click) |
897897e3 | 358 | (kill-ring-save (point) (mark t)) |
3f26b32a | 359 | (mouse-show-mark) |
dbc4e1c1 JB |
360 | (setq mouse-save-then-kill-posn |
361 | (list (car kill-ring) (point) click-posn))))) | |
e66feb07 RS |
362 | \f |
363 | (global-set-key [M-mouse-1] 'mouse-start-secondary) | |
364 | (global-set-key [M-drag-mouse-1] 'mouse-set-secondary) | |
365 | (global-set-key [M-down-mouse-1] 'mouse-drag-secondary) | |
366 | (global-set-key [M-mouse-3] 'mouse-secondary-save-then-kill) | |
367 | (global-set-key [M-mouse-2] 'mouse-kill-secondary) | |
368 | ||
369 | ;; An overlay which records the current secondary selection | |
370 | ;; or else is deleted when there is no secondary selection. | |
371 | ;; May be nil. | |
372 | (defvar mouse-secondary-overlay nil) | |
373 | ||
374 | ;; A marker which records the specified first end for a secondary selection. | |
375 | ;; May be nil. | |
376 | (defvar mouse-secondary-start nil) | |
377 | ||
378 | (defun mouse-start-secondary (click) | |
379 | "Set one end of the secondary selection to the position clicked on. | |
380 | Use \\[mouse-secondary-save-then-kill] to set the other end | |
381 | and complete the secondary selection." | |
382 | (interactive "e") | |
383 | (let ((posn (event-start click))) | |
230aaa73 RS |
384 | (save-excursion |
385 | (set-buffer (window-buffer (posn-window posn))) | |
386 | ;; Cancel any preexisting secondary selection. | |
387 | (if mouse-secondary-overlay | |
388 | (delete-overlay mouse-secondary-overlay)) | |
389 | (if (numberp (posn-point posn)) | |
390 | (progn | |
391 | (or mouse-secondary-start | |
392 | (setq mouse-secondary-start (make-marker))) | |
393 | (move-marker mouse-secondary-start (posn-point posn))))))) | |
e66feb07 RS |
394 | |
395 | (defun mouse-set-secondary (click) | |
396 | "Set the secondary selection to the text that the mouse is dragged over. | |
397 | This must be bound to a mouse drag event." | |
398 | (interactive "e") | |
399 | (let ((posn (event-start click)) | |
400 | beg | |
401 | (end (event-end click))) | |
230aaa73 RS |
402 | (save-excursion |
403 | (set-buffer (window-buffer (posn-window posn))) | |
404 | (if (numberp (posn-point posn)) | |
405 | (setq beg (posn-point posn))) | |
406 | (if mouse-secondary-overlay | |
407 | (move-overlay mouse-secondary-overlay beg (posn-point end)) | |
408 | (setq mouse-secondary-overlay (make-overlay beg (posn-point end)))) | |
409 | (overlay-put mouse-secondary-overlay 'face 'secondary-selection)))) | |
947da0c4 | 410 | |
e66feb07 RS |
411 | (defun mouse-drag-secondary (click) |
412 | "Set the secondary selection to the text that the mouse is dragged over. | |
413 | This must be bound to a button-down mouse event." | |
414 | (interactive "e") | |
415 | (let ((posn (event-start click))) | |
230aaa73 RS |
416 | (save-window-excursion |
417 | (select-window (posn-window posn)) | |
418 | ;; Set point temporarily, so user sees where it is. | |
419 | (save-excursion | |
420 | (if (numberp (posn-point posn)) | |
421 | (goto-char (posn-point posn))) | |
422 | (setq unread-command-events | |
423 | (cons (read-event) unread-command-events)))))) | |
e66feb07 RS |
424 | |
425 | (defun mouse-kill-secondary () | |
426 | "Kill the text in the secondary selection." | |
427 | (interactive "*") | |
428 | (kill-region (overlay-start mouse-secondary-overlay) | |
429 | (overlay-end mouse-secondary-overlay)) | |
430 | (delete-overlay mouse-secondary-overlay) | |
431 | (setq mouse-secondary-overlay nil)) | |
432 | ||
433 | (defun mouse-secondary-save-then-kill (click) | |
434 | "Save text to secondary start point in kill ring; if twice, kill it. | |
435 | If the text between secondary start point and the mouse is the same as what's | |
436 | at the front of the kill ring, this deletes the text. | |
437 | Otherwise, it adds the text to the kill ring, like \\[kill-ring-save], | |
438 | which prepares for a second click to delete the text." | |
439 | (interactive "e") | |
440 | (let ((click-posn (posn-point (event-start click))) | |
441 | (start (+ 0 mouse-secondary-start)) | |
442 | ;; Don't let a subsequent kill command append to this one: | |
443 | ;; prevent setting this-command to kill-region. | |
444 | (this-command this-command)) | |
445 | (if (and (eq last-command 'mouse-secondary-save-then-kill) | |
446 | mouse-save-then-kill-posn | |
447 | (eq (car mouse-save-then-kill-posn) (car kill-ring)) | |
448 | (equal (cdr mouse-save-then-kill-posn) | |
449 | (list start click-posn))) | |
450 | ;; If this is the second time we've called | |
451 | ;; mouse-save-then-kill, delete the text from the buffer. | |
452 | (progn | |
453 | (let ((buffer-undo-list t)) | |
454 | (delete-overlay mouse-secondary-overlay) | |
455 | (delete-region start click-posn)) | |
456 | ;; Make the undo list by hand so it is shared. | |
457 | (if (not (eq buffer-undo-list t)) | |
458 | (setq buffer-undo-list | |
367ee8f4 | 459 | (cons (cons (car kill-ring) (marker-position start)) |
e66feb07 RS |
460 | buffer-undo-list)))) |
461 | ;; Otherwise, save this region. | |
230aaa73 RS |
462 | (save-excursion |
463 | (set-buffer (window-buffer (posn-window (event-start click)))) | |
464 | (kill-ring-save start click-posn) | |
465 | (if mouse-secondary-overlay | |
466 | (move-overlay mouse-secondary-overlay start click-posn) | |
467 | (setq mouse-secondary-overlay (make-overlay start click-posn))) | |
468 | (overlay-put mouse-secondary-overlay 'face 'secondary-selection) | |
469 | (setq mouse-save-then-kill-posn | |
470 | (list (car kill-ring) start click-posn)))))) | |
e66feb07 | 471 | \f |
8b34e79d | 472 | (defun mouse-buffer-menu (event) |
2d82f7b9 RS |
473 | "Pop up a menu of buffers for selection with the mouse. |
474 | This switches buffers in the window that you clicked on, | |
475 | and selects that window." | |
ec558adc | 476 | (interactive "e") |
8b34e79d RS |
477 | (let ((menu |
478 | (list "Buffer Menu" | |
479 | (cons "Select Buffer" | |
480 | (let ((tail (buffer-list)) | |
af2a85fe | 481 | (maxbuf 0) |
8b34e79d | 482 | head) |
af2a85fe RS |
483 | (while tail |
484 | (or (eq ?\ (aref (buffer-name (car tail)) 0)) | |
485 | (setq maxbuf | |
486 | (max maxbuf | |
487 | (length (buffer-name (car tail)))))) | |
488 | (setq tail (cdr tail))) | |
489 | (setq tail (buffer-list)) | |
8b34e79d RS |
490 | (while tail |
491 | (let ((elt (car tail))) | |
492 | (if (not (string-match "^ " | |
493 | (buffer-name elt))) | |
494 | (setq head (cons | |
495 | (cons | |
496 | (format | |
af2a85fe RS |
497 | (format "%%%ds %%s%%s %%s" |
498 | maxbuf) | |
8b34e79d | 499 | (buffer-name elt) |
af2a85fe RS |
500 | (if (buffer-modified-p elt) |
501 | "*" " ") | |
502 | (save-excursion | |
503 | (set-buffer elt) | |
504 | (if buffer-read-only "%" " ")) | |
8b34e79d RS |
505 | (or (buffer-file-name elt) "")) |
506 | elt) | |
507 | head)))) | |
508 | (setq tail (cdr tail))) | |
509 | (reverse head)))))) | |
2d82f7b9 RS |
510 | (let ((buf (x-popup-menu event menu)) |
511 | (window (posn-window (event-start event)))) | |
512 | (if buf | |
513 | (progn | |
c0bb9f3b | 514 | (or (framep window) (select-window window)) |
2d82f7b9 | 515 | (switch-to-buffer buf)))))) |
72ea54a4 | 516 | \f |
5ba2dc3f | 517 | ;;; These need to be rewritten for the new scroll bar implementation. |
dbc4e1c1 JB |
518 | |
519 | ;;;!! ;; Commands for the scroll bar. | |
520 | ;;;!! | |
521 | ;;;!! (defun mouse-scroll-down (click) | |
522 | ;;;!! (interactive "@e") | |
523 | ;;;!! (scroll-down (1+ (cdr (mouse-coords click))))) | |
524 | ;;;!! | |
525 | ;;;!! (defun mouse-scroll-up (click) | |
526 | ;;;!! (interactive "@e") | |
527 | ;;;!! (scroll-up (1+ (cdr (mouse-coords click))))) | |
528 | ;;;!! | |
529 | ;;;!! (defun mouse-scroll-down-full () | |
530 | ;;;!! (interactive "@") | |
531 | ;;;!! (scroll-down nil)) | |
532 | ;;;!! | |
533 | ;;;!! (defun mouse-scroll-up-full () | |
534 | ;;;!! (interactive "@") | |
535 | ;;;!! (scroll-up nil)) | |
536 | ;;;!! | |
537 | ;;;!! (defun mouse-scroll-move-cursor (click) | |
538 | ;;;!! (interactive "@e") | |
539 | ;;;!! (move-to-window-line (1+ (cdr (mouse-coords click))))) | |
540 | ;;;!! | |
541 | ;;;!! (defun mouse-scroll-absolute (event) | |
542 | ;;;!! (interactive "@e") | |
543 | ;;;!! (let* ((pos (car event)) | |
544 | ;;;!! (position (car pos)) | |
545 | ;;;!! (length (car (cdr pos)))) | |
546 | ;;;!! (if (<= length 0) (setq length 1)) | |
547 | ;;;!! (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size))))) | |
548 | ;;;!! (newpos (* (/ (* (/ (buffer-size) scale-factor) | |
549 | ;;;!! position) | |
550 | ;;;!! length) | |
551 | ;;;!! scale-factor))) | |
552 | ;;;!! (goto-char newpos) | |
553 | ;;;!! (recenter '(4))))) | |
554 | ;;;!! | |
555 | ;;;!! (defun mouse-scroll-left (click) | |
556 | ;;;!! (interactive "@e") | |
557 | ;;;!! (scroll-left (1+ (car (mouse-coords click))))) | |
558 | ;;;!! | |
559 | ;;;!! (defun mouse-scroll-right (click) | |
560 | ;;;!! (interactive "@e") | |
561 | ;;;!! (scroll-right (1+ (car (mouse-coords click))))) | |
562 | ;;;!! | |
563 | ;;;!! (defun mouse-scroll-left-full () | |
564 | ;;;!! (interactive "@") | |
565 | ;;;!! (scroll-left nil)) | |
566 | ;;;!! | |
567 | ;;;!! (defun mouse-scroll-right-full () | |
568 | ;;;!! (interactive "@") | |
569 | ;;;!! (scroll-right nil)) | |
570 | ;;;!! | |
571 | ;;;!! (defun mouse-scroll-move-cursor-horizontally (click) | |
572 | ;;;!! (interactive "@e") | |
573 | ;;;!! (move-to-column (1+ (car (mouse-coords click))))) | |
574 | ;;;!! | |
575 | ;;;!! (defun mouse-scroll-absolute-horizontally (event) | |
576 | ;;;!! (interactive "@e") | |
577 | ;;;!! (let* ((pos (car event)) | |
578 | ;;;!! (position (car pos)) | |
579 | ;;;!! (length (car (cdr pos)))) | |
580 | ;;;!! (set-window-hscroll (selected-window) 33))) | |
581 | ;;;!! | |
582 | ;;;!! (global-set-key [scroll-bar mouse-1] 'mouse-scroll-up) | |
583 | ;;;!! (global-set-key [scroll-bar mouse-2] 'mouse-scroll-absolute) | |
584 | ;;;!! (global-set-key [scroll-bar mouse-3] 'mouse-scroll-down) | |
585 | ;;;!! | |
586 | ;;;!! (global-set-key [vertical-slider mouse-1] 'mouse-scroll-move-cursor) | |
587 | ;;;!! (global-set-key [vertical-slider mouse-2] 'mouse-scroll-move-cursor) | |
588 | ;;;!! (global-set-key [vertical-slider mouse-3] 'mouse-scroll-move-cursor) | |
589 | ;;;!! | |
590 | ;;;!! (global-set-key [thumbup mouse-1] 'mouse-scroll-up-full) | |
591 | ;;;!! (global-set-key [thumbup mouse-2] 'mouse-scroll-up-full) | |
592 | ;;;!! (global-set-key [thumbup mouse-3] 'mouse-scroll-up-full) | |
593 | ;;;!! | |
594 | ;;;!! (global-set-key [thumbdown mouse-1] 'mouse-scroll-down-full) | |
595 | ;;;!! (global-set-key [thumbdown mouse-2] 'mouse-scroll-down-full) | |
596 | ;;;!! (global-set-key [thumbdown mouse-3] 'mouse-scroll-down-full) | |
597 | ;;;!! | |
598 | ;;;!! (global-set-key [horizontal-scroll-bar mouse-1] 'mouse-scroll-left) | |
599 | ;;;!! (global-set-key [horizontal-scroll-bar mouse-2] | |
600 | ;;;!! 'mouse-scroll-absolute-horizontally) | |
601 | ;;;!! (global-set-key [horizontal-scroll-bar mouse-3] 'mouse-scroll-right) | |
602 | ;;;!! | |
603 | ;;;!! (global-set-key [horizontal-slider mouse-1] | |
604 | ;;;!! 'mouse-scroll-move-cursor-horizontally) | |
605 | ;;;!! (global-set-key [horizontal-slider mouse-2] | |
606 | ;;;!! 'mouse-scroll-move-cursor-horizontally) | |
607 | ;;;!! (global-set-key [horizontal-slider mouse-3] | |
608 | ;;;!! 'mouse-scroll-move-cursor-horizontally) | |
609 | ;;;!! | |
610 | ;;;!! (global-set-key [thumbleft mouse-1] 'mouse-scroll-left-full) | |
611 | ;;;!! (global-set-key [thumbleft mouse-2] 'mouse-scroll-left-full) | |
612 | ;;;!! (global-set-key [thumbleft mouse-3] 'mouse-scroll-left-full) | |
613 | ;;;!! | |
614 | ;;;!! (global-set-key [thumbright mouse-1] 'mouse-scroll-right-full) | |
615 | ;;;!! (global-set-key [thumbright mouse-2] 'mouse-scroll-right-full) | |
616 | ;;;!! (global-set-key [thumbright mouse-3] 'mouse-scroll-right-full) | |
617 | ;;;!! | |
618 | ;;;!! (global-set-key [horizontal-scroll-bar S-mouse-2] | |
619 | ;;;!! 'mouse-split-window-horizontally) | |
620 | ;;;!! (global-set-key [mode-line S-mouse-2] | |
621 | ;;;!! 'mouse-split-window-horizontally) | |
622 | ;;;!! (global-set-key [vertical-scroll-bar S-mouse-2] | |
623 | ;;;!! 'mouse-split-window) | |
6b2154de | 624 | \f |
dbc4e1c1 JB |
625 | ;;;!! ;;;; |
626 | ;;;!! ;;;; Here are experimental things being tested. Mouse events | |
627 | ;;;!! ;;;; are of the form: | |
628 | ;;;!! ;;;; ((x y) window screen-part key-sequence timestamp) | |
629 | ;;;!! ;; | |
630 | ;;;!! ;;;; | |
631 | ;;;!! ;;;; Dynamically track mouse coordinates | |
632 | ;;;!! ;;;; | |
633 | ;;;!! ;; | |
634 | ;;;!! ;;(defun track-mouse (event) | |
635 | ;;;!! ;; "Track the coordinates, absolute and relative, of the mouse." | |
636 | ;;;!! ;; (interactive "@e") | |
637 | ;;;!! ;; (while mouse-grabbed | |
638 | ;;;!! ;; (let* ((pos (read-mouse-position (selected-screen))) | |
639 | ;;;!! ;; (abs-x (car pos)) | |
640 | ;;;!! ;; (abs-y (cdr pos)) | |
641 | ;;;!! ;; (relative-coordinate (coordinates-in-window-p | |
642 | ;;;!! ;; (list (car pos) (cdr pos)) | |
643 | ;;;!! ;; (selected-window)))) | |
644 | ;;;!! ;; (if (consp relative-coordinate) | |
645 | ;;;!! ;; (message "mouse: [%d %d], (%d %d)" abs-x abs-y | |
646 | ;;;!! ;; (car relative-coordinate) | |
647 | ;;;!! ;; (car (cdr relative-coordinate))) | |
648 | ;;;!! ;; (message "mouse: [%d %d]" abs-x abs-y))))) | |
649 | ;;;!! | |
650 | ;;;!! ;; | |
651 | ;;;!! ;; Dynamically put a box around the line indicated by point | |
652 | ;;;!! ;; | |
653 | ;;;!! ;; | |
654 | ;;;!! ;;(require 'backquote) | |
655 | ;;;!! ;; | |
656 | ;;;!! ;;(defun mouse-select-buffer-line (event) | |
657 | ;;;!! ;; (interactive "@e") | |
658 | ;;;!! ;; (let ((relative-coordinate | |
659 | ;;;!! ;; (coordinates-in-window-p (car event) (selected-window))) | |
660 | ;;;!! ;; (abs-y (car (cdr (car event))))) | |
661 | ;;;!! ;; (if (consp relative-coordinate) | |
662 | ;;;!! ;; (progn | |
663 | ;;;!! ;; (save-excursion | |
664 | ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate))) | |
665 | ;;;!! ;; (x-draw-rectangle | |
666 | ;;;!! ;; (selected-screen) | |
667 | ;;;!! ;; abs-y 0 | |
668 | ;;;!! ;; (save-excursion | |
669 | ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate))) | |
670 | ;;;!! ;; (end-of-line) | |
671 | ;;;!! ;; (push-mark nil t) | |
672 | ;;;!! ;; (beginning-of-line) | |
673 | ;;;!! ;; (- (region-end) (region-beginning))) 1)) | |
674 | ;;;!! ;; (sit-for 1) | |
675 | ;;;!! ;; (x-erase-rectangle (selected-screen)))))) | |
676 | ;;;!! ;; | |
677 | ;;;!! ;;(defvar last-line-drawn nil) | |
678 | ;;;!! ;;(defvar begin-delim "[^ \t]") | |
679 | ;;;!! ;;(defvar end-delim "[^ \t]") | |
680 | ;;;!! ;; | |
681 | ;;;!! ;;(defun mouse-boxing (event) | |
682 | ;;;!! ;; (interactive "@e") | |
683 | ;;;!! ;; (save-excursion | |
684 | ;;;!! ;; (let ((screen (selected-screen))) | |
685 | ;;;!! ;; (while (= (x-mouse-events) 0) | |
686 | ;;;!! ;; (let* ((pos (read-mouse-position screen)) | |
687 | ;;;!! ;; (abs-x (car pos)) | |
688 | ;;;!! ;; (abs-y (cdr pos)) | |
689 | ;;;!! ;; (relative-coordinate | |
690 | ;;;!! ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y))) | |
691 | ;;;!! ;; (selected-window))) | |
692 | ;;;!! ;; (begin-reg nil) | |
693 | ;;;!! ;; (end-reg nil) | |
694 | ;;;!! ;; (end-column nil) | |
695 | ;;;!! ;; (begin-column nil)) | |
696 | ;;;!! ;; (if (and (consp relative-coordinate) | |
697 | ;;;!! ;; (or (not last-line-drawn) | |
698 | ;;;!! ;; (not (= last-line-drawn abs-y)))) | |
699 | ;;;!! ;; (progn | |
700 | ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate))) | |
701 | ;;;!! ;; (if (= (following-char) 10) | |
702 | ;;;!! ;; () | |
703 | ;;;!! ;; (progn | |
704 | ;;;!! ;; (setq begin-reg (1- (re-search-forward end-delim))) | |
705 | ;;;!! ;; (setq begin-column (1- (current-column))) | |
706 | ;;;!! ;; (end-of-line) | |
707 | ;;;!! ;; (setq end-reg (1+ (re-search-backward begin-delim))) | |
708 | ;;;!! ;; (setq end-column (1+ (current-column))) | |
709 | ;;;!! ;; (message "%s" (buffer-substring begin-reg end-reg)) | |
710 | ;;;!! ;; (x-draw-rectangle screen | |
711 | ;;;!! ;; (setq last-line-drawn abs-y) | |
712 | ;;;!! ;; begin-column | |
713 | ;;;!! ;; (- end-column begin-column) 1)))))))))) | |
714 | ;;;!! ;; | |
715 | ;;;!! ;;(defun mouse-erase-box () | |
716 | ;;;!! ;; (interactive) | |
717 | ;;;!! ;; (if last-line-drawn | |
718 | ;;;!! ;; (progn | |
719 | ;;;!! ;; (x-erase-rectangle (selected-screen)) | |
720 | ;;;!! ;; (setq last-line-drawn nil)))) | |
721 | ;;;!! | |
722 | ;;;!! ;;; (defun test-x-rectangle () | |
723 | ;;;!! ;;; (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap))) | |
724 | ;;;!! ;;; (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing) | |
725 | ;;;!! ;;; (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box)) | |
726 | ;;;!! | |
727 | ;;;!! ;; | |
728 | ;;;!! ;; Here is how to do double clicking in lisp. About to change. | |
729 | ;;;!! ;; | |
730 | ;;;!! | |
731 | ;;;!! (defvar double-start nil) | |
732 | ;;;!! (defconst double-click-interval 300 | |
733 | ;;;!! "Max ticks between clicks") | |
734 | ;;;!! | |
735 | ;;;!! (defun double-down (event) | |
736 | ;;;!! (interactive "@e") | |
737 | ;;;!! (if double-start | |
738 | ;;;!! (let ((interval (- (nth 4 event) double-start))) | |
739 | ;;;!! (if (< interval double-click-interval) | |
740 | ;;;!! (progn | |
741 | ;;;!! (backward-up-list 1) | |
742 | ;;;!! ;; (message "Interval %d" interval) | |
743 | ;;;!! (sleep-for 1))) | |
744 | ;;;!! (setq double-start nil)) | |
745 | ;;;!! (setq double-start (nth 4 event)))) | |
746 | ;;;!! | |
747 | ;;;!! (defun double-up (event) | |
748 | ;;;!! (interactive "@e") | |
749 | ;;;!! (and double-start | |
750 | ;;;!! (> (- (nth 4 event ) double-start) double-click-interval) | |
751 | ;;;!! (setq double-start nil))) | |
752 | ;;;!! | |
753 | ;;;!! ;;; (defun x-test-doubleclick () | |
754 | ;;;!! ;;; (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap))) | |
755 | ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left 'double-down) | |
756 | ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left-up 'double-up)) | |
757 | ;;;!! | |
758 | ;;;!! ;; | |
5ba2dc3f | 759 | ;;;!! ;; This scrolls while button is depressed. Use preferable in scroll bar. |
dbc4e1c1 JB |
760 | ;;;!! ;; |
761 | ;;;!! | |
762 | ;;;!! (defvar scrolled-lines 0) | |
763 | ;;;!! (defconst scroll-speed 1) | |
764 | ;;;!! | |
765 | ;;;!! (defun incr-scroll-down (event) | |
766 | ;;;!! (interactive "@e") | |
767 | ;;;!! (setq scrolled-lines 0) | |
768 | ;;;!! (incremental-scroll scroll-speed)) | |
769 | ;;;!! | |
770 | ;;;!! (defun incr-scroll-up (event) | |
771 | ;;;!! (interactive "@e") | |
772 | ;;;!! (setq scrolled-lines 0) | |
773 | ;;;!! (incremental-scroll (- scroll-speed))) | |
774 | ;;;!! | |
775 | ;;;!! (defun incremental-scroll (n) | |
776 | ;;;!! (while (= (x-mouse-events) 0) | |
777 | ;;;!! (setq scrolled-lines (1+ (* scroll-speed scrolled-lines))) | |
778 | ;;;!! (scroll-down n) | |
779 | ;;;!! (sit-for 300 t))) | |
780 | ;;;!! | |
781 | ;;;!! (defun incr-scroll-stop (event) | |
782 | ;;;!! (interactive "@e") | |
783 | ;;;!! (message "Scrolled %d lines" scrolled-lines) | |
784 | ;;;!! (setq scrolled-lines 0) | |
785 | ;;;!! (sleep-for 1)) | |
786 | ;;;!! | |
787 | ;;;!! ;;; (defun x-testing-scroll () | |
788 | ;;;!! ;;; (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix))) | |
789 | ;;;!! ;;; (define-key scrolling-map mouse-button-left 'incr-scroll-down) | |
790 | ;;;!! ;;; (define-key scrolling-map mouse-button-right 'incr-scroll-up) | |
791 | ;;;!! ;;; (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop) | |
792 | ;;;!! ;;; (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop))) | |
793 | ;;;!! | |
794 | ;;;!! ;; | |
795 | ;;;!! ;; Some playthings suitable for picture mode? They need work. | |
796 | ;;;!! ;; | |
797 | ;;;!! | |
798 | ;;;!! (defun mouse-kill-rectangle (event) | |
799 | ;;;!! "Kill the rectangle between point and the mouse cursor." | |
800 | ;;;!! (interactive "@e") | |
801 | ;;;!! (let ((point-save (point))) | |
802 | ;;;!! (save-excursion | |
803 | ;;;!! (mouse-set-point event) | |
804 | ;;;!! (push-mark nil t) | |
805 | ;;;!! (if (> point-save (point)) | |
806 | ;;;!! (kill-rectangle (point) point-save) | |
807 | ;;;!! (kill-rectangle point-save (point)))))) | |
808 | ;;;!! | |
809 | ;;;!! (defun mouse-open-rectangle (event) | |
810 | ;;;!! "Kill the rectangle between point and the mouse cursor." | |
811 | ;;;!! (interactive "@e") | |
812 | ;;;!! (let ((point-save (point))) | |
813 | ;;;!! (save-excursion | |
814 | ;;;!! (mouse-set-point event) | |
815 | ;;;!! (push-mark nil t) | |
816 | ;;;!! (if (> point-save (point)) | |
817 | ;;;!! (open-rectangle (point) point-save) | |
818 | ;;;!! (open-rectangle point-save (point)))))) | |
819 | ;;;!! | |
820 | ;;;!! ;; Must be a better way to do this. | |
821 | ;;;!! | |
822 | ;;;!! (defun mouse-multiple-insert (n char) | |
823 | ;;;!! (while (> n 0) | |
824 | ;;;!! (insert char) | |
825 | ;;;!! (setq n (1- n)))) | |
826 | ;;;!! | |
827 | ;;;!! ;; What this could do is not finalize until button was released. | |
828 | ;;;!! | |
829 | ;;;!! (defun mouse-move-text (event) | |
830 | ;;;!! "Move text from point to cursor position, inserting spaces." | |
831 | ;;;!! (interactive "@e") | |
832 | ;;;!! (let* ((relative-coordinate | |
833 | ;;;!! (coordinates-in-window-p (car event) (selected-window)))) | |
834 | ;;;!! (if (consp relative-coordinate) | |
835 | ;;;!! (cond ((> (current-column) (car relative-coordinate)) | |
836 | ;;;!! (delete-char | |
837 | ;;;!! (- (car relative-coordinate) (current-column)))) | |
838 | ;;;!! ((< (current-column) (car relative-coordinate)) | |
839 | ;;;!! (mouse-multiple-insert | |
840 | ;;;!! (- (car relative-coordinate) (current-column)) " ")) | |
841 | ;;;!! ((= (current-column) (car relative-coordinate)) (ding)))))) | |
07a78410 | 842 | \f |
f936ae06 RS |
843 | ;; Choose a completion with the mouse. |
844 | ||
845 | (defun mouse-choose-completion (event) | |
846 | (interactive "e") | |
847 | (let (choice) | |
848 | (save-excursion | |
849 | (set-buffer (window-buffer (posn-window (event-start event)))) | |
850 | (save-excursion | |
851 | (goto-char (posn-point (event-start event))) | |
852 | (skip-chars-backward "^ \t\n") | |
853 | (let ((beg (point))) | |
854 | (skip-chars-forward "^ \t\n") | |
855 | (setq choice (buffer-substring beg (point)))))) | |
856 | (save-excursion | |
857 | (set-buffer (window-buffer (minibuffer-window))) | |
858 | (goto-char (max (point-min) (- (point-max) (length choice)))) | |
859 | (while (and (not (eobp)) | |
860 | (let ((tail (buffer-substring (point) (point-max)))) | |
861 | (not (string= tail (substring choice 0 (length tail)))))) | |
862 | (forward-char 1)) | |
863 | (insert choice) | |
864 | (delete-region (point) (point-max))))) | |
865 | \f | |
07a78410 RS |
866 | ;; Font selection. |
867 | ||
868 | (defvar x-fixed-font-alist | |
869 | '("Font menu" | |
870 | ("Misc" | |
fa21fdec RS |
871 | ("6x10" "-misc-fixed-medium-r-semicondensed--10-110-75-75-c-60-*-1") |
872 | ("6x12" "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-*-1") | |
873 | ("6x13" "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-1") | |
874 | ("lucida 13" | |
875 | "-b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-*-1") | |
876 | ("7x13" "-misc-fixed-medium-r-normal--13-120-75-75-c-70-*-1") | |
877 | ("7x14" "-misc-fixed-medium-r-normal--14-130-75-75-c-70-*-1") | |
878 | ("9x15" "-misc-fixed-medium-r-normal--15-140-*-*-c-*-*-1") | |
879 | ("") | |
880 | ("clean 8x8" "-schumacher-clean-medium-r-normal--*-80-*-*-c-*-*-1") | |
881 | ("clean 8x14" "-schumacher-clean-medium-r-normal--*-140-*-*-c-*-*-1") | |
882 | ("clean 8x10" "-schumacher-clean-medium-r-normal--*-100-*-*-c-*-*-1") | |
883 | ("clean 8x16" "-schumacher-clean-medium-r-normal--*-160-*-*-c-*-*-1") | |
884 | ("") | |
885 | ("sony 8x16" "-sony-fixed-medium-r-normal--16-120-100-100-c-80-*-1") | |
886 | ("") | |
07a78410 | 887 | ("fixed" "fixed") |
07a78410 RS |
888 | ("10x20" "10x20") |
889 | ("11x18" "11x18") | |
890 | ("12x24" "12x24")) | |
891 | ;;; We don't seem to have these; who knows what they are. | |
892 | ;;; ("fg-18" "fg-18") | |
893 | ;;; ("fg-25" "fg-25") | |
894 | ;;; ("lucidasanstypewriter-12" "lucidasanstypewriter-12") | |
895 | ;;; ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14") | |
896 | ;;; ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24") | |
897 | ;;; ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1") | |
898 | ;;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*") | |
899 | ("Courier" | |
82c048a9 RS |
900 | ("8" "-adobe-courier-medium-r-normal--*-80-*-*-m-*-iso8859-1") |
901 | ("10" "-adobe-courier-medium-r-normal--*-100-*-*-m-*-iso8859-1") | |
902 | ("12" "-adobe-courier-medium-r-normal--*-120-*-*-m-*-iso8859-1") | |
903 | ("14" "-adobe-courier-medium-r-normal--*-140-*-*-m-*-iso8859-1") | |
904 | ("18" "-adobe-courier-medium-r-normal--*-180-*-*-m-*-iso8859-1") | |
905 | ("24" "-adobe-courier-medium-r-normal--*-240-*-*-m-*-iso8859-1") | |
906 | ("8 bold" "-adobe-courier-bold-r-normal--*-80-*-*-m-*-iso8859-1") | |
907 | ("10 bold" "-adobe-courier-bold-r-normal--*-100-*-*-m-*-iso8859-1") | |
908 | ("12 bold" "-adobe-courier-bold-r-normal--*-120-*-*-m-*-iso8859-1") | |
909 | ("14 bold" "-adobe-courier-bold-r-normal--*-140-*-*-m-*-iso8859-1") | |
910 | ("18 bold" "-adobe-courier-bold-r-normal--*-180-*-*-m-*-iso8859-1") | |
911 | ("24 bold" "-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1") | |
912 | ("8 slant" "-adobe-courier-medium-o-normal--*-80-*-*-m-*-iso8859-1") | |
913 | ("10 slant" "-adobe-courier-medium-o-normal--*-100-*-*-m-*-iso8859-1") | |
914 | ("12 slant" "-adobe-courier-medium-o-normal--*-120-*-*-m-*-iso8859-1") | |
915 | ("14 slant" "-adobe-courier-medium-o-normal--*-140-*-*-m-*-iso8859-1") | |
916 | ("18 slant" "-adobe-courier-medium-o-normal--*-180-*-*-m-*-iso8859-1") | |
917 | ("24 slant" "-adobe-courier-medium-o-normal--*-240-*-*-m-*-iso8859-1") | |
918 | ("8 bold slant" "-adobe-courier-bold-o-normal--*-80-*-*-m-*-iso8859-1") | |
919 | ("10 bold slant" "-adobe-courier-bold-o-normal--*-100-*-*-m-*-iso8859-1") | |
920 | ("12 bold slant" "-adobe-courier-bold-o-normal--*-120-*-*-m-*-iso8859-1") | |
921 | ("14 bold slant" "-adobe-courier-bold-o-normal--*-140-*-*-m-*-iso8859-1") | |
922 | ("18 bold slant" "-adobe-courier-bold-o-normal--*-180-*-*-m-*-iso8859-1") | |
923 | ("24 bold slant" "-adobe-courier-bold-o-normal--*-240-*-*-m-*-iso8859-1")) | |
07a78410 RS |
924 | ) |
925 | "X fonts suitable for use in Emacs.") | |
926 | ||
dbc4e1c1 | 927 | (defun mouse-set-font (&optional font) |
07a78410 RS |
928 | "Select an emacs font from a list of known good fonts" |
929 | (interactive | |
930 | (x-popup-menu last-nonmenu-event x-fixed-font-alist)) | |
dbc4e1c1 | 931 | (if font |
26d86f19 RS |
932 | (progn (modify-frame-parameters (selected-frame) |
933 | (list (cons 'font font))) | |
934 | ;; Update some standard faces too. | |
935 | (set-face-font 'bold nil (selected-frame)) | |
936 | (make-face-bold 'bold (selected-frame) t) | |
937 | (set-face-font 'italic nil (selected-frame)) | |
938 | (make-face-italic 'italic (selected-frame) t) | |
939 | (set-face-font 'bold-italic nil (selected-frame)) | |
940 | (make-face-bold-italic 'bold-italic (selected-frame) t)))) | |
cc0a8174 JB |
941 | \f |
942 | ;;; Bindings for mouse commands. | |
943 | ||
fcfc3c63 | 944 | (define-key global-map [down-mouse-1] 'mouse-drag-region) |
dbc4e1c1 | 945 | (global-set-key [mouse-1] 'mouse-set-point) |
dbc4e1c1 | 946 | (global-set-key [drag-mouse-1] 'mouse-set-region) |
fcfc3c63 | 947 | |
dbc4e1c1 JB |
948 | (global-set-key [mouse-2] 'mouse-yank-at-click) |
949 | (global-set-key [mouse-3] 'mouse-save-then-kill) | |
8b34e79d | 950 | |
dbc4e1c1 JB |
951 | ;; By binding these to down-going events, we let the user use the up-going |
952 | ;; event to make the selection, saving a click. | |
953 | (global-set-key [C-down-mouse-1] 'mouse-buffer-menu) | |
954 | (global-set-key [C-down-mouse-3] 'mouse-set-font) | |
07a78410 | 955 | |
8b34e79d RS |
956 | ;; Replaced with dragging mouse-1 |
957 | ;; (global-set-key [S-mouse-1] 'mouse-set-mark) | |
947da0c4 | 958 | |
dbc4e1c1 JB |
959 | (global-set-key [mode-line mouse-1] 'mouse-delete-other-windows) |
960 | (global-set-key [mode-line mouse-3] 'mouse-delete-window) | |
961 | (global-set-key [mode-line S-mouse-2] 'mouse-split-window-horizontally) | |
8b34e79d | 962 | \f |
6b2154de RS |
963 | ;; Define the mouse help menu tree. |
964 | ||
8b34e79d | 965 | (defvar help-menu-map '(keymap "Help")) |
dbc4e1c1 JB |
966 | (global-set-key [C-down-mouse-2] help-menu-map) |
967 | ||
968 | (defvar help-apropos-map (make-sparse-keymap "Is there a command that...")) | |
969 | (defvar help-keys-map (make-sparse-keymap "Key Commands <==> Functions")) | |
970 | (defvar help-manual-map (make-sparse-keymap "Manual and tutorial")) | |
971 | (defvar help-misc-map (make-sparse-keymap "Odds and ends")) | |
972 | (defvar help-modes-map (make-sparse-keymap "Modes")) | |
973 | (defvar help-admin-map (make-sparse-keymap "Administrivia")) | |
8b34e79d | 974 | |
e7691e9c | 975 | (define-key help-menu-map [apropos] |
6ec3899e | 976 | (cons "@Is there a command that..." help-apropos-map)) |
e7691e9c | 977 | (define-key help-menu-map [keys] |
6ec3899e | 978 | (cons "@Key Commands <==> Functions" help-keys-map)) |
e7691e9c | 979 | (define-key help-menu-map [manuals] |
6ec3899e | 980 | (cons "@Manual and tutorial" help-manual-map)) |
e7691e9c | 981 | (define-key help-menu-map [misc] |
6ec3899e | 982 | (cons "@Odds and ends" help-misc-map)) |
e7691e9c | 983 | (define-key help-menu-map [modes] |
6ec3899e | 984 | (cons "@Modes" help-modes-map)) |
e7691e9c | 985 | (define-key help-menu-map [admin] |
6ec3899e | 986 | (cons "@Administrivia" help-admin-map)) |
8b34e79d RS |
987 | |
988 | (define-key help-apropos-map "c" '("Command Apropos" . command-apropos)) | |
989 | (define-key help-apropos-map "a" '("Apropos" . apropos)) | |
990 | ||
991 | (define-key help-keys-map "b" | |
992 | '("List all keystroke commands" . describe-bindings)) | |
993 | (define-key help-keys-map "c" | |
994 | '("Describe key briefly" . describe-key-briefly)) | |
995 | (define-key help-keys-map "k" | |
996 | '("Describe key verbose" . describe-key)) | |
997 | (define-key help-keys-map "f" | |
998 | '("Describe Lisp function" . describe-function)) | |
999 | (define-key help-keys-map "w" | |
1000 | '("Where is this command" . where-is)) | |
1001 | ||
1002 | (define-key help-manual-map "i" '("Info system" . info)) | |
1003 | (define-key help-manual-map "t" | |
1004 | '("Invoke Emacs tutorial" . help-with-tutorial)) | |
1005 | ||
1006 | (define-key help-misc-map "l" '("Last 100 Keystrokes" . view-lossage)) | |
1007 | (define-key help-misc-map "s" '("Describe syntax table" . describe-syntax)) | |
1008 | ||
1009 | (define-key help-modes-map "m" | |
1010 | '("Describe current major mode" . describe-mode)) | |
1011 | (define-key help-modes-map "b" | |
1012 | '("List all keystroke commands" . describe-bindings)) | |
1013 | ||
1014 | (define-key help-admin-map "n" | |
1015 | '("view Emacs news" . view-emacs-news)) | |
1016 | (define-key help-admin-map "l" | |
1017 | '("View the GNU Emacs license" . describe-copying)) | |
1018 | (define-key help-admin-map "d" | |
1019 | '("Describe distribution" . describe-distribution)) | |
1020 | (define-key help-admin-map "w" | |
1021 | '("Describe (non)warranty" . describe-no-warranty)) | |
49116ac0 JB |
1022 | |
1023 | (provide 'mouse) | |
1024 | ||
6594deb0 | 1025 | ;;; mouse.el ends here |