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