27db75367587ef6e0d18849b36592d87f2aa4e2e
[bpt/emacs.git] / lisp / mouse.el
1 ;;; mouse.el --- window system-independent mouse support.
2
3 ;;; Copyright (C) 1988, 1992 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: hardware
7
8 ;;; This file is part of GNU Emacs.
9
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
12 ;;; the Free Software Foundation; either version 2, or (at your option)
13 ;;; any later version.
14
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.
19
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.
23
24 \f
25 ;;; Utility functions.
26
27 (defsubst mouse-movement-p (object)
28 "Return non-nil if OBJECT is a mouse movement event."
29 (and (consp object)
30 (eq (car object) 'mouse-movement)))
31
32 (defsubst event-start (event)
33 "Return the starting position of EVENT.
34 If EVENT is a mouse press or a mouse click, this returns the location
35 of the event.
36 If EVENT is a drag, this returns the drag's starting position.
37 The return value is of the form
38 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
39 The `posn-' functions access elements of such lists."
40 (nth 1 event))
41
42 (defsubst event-end (event)
43 "Return the ending location of EVENT. EVENT should be a drag event.
44 The return value is of the form
45 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
46 The `posn-' functions access elements of such lists."
47 (nth 2 event))
48
49 (defsubst posn-window (position)
50 "Return the window in POSITION.
51 POSITION should be a list of the form
52 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
53 as returned by the `event-start' and `event-end' functions."
54 (nth 0 position))
55
56 (defsubst posn-point (position)
57 "Return the buffer location in POSITION.
58 POSITION should be a list of the form
59 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
60 as returned by the `event-start' and `event-end' functions."
61 (nth 1 position))
62
63 (defsubst posn-col-row (position)
64 "Return the row and column in POSITION.
65 POSITION should be a list of the form
66 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
67 as returned by the `event-start' and `event-end' functions."
68 (nth 2 position))
69
70 (defsubst posn-timestamp (position)
71 "Return the timestamp of POSITION.
72 POSITION should be a list of the form
73 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
74 nas returned by the `event-start' and `event-end' functions."
75 (nth 3 position))
76
77 ;;; Indent track-mouse like progn.
78 (put 'track-mouse 'lisp-indent-function 0)
79
80 \f
81 (defun mouse-delete-window (click)
82 "Delete the window you click on.
83 This must be bound to a mouse click."
84 (interactive "e")
85 (delete-window (posn-window (event-start click))))
86
87 (defun mouse-tear-off-window (click)
88 "Delete the window clicked on, and create a new frame displaying its buffer."
89 (interactive "e")
90 (let* ((window (posn-window (event-start click)))
91 (buf (window-buffer window))
92 (frame (new-frame)))
93 (select-frame frame)
94 (switch-to-buffer buf)
95 (delete-window window)))
96
97 (defun mouse-delete-other-windows ()
98 "Delete all window except the one you click on."
99 (interactive "@")
100 (delete-other-windows))
101
102 (defun mouse-split-window-vertically (click)
103 "Select Emacs window mouse is on, then split it vertically in half.
104 The window is split at the line clicked on.
105 This command must be bound to a mouse click."
106 (interactive "@e")
107 (let ((start (event-start click)))
108 (select-window (posn-window start))
109 (split-window-vertically (1+ (cdr (posn-col-row click))))))
110
111 (defun mouse-split-window-horizontally (click)
112 "Select Emacs window mouse is on, then split it horizontally in half.
113 The window is split at the column clicked on.
114 This command must be bound to a mouse click."
115 (interactive "@e")
116 (split-window-horizontally (1+ (car (mouse-coords click)))))
117
118 (defun mouse-set-point (click)
119 "Move point to the position clicked on with the mouse.
120 This must be bound to a mouse click."
121 (interactive "e")
122 (let ((posn (event-start click)))
123 (select-window (posn-window posn))
124 (if (numberp (posn-point posn))
125 (goto-char (posn-point posn)))))
126
127 (defun mouse-set-region (click)
128 "Set the region to the text that the mouse is dragged over.
129 This must be bound to a mouse click."
130 (interactive "e")
131 (let ((posn (event-start click))
132 (end (event-end click)))
133 (select-window (posn-window posn))
134 (if (numberp (posn-point posn))
135 (goto-char (posn-point posn)))
136 (sit-for 1)
137 (push-mark)
138 (if (numberp (posn-point end))
139 (goto-char (posn-point end)))))
140
141 (defun mouse-set-mark (click)
142 "Set mark at the position clicked on with the mouse.
143 Display cursor at that position for a second.
144 This must be bound to a mouse click."
145 (interactive "e")
146 (let ((point-save (point)))
147 (unwind-protect
148 (progn (mouse-set-point click)
149 (push-mark nil t)
150 (sit-for 1))
151 (goto-char point-save))))
152
153 (defun mouse-kill (click)
154 "Kill the region between point and the mouse click.
155 The text is saved in the kill ring, as with \\[kill-region]."
156 (interactive "e")
157 (let ((click-posn (posn-point (event-start click))))
158 (if (numberp click-posn)
159 (kill-region (min (point) click-posn)
160 (max (point) click-posn)))))
161
162 (defun mouse-yank-at-click (click arg)
163 "Insert the last stretch of killed text at the position clicked on.
164 Prefix arguments are interpreted as with \\[yank]."
165 (interactive "e\nP")
166 (mouse-set-point click)
167 (yank arg))
168
169 (defun mouse-kill-ring-save (click)
170 "Copy the region between point and the mouse click in the kill ring.
171 This does not delete the region; it acts like \\[kill-ring-save]."
172 (interactive "e")
173 (mouse-set-mark click)
174 (call-interactively 'kill-ring-save))
175
176 (defun mouse-save-then-kill (click)
177 "Save text to point in kill ring; the second time, kill the text.
178 If the text between point and the mouse is the same as what's
179 at the front of the kill ring, this deletes the text.
180 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
181 which prepares for a second click to delete the text."
182 (interactive "e")
183 (let ((click-posn (posn-point (event-start click))))
184 (if (string= (buffer-substring (point) click-posn) (car kill-ring))
185 ;; If this text was already saved in kill ring,
186 ;; now delete it from the buffer.
187 (progn
188 (let ((buffer-undo-list t))
189 (delete-region (point) (mark)))
190 ;; Make the undo list by hand so it is shared.
191 (setq buffer-undo-list
192 (cons (cons (car kill-ring) (point)) buffer-undo-list)))
193 ;; Otherwise, save this region.
194 (mouse-set-mark click)
195 (call-interactively 'kill-ring-save))))
196
197 (defun mouse-buffer-menu (event)
198 "Pop up a menu of buffers for selection with the mouse.
199 This switches buffers in the window that you clicked on,
200 and selects that window."
201 (interactive "e")
202 (let ((menu
203 (list "Buffer Menu"
204 (cons "Select Buffer"
205 (let ((tail (buffer-list))
206 head)
207 (while tail
208 (let ((elt (car tail)))
209 (if (not (string-match "^ "
210 (buffer-name elt)))
211 (setq head (cons
212 (cons
213 (format
214 "%14s %s"
215 (buffer-name elt)
216 (or (buffer-file-name elt) ""))
217 elt)
218 head))))
219 (setq tail (cdr tail)))
220 (reverse head))))))
221 (let ((buf (x-popup-menu event menu))
222 (window (posn-window (event-start event))))
223 (if buf
224 (progn
225 (select-window window)
226 (switch-to-buffer buf))))))
227 \f
228 ;; Commands for the scroll bar.
229
230 (defun mouse-scroll-down (click)
231 (interactive "@e")
232 (scroll-down (1+ (cdr (mouse-coords click)))))
233
234 (defun mouse-scroll-up (click)
235 (interactive "@e")
236 (scroll-up (1+ (cdr (mouse-coords click)))))
237
238 (defun mouse-scroll-down-full ()
239 (interactive "@")
240 (scroll-down nil))
241
242 (defun mouse-scroll-up-full ()
243 (interactive "@")
244 (scroll-up nil))
245
246 (defun mouse-scroll-move-cursor (click)
247 (interactive "@e")
248 (move-to-window-line (1+ (cdr (mouse-coords click)))))
249
250 (defun mouse-scroll-absolute (event)
251 (interactive "@e")
252 (let* ((pos (car event))
253 (position (car pos))
254 (length (car (cdr pos))))
255 (if (<= length 0) (setq length 1))
256 (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size)))))
257 (newpos (* (/ (* (/ (buffer-size) scale-factor)
258 position)
259 length)
260 scale-factor)))
261 (goto-char newpos)
262 (recenter '(4)))))
263
264 (defun mouse-scroll-left (click)
265 (interactive "@e")
266 (scroll-left (1+ (car (mouse-coords click)))))
267
268 (defun mouse-scroll-right (click)
269 (interactive "@e")
270 (scroll-right (1+ (car (mouse-coords click)))))
271
272 (defun mouse-scroll-left-full ()
273 (interactive "@")
274 (scroll-left nil))
275
276 (defun mouse-scroll-right-full ()
277 (interactive "@")
278 (scroll-right nil))
279
280 (defun mouse-scroll-move-cursor-horizontally (click)
281 (interactive "@e")
282 (move-to-column (1+ (car (mouse-coords click)))))
283
284 (defun mouse-scroll-absolute-horizontally (event)
285 (interactive "@e")
286 (let* ((pos (car event))
287 (position (car pos))
288 (length (car (cdr pos))))
289 (set-window-hscroll (selected-window) 33)))
290
291 (global-set-key [scroll-bar mouse-1] 'mouse-scroll-up)
292 (global-set-key [scroll-bar mouse-2] 'mouse-scroll-absolute)
293 (global-set-key [scroll-bar mouse-3] 'mouse-scroll-down)
294
295 (global-set-key [vertical-slider mouse-1] 'mouse-scroll-move-cursor)
296 (global-set-key [vertical-slider mouse-2] 'mouse-scroll-move-cursor)
297 (global-set-key [vertical-slider mouse-3] 'mouse-scroll-move-cursor)
298
299 (global-set-key [thumbup mouse-1] 'mouse-scroll-up-full)
300 (global-set-key [thumbup mouse-2] 'mouse-scroll-up-full)
301 (global-set-key [thumbup mouse-3] 'mouse-scroll-up-full)
302
303 (global-set-key [thumbdown mouse-1] 'mouse-scroll-down-full)
304 (global-set-key [thumbdown mouse-2] 'mouse-scroll-down-full)
305 (global-set-key [thumbdown mouse-3] 'mouse-scroll-down-full)
306
307 (global-set-key [horizontal-scroll-bar mouse-1] 'mouse-scroll-left)
308 (global-set-key [horizontal-scroll-bar mouse-2]
309 'mouse-scroll-absolute-horizontally)
310 (global-set-key [horizontal-scroll-bar mouse-3] 'mouse-scroll-right)
311
312 (global-set-key [horizontal-slider mouse-1]
313 'mouse-scroll-move-cursor-horizontally)
314 (global-set-key [horizontal-slider mouse-2]
315 'mouse-scroll-move-cursor-horizontally)
316 (global-set-key [horizontal-slider mouse-3]
317 'mouse-scroll-move-cursor-horizontally)
318
319 (global-set-key [thumbleft mouse-1] 'mouse-scroll-left-full)
320 (global-set-key [thumbleft mouse-2] 'mouse-scroll-left-full)
321 (global-set-key [thumbleft mouse-3] 'mouse-scroll-left-full)
322
323 (global-set-key [thumbright mouse-1] 'mouse-scroll-right-full)
324 (global-set-key [thumbright mouse-2] 'mouse-scroll-right-full)
325 (global-set-key [thumbright mouse-3] 'mouse-scroll-right-full)
326
327 (global-set-key [horizontal-scroll-bar S-mouse-2]
328 'mouse-split-window-horizontally)
329 (global-set-key [mode-line S-mouse-2]
330 'mouse-split-window-horizontally)
331 (global-set-key [vertical-scroll-bar S-mouse-2]
332 'mouse-split-window)
333 \f
334 ;;;;
335 ;;;; Here are experimental things being tested. Mouse events
336 ;;;; are of the form:
337 ;;;; ((x y) window screen-part key-sequence timestamp)
338 ;;
339 ;;;;
340 ;;;; Dynamically track mouse coordinates
341 ;;;;
342 ;;
343 ;;(defun track-mouse (event)
344 ;; "Track the coordinates, absolute and relative, of the mouse."
345 ;; (interactive "@e")
346 ;; (while mouse-grabbed
347 ;; (let* ((pos (read-mouse-position (selected-screen)))
348 ;; (abs-x (car pos))
349 ;; (abs-y (cdr pos))
350 ;; (relative-coordinate (coordinates-in-window-p
351 ;; (list (car pos) (cdr pos))
352 ;; (selected-window))))
353 ;; (if (consp relative-coordinate)
354 ;; (message "mouse: [%d %d], (%d %d)" abs-x abs-y
355 ;; (car relative-coordinate)
356 ;; (car (cdr relative-coordinate)))
357 ;; (message "mouse: [%d %d]" abs-x abs-y)))))
358
359 ;;
360 ;; Dynamically put a box around the line indicated by point
361 ;;
362 ;;
363 ;;(require 'backquote)
364 ;;
365 ;;(defun mouse-select-buffer-line (event)
366 ;; (interactive "@e")
367 ;; (let ((relative-coordinate
368 ;; (coordinates-in-window-p (car event) (selected-window)))
369 ;; (abs-y (car (cdr (car event)))))
370 ;; (if (consp relative-coordinate)
371 ;; (progn
372 ;; (save-excursion
373 ;; (move-to-window-line (car (cdr relative-coordinate)))
374 ;; (x-draw-rectangle
375 ;; (selected-screen)
376 ;; abs-y 0
377 ;; (save-excursion
378 ;; (move-to-window-line (car (cdr relative-coordinate)))
379 ;; (end-of-line)
380 ;; (push-mark nil t)
381 ;; (beginning-of-line)
382 ;; (- (region-end) (region-beginning))) 1))
383 ;; (sit-for 1)
384 ;; (x-erase-rectangle (selected-screen))))))
385 ;;
386 ;;(defvar last-line-drawn nil)
387 ;;(defvar begin-delim "[^ \t]")
388 ;;(defvar end-delim "[^ \t]")
389 ;;
390 ;;(defun mouse-boxing (event)
391 ;; (interactive "@e")
392 ;; (save-excursion
393 ;; (let ((screen (selected-screen)))
394 ;; (while (= (x-mouse-events) 0)
395 ;; (let* ((pos (read-mouse-position screen))
396 ;; (abs-x (car pos))
397 ;; (abs-y (cdr pos))
398 ;; (relative-coordinate
399 ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y)))
400 ;; (selected-window)))
401 ;; (begin-reg nil)
402 ;; (end-reg nil)
403 ;; (end-column nil)
404 ;; (begin-column nil))
405 ;; (if (and (consp relative-coordinate)
406 ;; (or (not last-line-drawn)
407 ;; (not (= last-line-drawn abs-y))))
408 ;; (progn
409 ;; (move-to-window-line (car (cdr relative-coordinate)))
410 ;; (if (= (following-char) 10)
411 ;; ()
412 ;; (progn
413 ;; (setq begin-reg (1- (re-search-forward end-delim)))
414 ;; (setq begin-column (1- (current-column)))
415 ;; (end-of-line)
416 ;; (setq end-reg (1+ (re-search-backward begin-delim)))
417 ;; (setq end-column (1+ (current-column)))
418 ;; (message "%s" (buffer-substring begin-reg end-reg))
419 ;; (x-draw-rectangle screen
420 ;; (setq last-line-drawn abs-y)
421 ;; begin-column
422 ;; (- end-column begin-column) 1))))))))))
423 ;;
424 ;;(defun mouse-erase-box ()
425 ;; (interactive)
426 ;; (if last-line-drawn
427 ;; (progn
428 ;; (x-erase-rectangle (selected-screen))
429 ;; (setq last-line-drawn nil))))
430
431 ;;; (defun test-x-rectangle ()
432 ;;; (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap)))
433 ;;; (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing)
434 ;;; (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box))
435
436 ;;
437 ;; Here is how to do double clicking in lisp. About to change.
438 ;;
439
440 (defvar double-start nil)
441 (defconst double-click-interval 300
442 "Max ticks between clicks")
443
444 (defun double-down (event)
445 (interactive "@e")
446 (if double-start
447 (let ((interval (- (nth 4 event) double-start)))
448 (if (< interval double-click-interval)
449 (progn
450 (backward-up-list 1)
451 ;; (message "Interval %d" interval)
452 (sleep-for 1)))
453 (setq double-start nil))
454 (setq double-start (nth 4 event))))
455
456 (defun double-up (event)
457 (interactive "@e")
458 (and double-start
459 (> (- (nth 4 event ) double-start) double-click-interval)
460 (setq double-start nil)))
461
462 ;;; (defun x-test-doubleclick ()
463 ;;; (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap)))
464 ;;; (define-key doubleclick-test-map mouse-button-left 'double-down)
465 ;;; (define-key doubleclick-test-map mouse-button-left-up 'double-up))
466
467 ;;
468 ;; This scrolls while button is depressed. Use preferable in scrollbar.
469 ;;
470
471 (defvar scrolled-lines 0)
472 (defconst scroll-speed 1)
473
474 (defun incr-scroll-down (event)
475 (interactive "@e")
476 (setq scrolled-lines 0)
477 (incremental-scroll scroll-speed))
478
479 (defun incr-scroll-up (event)
480 (interactive "@e")
481 (setq scrolled-lines 0)
482 (incremental-scroll (- scroll-speed)))
483
484 (defun incremental-scroll (n)
485 (while (= (x-mouse-events) 0)
486 (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
487 (scroll-down n)
488 (sit-for 300 t)))
489
490 (defun incr-scroll-stop (event)
491 (interactive "@e")
492 (message "Scrolled %d lines" scrolled-lines)
493 (setq scrolled-lines 0)
494 (sleep-for 1))
495
496 ;;; (defun x-testing-scroll ()
497 ;;; (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix)))
498 ;;; (define-key scrolling-map mouse-button-left 'incr-scroll-down)
499 ;;; (define-key scrolling-map mouse-button-right 'incr-scroll-up)
500 ;;; (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop)
501 ;;; (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop)))
502
503 ;;
504 ;; Some playthings suitable for picture mode? They need work.
505 ;;
506
507 (defun mouse-kill-rectangle (event)
508 "Kill the rectangle between point and the mouse cursor."
509 (interactive "@e")
510 (let ((point-save (point)))
511 (save-excursion
512 (mouse-set-point event)
513 (push-mark nil t)
514 (if (> point-save (point))
515 (kill-rectangle (point) point-save)
516 (kill-rectangle point-save (point))))))
517
518 (defun mouse-open-rectangle (event)
519 "Kill the rectangle between point and the mouse cursor."
520 (interactive "@e")
521 (let ((point-save (point)))
522 (save-excursion
523 (mouse-set-point event)
524 (push-mark nil t)
525 (if (> point-save (point))
526 (open-rectangle (point) point-save)
527 (open-rectangle point-save (point))))))
528
529 ;; Must be a better way to do this.
530
531 (defun mouse-multiple-insert (n char)
532 (while (> n 0)
533 (insert char)
534 (setq n (1- n))))
535
536 ;; What this could do is not finalize until button was released.
537
538 (defun mouse-move-text (event)
539 "Move text from point to cursor position, inserting spaces."
540 (interactive "@e")
541 (let* ((relative-coordinate
542 (coordinates-in-window-p (car event) (selected-window))))
543 (if (consp relative-coordinate)
544 (cond ((> (current-column) (car relative-coordinate))
545 (delete-char
546 (- (car relative-coordinate) (current-column))))
547 ((< (current-column) (car relative-coordinate))
548 (mouse-multiple-insert
549 (- (car relative-coordinate) (current-column)) " "))
550 ((= (current-column) (car relative-coordinate)) (ding))))))
551 \f
552 ;; Font selection.
553
554 (defvar x-fixed-font-alist
555 '("Font menu"
556 ("Misc"
557 ("fixed" "fixed")
558 ("6x10" "6x10")
559 ("6x12" "6x12")
560 ("6x13" "6x13")
561 ("7x13" "7x13")
562 ("7x14" "7x14")
563 ("8x13" "8x13")
564 ("8x13 bold" "8x13bold")
565 ("8x16" "8x16")
566 ("9x15" "9x15")
567 ("9x15 bold" "9x15bold")
568 ("10x20" "10x20")
569 ("11x18" "11x18")
570 ("12x24" "12x24"))
571 ;;; We don't seem to have these; who knows what they are.
572 ;;; ("fg-18" "fg-18")
573 ;;; ("fg-25" "fg-25")
574 ;;; ("lucidasanstypewriter-12" "lucidasanstypewriter-12")
575 ;;; ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14")
576 ;;; ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24")
577 ;;; ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1")
578 ;;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*")
579 ("Courier"
580 ("8" "-adobe-courier-medium-r-normal--8-*-*-*-m-*-iso8859-1")
581 ("10" "-adobe-courier-medium-r-normal--10-*-*-*-m-*-iso8859-1")
582 ("12" "-adobe-courier-medium-r-normal--12-*-*-*-m-*-iso8859-1")
583 ("14" "-adobe-courier-medium-r-normal--14-*-*-*-m-*-iso8859-1")
584 ("18" "-adobe-courier-medium-r-normal--18-*-*-*-m-*-iso8859-1")
585 ("24" "-adobe-courier-medium-r-normal--24-*-*-*-m-*-iso8859-1")
586 ("8 bold" "-adobe-courier-bold-r-normal--8-*-*-*-m-*-iso8859-1")
587 ("10 bold" "-adobe-courier-bold-r-normal--10-*-*-*-m-*-iso8859-1")
588 ("12 bold" "-adobe-courier-bold-r-normal--12-*-*-*-m-*-iso8859-1")
589 ("14 bold" "-adobe-courier-bold-r-normal--14-*-*-*-m-*-iso8859-1")
590 ("18 bold" "-adobe-courier-bold-r-normal--18-*-*-*-m-*-iso8859-1")
591 ("24 bold" "-adobe-courier-bold-r-normal--24-*-*-*-m-*-iso8859-1")
592 ("8 slant" "-adobe-courier-medium-o-normal--8-*-*-*-m-*-iso8859-1")
593 ("10 slant" "-adobe-courier-medium-o-normal--10-*-*-*-m-*-iso8859-1")
594 ("12 slant" "-adobe-courier-medium-o-normal--12-*-*-*-m-*-iso8859-1")
595 ("14 slant" "-adobe-courier-medium-o-normal--14-*-*-*-m-*-iso8859-1")
596 ("18 slant" "-adobe-courier-medium-o-normal--18-*-*-*-m-*-iso8859-1")
597 ("24 slant" "-adobe-courier-medium-o-normal--24-*-*-*-m-*-iso8859-1")
598 ("8 bold slant" "-adobe-courier-bold-o-normal--8-*-*-*-m-*-iso8859-1")
599 ("10 bold slant" "-adobe-courier-bold-o-normal--10-*-*-*-m-*-iso8859-1")
600 ("12 bold slant" "-adobe-courier-bold-o-normal--12-*-*-*-m-*-iso8859-1")
601 ("14 bold slant" "-adobe-courier-bold-o-normal--14-*-*-*-m-*-iso8859-1")
602 ("18 bold slant" "-adobe-courier-bold-o-normal--18-*-*-*-m-*-iso8859-1")
603 ("24 bold slant" "-adobe-courier-bold-o-normal--24-*-*-*-m-*-iso8859-1"))
604 )
605 "X fonts suitable for use in Emacs.")
606
607 (defun mouse-set-font (font)
608 "Select an emacs font from a list of known good fonts"
609 (interactive
610 (x-popup-menu last-nonmenu-event x-fixed-font-alist))
611 (modify-frame-parameters (selected-frame)
612 (list (cons 'font font))))
613 \f
614 ;;; Bindings for mouse commands.
615
616 ;; This won't be needed once the drag and down events
617 ;; are properly implemented.
618 (global-set-key [mouse-1] 'mouse-set-point)
619
620 (global-set-key [drag-mouse-1] 'mouse-set-region)
621 (global-set-key [mouse-2] 'mouse-yank-at-click)
622 (global-set-key [mouse-3] 'mouse-save-then-kill)
623
624 (global-set-key [C-mouse-1] 'mouse-buffer-menu)
625
626 (global-set-key [C-mouse-3] 'mouse-set-font)
627
628 ;; Replaced with dragging mouse-1
629 ;; (global-set-key [S-mouse-1] 'mouse-set-mark)
630
631 (global-set-key [mode-line mouse-1] 'mouse-delete-other-windows)
632 (global-set-key [mode-line mouse-3] 'mouse-delete-window)
633 \f
634 ;; Define the mouse help menu tree.
635
636 (defvar help-menu-map '(keymap "Help"))
637 (global-set-key [C-mouse-2] help-menu-map)
638
639 (defvar help-apropos-map '(keymap "Is there a command that..."))
640 (defvar help-keys-map '(keymap "Key Commands <==> Functions"))
641 (defvar help-manual-map '(keymap "Manual and tutorial"))
642 (defvar help-misc-map '(keymap "Odds and ends"))
643 (defvar help-modes-map '(keymap "Modes"))
644 (defvar help-admin-map '(keymap "Administrivia"))
645
646 (define-key help-menu-map [apropos]
647 (cons "@Is there a command that..." help-apropos-map))
648 (define-key help-menu-map [keys]
649 (cons "@Key Commands <==> Functions" help-keys-map))
650 (define-key help-menu-map [manuals]
651 (cons "@Manual and tutorial" help-manual-map))
652 (define-key help-menu-map [misc]
653 (cons "@Odds and ends" help-misc-map))
654 (define-key help-menu-map [modes]
655 (cons "@Modes" help-modes-map))
656 (define-key help-menu-map [admin]
657 (cons "@Administrivia" help-admin-map))
658
659 (define-key help-apropos-map "c" '("Command Apropos" . command-apropos))
660 (define-key help-apropos-map "a" '("Apropos" . apropos))
661
662 (define-key help-keys-map "b"
663 '("List all keystroke commands" . describe-bindings))
664 (define-key help-keys-map "c"
665 '("Describe key briefly" . describe-key-briefly))
666 (define-key help-keys-map "k"
667 '("Describe key verbose" . describe-key))
668 (define-key help-keys-map "f"
669 '("Describe Lisp function" . describe-function))
670 (define-key help-keys-map "w"
671 '("Where is this command" . where-is))
672
673 (define-key help-manual-map "i" '("Info system" . info))
674 (define-key help-manual-map "t"
675 '("Invoke Emacs tutorial" . help-with-tutorial))
676
677 (define-key help-misc-map "l" '("Last 100 Keystrokes" . view-lossage))
678 (define-key help-misc-map "s" '("Describe syntax table" . describe-syntax))
679
680 (define-key help-modes-map "m"
681 '("Describe current major mode" . describe-mode))
682 (define-key help-modes-map "b"
683 '("List all keystroke commands" . describe-bindings))
684
685 (define-key help-admin-map "n"
686 '("view Emacs news" . view-emacs-news))
687 (define-key help-admin-map "l"
688 '("View the GNU Emacs license" . describe-copying))
689 (define-key help-admin-map "d"
690 '("Describe distribution" . describe-distribution))
691 (define-key help-admin-map "w"
692 '("Describe (non)warranty" . describe-no-warranty))
693
694 (provide 'mouse)
695
696 ;;; mouse.el ends here