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