1 ;;; mouse.el --- window system-independent mouse support.
3 ;;; Copyright (C) 1993 Free Software Foundation, Inc.
8 ;;; This file is part of GNU Emacs.
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.
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.
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.
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.
30 ;; The code is rather X-dependent.
34 ;;; Utility functions.
36 ;;; Indent track-mouse like progn.
37 (put 'track-mouse
'lisp-indent-function
0)
40 (defun mouse-delete-window (click)
41 "Delete the window you click on.
42 This must be bound to a mouse click."
44 (delete-window (posn-window (event-start click
))))
46 (defun mouse-tear-off-window (click)
47 "Delete the window clicked on, and create a new frame displaying its buffer."
49 (let* ((window (posn-window (event-start click
)))
50 (buf (window-buffer window
))
53 (switch-to-buffer buf
)
54 (delete-window window
)))
56 (defun mouse-delete-other-windows ()
57 "Delete all window except the one you click on."
59 (delete-other-windows))
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."
66 (let ((start (event-start click
)))
67 (select-window (posn-window start
))
68 (let ((new-height (1+ (cdr (posn-col-row (event-end click
)))))
69 (first-line window-min-height
)
70 (last-line (- (window-height) window-min-height
)))
71 (if (< last-line first-line
)
72 (error "window too short to split")
73 (split-window-vertically
74 (min (max new-height first-line
) last-line
))))))
76 (defun mouse-split-window-horizontally (click)
77 "Select Emacs window mouse is on, then split it horizontally in half.
78 The window is split at the column clicked on.
79 This command must be bound to a mouse click."
81 (let ((start (event-start click
)))
82 (select-window (posn-window start
))
83 (let ((new-width (1+ (car (posn-col-row (event-end click
)))))
84 (first-col window-min-width
)
85 (last-col (- (window-width) window-min-width
)))
86 (if (< last-col first-col
)
87 (error "window too narrow to split")
88 (split-window-horizontally
89 (min (max new-width first-col
) last-col
))))))
91 (defun mouse-set-point (click)
92 "Move point to the position clicked on with the mouse.
93 This must be bound to a mouse click."
95 (let ((posn (event-start click
)))
96 (select-window (posn-window posn
))
97 (if (numberp (posn-point posn
))
98 (goto-char (posn-point posn
)))))
100 (defun mouse-set-region (click)
101 "Set the region to the text that the mouse is dragged over.
102 This must be bound to a mouse drag event."
104 (let ((posn (event-start click
))
105 (end (event-end click
)))
106 (select-window (posn-window posn
))
107 (if (numberp (posn-point posn
))
108 (goto-char (posn-point posn
)))
109 ;; If mark is highlighted, no need to bounce the cursor.
110 (or (and transient-mark-mode
111 (eq (framep (selected-frame)) 'x
))
115 (if (numberp (posn-point end
))
116 (goto-char (posn-point end
)))))
118 (defun mouse-drag-region (click)
119 "Set the region to the text that the mouse is dragged over.
120 This must be bound to a button-down mouse event."
122 (let ((posn (event-start click
))
123 done event
(mark-active nil
))
124 (select-window (posn-window posn
))
125 ;; Set point temporarily, so user sees where it is.
126 (if (numberp (posn-point posn
))
127 (goto-char (posn-point posn
)))
128 ;; Turn off the old mark when we set up an empty region.
129 (setq deactivate-mark t
)))
131 ;;;Nice hack, but too slow.
132 ;;;(defun mouse-drag-region-1 (click)
133 ;;; "Set the region to the text that the mouse is dragged over.
134 ;;;This must be bound to a button-down mouse event."
135 ;;; (interactive "e")
137 ;;; (let ((posn (event-start click))
138 ;;; done event omark (mark-active t))
139 ;;; (select-window (posn-window posn))
140 ;;; (setq omark (and mark-active (mark)))
141 ;;; (if (numberp (posn-point posn))
142 ;;; (goto-char (posn-point posn)))
143 ;;; ;; Set mark temporarily, so highlighting does what we want.
144 ;;; (set-marker (mark-marker) (point))
146 ;;; (while (not done)
147 ;;; (setq event (read-event))
148 ;;; (if (eq (car-safe event) 'mouse-movement)
149 ;;; (goto-char (posn-point (event-start event)))
150 ;;; ;; Exit when we get the drag event; ignore that event.
152 ;;; (if (/= (mark) (point))
153 ;;; (setq newmark (mark)))
154 ;;; ;; Restore previous mark status.
155 ;;; (if omark (set-marker (mark-marker) omark)))
156 ;;; ;; Now, if we dragged, set the mark at the proper place.
158 ;;; (push-mark newmark t)
159 ;;; ;; Turn off the old mark when we set up an empty region.
160 ;;; (setq deactivate-mark t))))
162 (defun mouse-set-mark (click)
163 "Set mark at the position clicked on with the mouse.
164 Display cursor at that position for a second.
165 This must be bound to a mouse click."
167 (let ((point-save (point)))
169 (progn (mouse-set-point click
)
171 (or transient-mark-mode
173 (goto-char point-save
))))
175 (defun mouse-kill (click)
176 "Kill the region between point and the mouse click.
177 The text is saved in the kill ring, as with \\[kill-region]."
179 (let ((click-posn (posn-point (event-start click
))))
180 (if (numberp click-posn
)
181 (kill-region (min (point) click-posn
)
182 (max (point) click-posn
)))))
184 (defun mouse-yank-at-click (click arg
)
185 "Insert the last stretch of killed text at the position clicked on.
186 Prefix arguments are interpreted as with \\[yank]."
188 (mouse-set-point click
)
191 (defun mouse-kill-ring-save (click)
192 "Copy the region between point and the mouse click in the kill ring.
193 This does not delete the region; it acts like \\[kill-ring-save]."
195 (mouse-set-mark click
)
196 (kill-ring-save (point) (mark t
)))
198 ;;; This function used to delete the text between point and the mouse
199 ;;; whenever it was equal to the front of the kill ring, but some
200 ;;; people found that confusing.
202 ;;; A list (TEXT START END), describing the text and position of the last
203 ;;; invocation of mouse-save-then-kill.
204 (defvar mouse-save-then-kill-posn nil
)
206 (defun mouse-save-then-kill (click)
207 "Save text to point in kill ring; the second time, kill the text.
208 If the text between point and the mouse is the same as what's
209 at the front of the kill ring, this deletes the text.
210 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
211 which prepares for a second click to delete the text."
213 (let ((click-posn (posn-point (event-start click
))))
214 (if (and (eq last-command
'kill-region
)
215 mouse-save-then-kill-posn
216 (eq (car mouse-save-then-kill-posn
) (car kill-ring
))
217 (equal (cdr mouse-save-then-kill-posn
) (list (point) click-posn
)))
218 ;; If this is the second time we've called
219 ;; mouse-save-then-kill, delete the text from the buffer.
221 (let ((buffer-undo-list t
))
222 (delete-region (point) (mark)))
223 ;; Make the undo list by hand so it is shared.
224 (if (not (eq buffer-undo-list t
))
225 (setq buffer-undo-list
226 (cons (cons (car kill-ring
) (point)) buffer-undo-list
))))
227 ;; Otherwise, save this region.
228 (mouse-set-mark click
)
229 (kill-ring-save (point) (mark t
))
230 (setq mouse-save-then-kill-posn
231 (list (car kill-ring
) (point) click-posn
)))))
233 (defun mouse-buffer-menu (event)
234 "Pop up a menu of buffers for selection with the mouse.
235 This switches buffers in the window that you clicked on,
236 and selects that window."
240 (cons "Select Buffer"
241 (let ((tail (buffer-list))
244 (let ((elt (car tail
)))
245 (if (not (string-match "^ "
252 (or (buffer-file-name elt
) ""))
255 (setq tail
(cdr tail
)))
257 (let ((buf (x-popup-menu event menu
))
258 (window (posn-window (event-start event
))))
261 (select-window window
)
262 (switch-to-buffer buf
))))))
264 ;;; These need to be rewritten for the new scroll bar implementation.
266 ;;;!! ;; Commands for the scroll bar.
268 ;;;!! (defun mouse-scroll-down (click)
269 ;;;!! (interactive "@e")
270 ;;;!! (scroll-down (1+ (cdr (mouse-coords click)))))
272 ;;;!! (defun mouse-scroll-up (click)
273 ;;;!! (interactive "@e")
274 ;;;!! (scroll-up (1+ (cdr (mouse-coords click)))))
276 ;;;!! (defun mouse-scroll-down-full ()
277 ;;;!! (interactive "@")
278 ;;;!! (scroll-down nil))
280 ;;;!! (defun mouse-scroll-up-full ()
281 ;;;!! (interactive "@")
282 ;;;!! (scroll-up nil))
284 ;;;!! (defun mouse-scroll-move-cursor (click)
285 ;;;!! (interactive "@e")
286 ;;;!! (move-to-window-line (1+ (cdr (mouse-coords click)))))
288 ;;;!! (defun mouse-scroll-absolute (event)
289 ;;;!! (interactive "@e")
290 ;;;!! (let* ((pos (car event))
291 ;;;!! (position (car pos))
292 ;;;!! (length (car (cdr pos))))
293 ;;;!! (if (<= length 0) (setq length 1))
294 ;;;!! (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size)))))
295 ;;;!! (newpos (* (/ (* (/ (buffer-size) scale-factor)
298 ;;;!! scale-factor)))
299 ;;;!! (goto-char newpos)
300 ;;;!! (recenter '(4)))))
302 ;;;!! (defun mouse-scroll-left (click)
303 ;;;!! (interactive "@e")
304 ;;;!! (scroll-left (1+ (car (mouse-coords click)))))
306 ;;;!! (defun mouse-scroll-right (click)
307 ;;;!! (interactive "@e")
308 ;;;!! (scroll-right (1+ (car (mouse-coords click)))))
310 ;;;!! (defun mouse-scroll-left-full ()
311 ;;;!! (interactive "@")
312 ;;;!! (scroll-left nil))
314 ;;;!! (defun mouse-scroll-right-full ()
315 ;;;!! (interactive "@")
316 ;;;!! (scroll-right nil))
318 ;;;!! (defun mouse-scroll-move-cursor-horizontally (click)
319 ;;;!! (interactive "@e")
320 ;;;!! (move-to-column (1+ (car (mouse-coords click)))))
322 ;;;!! (defun mouse-scroll-absolute-horizontally (event)
323 ;;;!! (interactive "@e")
324 ;;;!! (let* ((pos (car event))
325 ;;;!! (position (car pos))
326 ;;;!! (length (car (cdr pos))))
327 ;;;!! (set-window-hscroll (selected-window) 33)))
329 ;;;!! (global-set-key [scroll-bar mouse-1] 'mouse-scroll-up)
330 ;;;!! (global-set-key [scroll-bar mouse-2] 'mouse-scroll-absolute)
331 ;;;!! (global-set-key [scroll-bar mouse-3] 'mouse-scroll-down)
333 ;;;!! (global-set-key [vertical-slider mouse-1] 'mouse-scroll-move-cursor)
334 ;;;!! (global-set-key [vertical-slider mouse-2] 'mouse-scroll-move-cursor)
335 ;;;!! (global-set-key [vertical-slider mouse-3] 'mouse-scroll-move-cursor)
337 ;;;!! (global-set-key [thumbup mouse-1] 'mouse-scroll-up-full)
338 ;;;!! (global-set-key [thumbup mouse-2] 'mouse-scroll-up-full)
339 ;;;!! (global-set-key [thumbup mouse-3] 'mouse-scroll-up-full)
341 ;;;!! (global-set-key [thumbdown mouse-1] 'mouse-scroll-down-full)
342 ;;;!! (global-set-key [thumbdown mouse-2] 'mouse-scroll-down-full)
343 ;;;!! (global-set-key [thumbdown mouse-3] 'mouse-scroll-down-full)
345 ;;;!! (global-set-key [horizontal-scroll-bar mouse-1] 'mouse-scroll-left)
346 ;;;!! (global-set-key [horizontal-scroll-bar mouse-2]
347 ;;;!! 'mouse-scroll-absolute-horizontally)
348 ;;;!! (global-set-key [horizontal-scroll-bar mouse-3] 'mouse-scroll-right)
350 ;;;!! (global-set-key [horizontal-slider mouse-1]
351 ;;;!! 'mouse-scroll-move-cursor-horizontally)
352 ;;;!! (global-set-key [horizontal-slider mouse-2]
353 ;;;!! 'mouse-scroll-move-cursor-horizontally)
354 ;;;!! (global-set-key [horizontal-slider mouse-3]
355 ;;;!! 'mouse-scroll-move-cursor-horizontally)
357 ;;;!! (global-set-key [thumbleft mouse-1] 'mouse-scroll-left-full)
358 ;;;!! (global-set-key [thumbleft mouse-2] 'mouse-scroll-left-full)
359 ;;;!! (global-set-key [thumbleft mouse-3] 'mouse-scroll-left-full)
361 ;;;!! (global-set-key [thumbright mouse-1] 'mouse-scroll-right-full)
362 ;;;!! (global-set-key [thumbright mouse-2] 'mouse-scroll-right-full)
363 ;;;!! (global-set-key [thumbright mouse-3] 'mouse-scroll-right-full)
365 ;;;!! (global-set-key [horizontal-scroll-bar S-mouse-2]
366 ;;;!! 'mouse-split-window-horizontally)
367 ;;;!! (global-set-key [mode-line S-mouse-2]
368 ;;;!! 'mouse-split-window-horizontally)
369 ;;;!! (global-set-key [vertical-scroll-bar S-mouse-2]
370 ;;;!! 'mouse-split-window)
373 ;;;!! ;;;; Here are experimental things being tested. Mouse events
374 ;;;!! ;;;; are of the form:
375 ;;;!! ;;;; ((x y) window screen-part key-sequence timestamp)
378 ;;;!! ;;;; Dynamically track mouse coordinates
381 ;;;!! ;;(defun track-mouse (event)
382 ;;;!! ;; "Track the coordinates, absolute and relative, of the mouse."
383 ;;;!! ;; (interactive "@e")
384 ;;;!! ;; (while mouse-grabbed
385 ;;;!! ;; (let* ((pos (read-mouse-position (selected-screen)))
386 ;;;!! ;; (abs-x (car pos))
387 ;;;!! ;; (abs-y (cdr pos))
388 ;;;!! ;; (relative-coordinate (coordinates-in-window-p
389 ;;;!! ;; (list (car pos) (cdr pos))
390 ;;;!! ;; (selected-window))))
391 ;;;!! ;; (if (consp relative-coordinate)
392 ;;;!! ;; (message "mouse: [%d %d], (%d %d)" abs-x abs-y
393 ;;;!! ;; (car relative-coordinate)
394 ;;;!! ;; (car (cdr relative-coordinate)))
395 ;;;!! ;; (message "mouse: [%d %d]" abs-x abs-y)))))
398 ;;;!! ;; Dynamically put a box around the line indicated by point
401 ;;;!! ;;(require 'backquote)
403 ;;;!! ;;(defun mouse-select-buffer-line (event)
404 ;;;!! ;; (interactive "@e")
405 ;;;!! ;; (let ((relative-coordinate
406 ;;;!! ;; (coordinates-in-window-p (car event) (selected-window)))
407 ;;;!! ;; (abs-y (car (cdr (car event)))))
408 ;;;!! ;; (if (consp relative-coordinate)
410 ;;;!! ;; (save-excursion
411 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
412 ;;;!! ;; (x-draw-rectangle
413 ;;;!! ;; (selected-screen)
415 ;;;!! ;; (save-excursion
416 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
417 ;;;!! ;; (end-of-line)
418 ;;;!! ;; (push-mark nil t)
419 ;;;!! ;; (beginning-of-line)
420 ;;;!! ;; (- (region-end) (region-beginning))) 1))
422 ;;;!! ;; (x-erase-rectangle (selected-screen))))))
424 ;;;!! ;;(defvar last-line-drawn nil)
425 ;;;!! ;;(defvar begin-delim "[^ \t]")
426 ;;;!! ;;(defvar end-delim "[^ \t]")
428 ;;;!! ;;(defun mouse-boxing (event)
429 ;;;!! ;; (interactive "@e")
430 ;;;!! ;; (save-excursion
431 ;;;!! ;; (let ((screen (selected-screen)))
432 ;;;!! ;; (while (= (x-mouse-events) 0)
433 ;;;!! ;; (let* ((pos (read-mouse-position screen))
434 ;;;!! ;; (abs-x (car pos))
435 ;;;!! ;; (abs-y (cdr pos))
436 ;;;!! ;; (relative-coordinate
437 ;;;!! ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y)))
438 ;;;!! ;; (selected-window)))
439 ;;;!! ;; (begin-reg nil)
440 ;;;!! ;; (end-reg nil)
441 ;;;!! ;; (end-column nil)
442 ;;;!! ;; (begin-column nil))
443 ;;;!! ;; (if (and (consp relative-coordinate)
444 ;;;!! ;; (or (not last-line-drawn)
445 ;;;!! ;; (not (= last-line-drawn abs-y))))
447 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
448 ;;;!! ;; (if (= (following-char) 10)
451 ;;;!! ;; (setq begin-reg (1- (re-search-forward end-delim)))
452 ;;;!! ;; (setq begin-column (1- (current-column)))
453 ;;;!! ;; (end-of-line)
454 ;;;!! ;; (setq end-reg (1+ (re-search-backward begin-delim)))
455 ;;;!! ;; (setq end-column (1+ (current-column)))
456 ;;;!! ;; (message "%s" (buffer-substring begin-reg end-reg))
457 ;;;!! ;; (x-draw-rectangle screen
458 ;;;!! ;; (setq last-line-drawn abs-y)
459 ;;;!! ;; begin-column
460 ;;;!! ;; (- end-column begin-column) 1))))))))))
462 ;;;!! ;;(defun mouse-erase-box ()
463 ;;;!! ;; (interactive)
464 ;;;!! ;; (if last-line-drawn
466 ;;;!! ;; (x-erase-rectangle (selected-screen))
467 ;;;!! ;; (setq last-line-drawn nil))))
469 ;;;!! ;;; (defun test-x-rectangle ()
470 ;;;!! ;;; (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap)))
471 ;;;!! ;;; (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing)
472 ;;;!! ;;; (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box))
475 ;;;!! ;; Here is how to do double clicking in lisp. About to change.
478 ;;;!! (defvar double-start nil)
479 ;;;!! (defconst double-click-interval 300
480 ;;;!! "Max ticks between clicks")
482 ;;;!! (defun double-down (event)
483 ;;;!! (interactive "@e")
484 ;;;!! (if double-start
485 ;;;!! (let ((interval (- (nth 4 event) double-start)))
486 ;;;!! (if (< interval double-click-interval)
488 ;;;!! (backward-up-list 1)
489 ;;;!! ;; (message "Interval %d" interval)
490 ;;;!! (sleep-for 1)))
491 ;;;!! (setq double-start nil))
492 ;;;!! (setq double-start (nth 4 event))))
494 ;;;!! (defun double-up (event)
495 ;;;!! (interactive "@e")
496 ;;;!! (and double-start
497 ;;;!! (> (- (nth 4 event ) double-start) double-click-interval)
498 ;;;!! (setq double-start nil)))
500 ;;;!! ;;; (defun x-test-doubleclick ()
501 ;;;!! ;;; (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap)))
502 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left 'double-down)
503 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left-up 'double-up))
506 ;;;!! ;; This scrolls while button is depressed. Use preferable in scroll bar.
509 ;;;!! (defvar scrolled-lines 0)
510 ;;;!! (defconst scroll-speed 1)
512 ;;;!! (defun incr-scroll-down (event)
513 ;;;!! (interactive "@e")
514 ;;;!! (setq scrolled-lines 0)
515 ;;;!! (incremental-scroll scroll-speed))
517 ;;;!! (defun incr-scroll-up (event)
518 ;;;!! (interactive "@e")
519 ;;;!! (setq scrolled-lines 0)
520 ;;;!! (incremental-scroll (- scroll-speed)))
522 ;;;!! (defun incremental-scroll (n)
523 ;;;!! (while (= (x-mouse-events) 0)
524 ;;;!! (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
525 ;;;!! (scroll-down n)
526 ;;;!! (sit-for 300 t)))
528 ;;;!! (defun incr-scroll-stop (event)
529 ;;;!! (interactive "@e")
530 ;;;!! (message "Scrolled %d lines" scrolled-lines)
531 ;;;!! (setq scrolled-lines 0)
534 ;;;!! ;;; (defun x-testing-scroll ()
535 ;;;!! ;;; (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix)))
536 ;;;!! ;;; (define-key scrolling-map mouse-button-left 'incr-scroll-down)
537 ;;;!! ;;; (define-key scrolling-map mouse-button-right 'incr-scroll-up)
538 ;;;!! ;;; (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop)
539 ;;;!! ;;; (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop)))
542 ;;;!! ;; Some playthings suitable for picture mode? They need work.
545 ;;;!! (defun mouse-kill-rectangle (event)
546 ;;;!! "Kill the rectangle between point and the mouse cursor."
547 ;;;!! (interactive "@e")
548 ;;;!! (let ((point-save (point)))
549 ;;;!! (save-excursion
550 ;;;!! (mouse-set-point event)
551 ;;;!! (push-mark nil t)
552 ;;;!! (if (> point-save (point))
553 ;;;!! (kill-rectangle (point) point-save)
554 ;;;!! (kill-rectangle point-save (point))))))
556 ;;;!! (defun mouse-open-rectangle (event)
557 ;;;!! "Kill the rectangle between point and the mouse cursor."
558 ;;;!! (interactive "@e")
559 ;;;!! (let ((point-save (point)))
560 ;;;!! (save-excursion
561 ;;;!! (mouse-set-point event)
562 ;;;!! (push-mark nil t)
563 ;;;!! (if (> point-save (point))
564 ;;;!! (open-rectangle (point) point-save)
565 ;;;!! (open-rectangle point-save (point))))))
567 ;;;!! ;; Must be a better way to do this.
569 ;;;!! (defun mouse-multiple-insert (n char)
572 ;;;!! (setq n (1- n))))
574 ;;;!! ;; What this could do is not finalize until button was released.
576 ;;;!! (defun mouse-move-text (event)
577 ;;;!! "Move text from point to cursor position, inserting spaces."
578 ;;;!! (interactive "@e")
579 ;;;!! (let* ((relative-coordinate
580 ;;;!! (coordinates-in-window-p (car event) (selected-window))))
581 ;;;!! (if (consp relative-coordinate)
582 ;;;!! (cond ((> (current-column) (car relative-coordinate))
584 ;;;!! (- (car relative-coordinate) (current-column))))
585 ;;;!! ((< (current-column) (car relative-coordinate))
586 ;;;!! (mouse-multiple-insert
587 ;;;!! (- (car relative-coordinate) (current-column)) " "))
588 ;;;!! ((= (current-column) (car relative-coordinate)) (ding))))))
592 (defvar x-fixed-font-alist
602 ("8x13 bold" "8x13bold")
605 ("9x15 bold" "9x15bold")
609 ;;; We don't seem to have these; who knows what they are.
610 ;;; ("fg-18" "fg-18")
611 ;;; ("fg-25" "fg-25")
612 ;;; ("lucidasanstypewriter-12" "lucidasanstypewriter-12")
613 ;;; ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14")
614 ;;; ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24")
615 ;;; ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1")
616 ;;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*")
618 ("8" "-adobe-courier-medium-r-normal--*-80-*-*-m-*-iso8859-1")
619 ("10" "-adobe-courier-medium-r-normal--*-100-*-*-m-*-iso8859-1")
620 ("12" "-adobe-courier-medium-r-normal--*-120-*-*-m-*-iso8859-1")
621 ("14" "-adobe-courier-medium-r-normal--*-140-*-*-m-*-iso8859-1")
622 ("18" "-adobe-courier-medium-r-normal--*-180-*-*-m-*-iso8859-1")
623 ("24" "-adobe-courier-medium-r-normal--*-240-*-*-m-*-iso8859-1")
624 ("8 bold" "-adobe-courier-bold-r-normal--*-80-*-*-m-*-iso8859-1")
625 ("10 bold" "-adobe-courier-bold-r-normal--*-100-*-*-m-*-iso8859-1")
626 ("12 bold" "-adobe-courier-bold-r-normal--*-120-*-*-m-*-iso8859-1")
627 ("14 bold" "-adobe-courier-bold-r-normal--*-140-*-*-m-*-iso8859-1")
628 ("18 bold" "-adobe-courier-bold-r-normal--*-180-*-*-m-*-iso8859-1")
629 ("24 bold" "-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1")
630 ("8 slant" "-adobe-courier-medium-o-normal--*-80-*-*-m-*-iso8859-1")
631 ("10 slant" "-adobe-courier-medium-o-normal--*-100-*-*-m-*-iso8859-1")
632 ("12 slant" "-adobe-courier-medium-o-normal--*-120-*-*-m-*-iso8859-1")
633 ("14 slant" "-adobe-courier-medium-o-normal--*-140-*-*-m-*-iso8859-1")
634 ("18 slant" "-adobe-courier-medium-o-normal--*-180-*-*-m-*-iso8859-1")
635 ("24 slant" "-adobe-courier-medium-o-normal--*-240-*-*-m-*-iso8859-1")
636 ("8 bold slant" "-adobe-courier-bold-o-normal--*-80-*-*-m-*-iso8859-1")
637 ("10 bold slant" "-adobe-courier-bold-o-normal--*-100-*-*-m-*-iso8859-1")
638 ("12 bold slant" "-adobe-courier-bold-o-normal--*-120-*-*-m-*-iso8859-1")
639 ("14 bold slant" "-adobe-courier-bold-o-normal--*-140-*-*-m-*-iso8859-1")
640 ("18 bold slant" "-adobe-courier-bold-o-normal--*-180-*-*-m-*-iso8859-1")
641 ("24 bold slant" "-adobe-courier-bold-o-normal--*-240-*-*-m-*-iso8859-1"))
643 "X fonts suitable for use in Emacs.")
645 (defun mouse-set-font (&optional font
)
646 "Select an emacs font from a list of known good fonts"
648 (x-popup-menu last-nonmenu-event x-fixed-font-alist
))
650 (modify-frame-parameters (selected-frame)
651 (list (cons 'font font
)))))
653 ;;; Bindings for mouse commands.
655 (define-key global-map
[down-mouse-1
] 'mouse-drag-region
)
656 (global-set-key [mouse-1
] 'mouse-set-point
)
657 (global-set-key [drag-mouse-1
] 'mouse-set-region
)
659 (global-set-key [mouse-2
] 'mouse-yank-at-click
)
660 (global-set-key [mouse-3
] 'mouse-save-then-kill
)
662 ;; By binding these to down-going events, we let the user use the up-going
663 ;; event to make the selection, saving a click.
664 (global-set-key [C-down-mouse-1
] 'mouse-buffer-menu
)
665 (global-set-key [C-down-mouse-3
] 'mouse-set-font
)
667 ;; Replaced with dragging mouse-1
668 ;; (global-set-key [S-mouse-1] 'mouse-set-mark)
670 (global-set-key [mode-line mouse-1
] 'mouse-delete-other-windows
)
671 (global-set-key [mode-line mouse-3
] 'mouse-delete-window
)
672 (global-set-key [mode-line S-mouse-2
] 'mouse-split-window-horizontally
)
674 ;; Define the mouse help menu tree.
676 (defvar help-menu-map
'(keymap "Help"))
677 (global-set-key [C-down-mouse-2
] help-menu-map
)
679 (defvar help-apropos-map
(make-sparse-keymap "Is there a command that..."))
680 (defvar help-keys-map
(make-sparse-keymap "Key Commands <==> Functions"))
681 (defvar help-manual-map
(make-sparse-keymap "Manual and tutorial"))
682 (defvar help-misc-map
(make-sparse-keymap "Odds and ends"))
683 (defvar help-modes-map
(make-sparse-keymap "Modes"))
684 (defvar help-admin-map
(make-sparse-keymap "Administrivia"))
686 (define-key help-menu-map
[apropos]
687 (cons "@Is there a command that..." help-apropos-map))
688 (define-key help-menu-map [keys]
689 (cons "@Key Commands <==> Functions" help-keys-map))
690 (define-key help-menu-map [manuals]
691 (cons "@Manual and tutorial" help-manual-map))
692 (define-key help-menu-map [misc]
693 (cons "@Odds and ends" help-misc-map))
694 (define-key help-menu-map [modes]
695 (cons "@Modes" help-modes-map))
696 (define-key help-menu-map [admin]
697 (cons "@Administrivia" help-admin-map))
699 (define-key help-apropos-map "c" '("Command Apropos" . command-apropos))
700 (define-key help-apropos-map "a" '("Apropos" . apropos))
702 (define-key help-keys-map "b"
703 '("List all keystroke commands" . describe-bindings))
704 (define-key help-keys-map "c"
705 '("Describe key briefly" . describe-key-briefly))
706 (define-key help-keys-map "k"
707 '("Describe key verbose" . describe-key))
708 (define-key help-keys-map "f"
709 '("Describe Lisp function" . describe-function))
710 (define-key help-keys-map "w"
711 '("Where is this command" . where-is))
713 (define-key help-manual-map "i" '("Info system" . info))
714 (define-key help-manual-map "t"
715 '("Invoke Emacs tutorial" . help-with-tutorial))
717 (define-key help-misc-map "l" '("Last 100 Keystrokes" . view-lossage))
718 (define-key help-misc-map "s" '("Describe syntax table" . describe-syntax))
720 (define-key help-modes-map "m"
721 '("Describe current major mode" . describe-mode))
722 (define-key help-modes-map "b"
723 '("List all keystroke commands" . describe-bindings))
725 (define-key help-admin-map "n"
726 '("view Emacs news" . view-emacs-news))
727 (define-key help-admin-map "l"
728 '("View the GNU Emacs license" . describe-copying))
729 (define-key help-admin-map "d"
730 '("Describe distribution" . describe-distribution))
731 (define-key help-admin-map "w"
732 '("Describe (non)warranty" . describe-no-warranty))
736 ;;; mouse.el ends here