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