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