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)
39 (defvar mouse-yank-at-point nil
40 "*If non-nil, mouse yank commands yank at point instead of at click.")
42 (defun mouse-minibuffer-check (event)
43 (let ((w (posn-window (event-start event
))))
44 (and (window-minibuffer-p w
)
45 (not (minibuffer-window-active-p w
))
46 (error "Minibuffer window is not active"))))
48 (defun mouse-delete-window (click)
49 "Delete the window you click on.
50 This must be bound to a mouse click."
52 (mouse-minibuffer-check click
)
53 (delete-window (posn-window (event-start click
))))
55 (defun mouse-select-window (click)
56 "Select the window clicked on; don't move point."
58 (mouse-minibuffer-check click
)
59 (let ((oframe (selected-frame))
60 (frame (window-frame (posn-window (event-start click
)))))
61 (select-window (posn-window (event-start click
)))
65 (set-mouse-position (selected-frame) (1- (frame-width)) 0))
68 (defun mouse-tear-off-window (click)
69 "Delete the window clicked on, and create a new frame displaying its buffer."
71 (mouse-minibuffer-check click
)
72 (let* ((window (posn-window (event-start click
)))
73 (buf (window-buffer window
))
76 (switch-to-buffer buf
)
77 (delete-window window
)))
79 (defun mouse-delete-other-windows ()
80 "Delete all window except the one you click on."
82 (delete-other-windows))
84 (defun mouse-split-window-vertically (click)
85 "Select Emacs window mouse is on, then split it vertically in half.
86 The window is split at the line clicked on.
87 This command must be bound to a mouse click."
89 (mouse-minibuffer-check click
)
90 (let ((start (event-start click
)))
91 (select-window (posn-window start
))
92 (let ((new-height (if (eq (posn-point start
) 'vertical-scroll-bar
)
93 (scroll-bar-scale (posn-col-row start
)
95 (1+ (cdr (posn-col-row (event-end click
))))))
96 (first-line window-min-height
)
97 (last-line (- (window-height) window-min-height
)))
98 (if (< last-line first-line
)
99 (error "window too short to split")
100 (split-window-vertically
101 (min (max new-height first-line
) last-line
))))))
103 (defun mouse-split-window-horizontally (click)
104 "Select Emacs window mouse is on, then split it horizontally in half.
105 The window is split at the column clicked on.
106 This command must be bound to a mouse click."
108 (mouse-minibuffer-check click
)
109 (let ((start (event-start click
)))
110 (select-window (posn-window start
))
111 (let ((new-width (1+ (car (posn-col-row (event-end click
)))))
112 (first-col window-min-width
)
113 (last-col (- (window-width) window-min-width
)))
114 (if (< last-col first-col
)
115 (error "window too narrow to split")
116 (split-window-horizontally
117 (min (max new-width first-col
) last-col
))))))
119 (defun mouse-set-point (event)
120 "Move point to the position clicked on with the mouse.
121 This should be bound to a mouse click event type."
123 (mouse-minibuffer-check event
)
124 ;; Use event-end in case called from mouse-drag-region.
125 ;; If EVENT is a click, event-end and event-start give same value.
126 (let ((posn (event-end event
)))
127 (select-window (posn-window posn
))
128 (if (numberp (posn-point posn
))
129 (goto-char (posn-point posn
)))))
131 (defun mouse-set-region (click)
132 "Set the region to the text dragged over, and copy to kill ring.
133 This should be bound to a mouse drag event."
135 (mouse-minibuffer-check click
)
136 (let ((posn (event-start click
))
137 (end (event-end click
)))
138 (select-window (posn-window posn
))
139 (if (numberp (posn-point posn
))
140 (goto-char (posn-point posn
)))
141 ;; If mark is highlighted, no need to bounce the cursor.
142 (or (and transient-mark-mode
143 (eq (framep (selected-frame)) 'x
))
147 (if (numberp (posn-point end
))
148 (goto-char (posn-point end
)))
149 ;; Don't set this-command to kill-region, so that a following
150 ;; C-w will not double the text in the kill ring.
152 (copy-region-as-kill (mark) (point)))))
154 (defvar mouse-scroll-delay
0.25
155 "*The pause between scroll steps caused by mouse drags, in seconds.
156 If you drag the mouse beyond the edge of a window, Emacs scrolls the
157 window to bring the text beyond that edge into view, with a delay of
158 this many seconds between scroll steps. Scrolling stops when you move
159 the mouse back into the window, or release the button.
160 This variable's value may be non-integral.
161 Setting this to zero causes Emacs to scroll as fast as it can.")
163 (defun mouse-scroll-subr (jump &optional overlay start
)
164 "Scroll the selected window JUMP lines at a time, until new input arrives.
165 If OVERLAY is an overlay, let it stretch from START to the far edge of
166 the newly visible text.
167 Upon exit, point is at the far edge of the newly visible text."
169 (goto-char (window-start))
170 (if (not (zerop (vertical-motion jump
)))
172 (set-window-start (selected-window) (point))
175 (goto-char (window-end (selected-window)))
176 ;; window-end doesn't reflect the window's new
177 ;; start position until the next redisplay. Hurrah.
178 (vertical-motion (1- jump
)))
179 (goto-char (window-start (selected-window))))
181 (move-overlay overlay start
(point)))
183 (sit-for mouse-scroll-delay
))))))
186 (defvar mouse-drag-overlay
(make-overlay 1 1))
187 (overlay-put mouse-drag-overlay
'face
'region
)
189 (defvar mouse-selection-click-count
0)
191 (defun mouse-drag-region (start-event)
192 "Set the region to the text that the mouse is dragged over.
193 Highlight the drag area as you move the mouse.
194 This must be bound to a button-down mouse event.
195 In Transient Mark mode, the highlighting remains once you
196 release the mouse button. Otherwise, it does not."
198 (mouse-minibuffer-check start-event
)
199 (let* ((start-posn (event-start start-event
))
200 (start-point (posn-point start-posn
))
201 (start-window (posn-window start-posn
))
202 (start-frame (window-frame start-window
))
203 (bounds (window-edges start-window
))
205 (bottom (if (window-minibuffer-p start-window
)
207 ;; Don't count the mode line.
208 (1- (nth 3 bounds
))))
209 (click-count (1- (event-click-count start-event
))))
210 (setq mouse-selection-click-count click-count
)
211 (mouse-set-point start-event
)
212 (let ((range (mouse-start-end start-point start-point click-count
)))
213 (move-overlay mouse-drag-overlay
(car range
) (nth 1 range
)
214 (window-buffer start-window
)))
216 (let (event end end-point
)
219 (setq event
(read-event))
220 (or (mouse-movement-p event
)
221 (eq (car-safe event
) 'switch-frame
)))
222 (if (eq (car-safe event
) 'switch-frame
)
224 (setq end
(event-end event
)
225 end-point
(posn-point end
))
229 ;; Ignore switch-frame events.
230 ((eq (car-safe event
) 'switch-frame
))
232 ;; Are we moving within the original window?
233 ((and (eq (posn-window end
) start-window
)
234 (integer-or-marker-p end-point
))
235 (goto-char end-point
)
236 (let ((range (mouse-start-end start-point
(point) click-count
)))
237 (move-overlay mouse-drag-overlay
(car range
) (nth 1 range
))))
240 (let ((mouse-row (cdr (cdr (mouse-position)))))
245 (- mouse-row top
) mouse-drag-overlay start-point
))
247 (>= mouse-row bottom
))
248 (mouse-scroll-subr (1+ (- mouse-row bottom
))
249 mouse-drag-overlay start-point
)))))))))
251 (if (and (eq (get (event-basic-type event
) 'event-kind
) 'mouse-click
)
252 (eq (posn-window (event-end event
)) start-window
)
253 (numberp (posn-point (event-end event
))))
254 (let ((fun (key-binding (vector (car event
)))))
255 (if (memq fun
'(mouse-set-region mouse-set-point
))
256 (if (not (= (overlay-start mouse-drag-overlay
)
257 (overlay-end mouse-drag-overlay
)))
259 (push-mark (overlay-start mouse-drag-overlay
) t t
)
260 (goto-char (overlay-end mouse-drag-overlay
))
261 (copy-region-as-kill (point) (mark t
)))
262 (goto-char (overlay-end mouse-drag-overlay
))
263 (setq this-command
'mouse-set-point
))
265 (funcall fun event
)))))
266 (delete-overlay mouse-drag-overlay
))))
268 ;; Commands to handle xterm-style multiple clicks.
270 (defun mouse-skip-word (dir)
271 "Skip over word, over whitespace, or over identical punctuation.
272 If DIR is positive skip forward; if negative, skip backward."
273 (let* ((char (following-char))
274 (syntax (char-to-string (char-syntax char
))))
275 (if (or (string= syntax
"w") (string= syntax
" "))
277 (skip-syntax-backward syntax
)
278 (skip-syntax-forward syntax
))
280 (while (and (not (bobp)) (= (preceding-char) char
))
282 (while (and (not (eobp)) (= (following-char) char
))
283 (forward-char 1))))))
285 ;; Return a list of region bounds based on START and END according to MODE.
286 ;; If MODE is 0 then set point to (min START END), mark to (max START END).
287 ;; If MODE is 1 then set point to start of word at (min START END),
288 ;; mark to end of word at (max START END).
289 ;; If MODE is 2 then do the same for lines.
290 (defun mouse-start-end (start end mode
)
295 (setq mode
(mod mode
3))
301 (= (char-syntax (char-after start
)) ?\
())
310 (= (char-syntax (char-after start
)) ?\
)))
311 (list (save-excursion
312 (goto-char (1+ start
))
317 (list (save-excursion
326 (list (save-excursion
328 (beginning-of-line 1)
335 ;; Subroutine: set the mark where CLICK happened,
336 ;; but don't do anything else.
337 (defun mouse-set-mark-fast (click)
338 (mouse-minibuffer-check click
)
339 (let ((posn (event-start click
)))
340 (select-window (posn-window posn
))
341 (if (numberp (posn-point posn
))
342 (push-mark (posn-point posn
) t t
))))
344 ;; Momentarily show where the mark is, if highlighting doesn't show it.
345 (defun mouse-show-mark ()
346 (or transient-mark-mode
351 (defun mouse-set-mark (click)
352 "Set mark at the position clicked on with the mouse.
353 Display cursor at that position for a second.
354 This must be bound to a mouse click."
356 (let ((point-save (point)))
358 (progn (mouse-set-point click
)
360 (or transient-mark-mode
362 (goto-char point-save
))))
364 (defun mouse-kill (click)
365 "Kill the region between point and the mouse click.
366 The text is saved in the kill ring, as with \\[kill-region]."
368 (mouse-minibuffer-check click
)
369 (let* ((posn (event-start click
))
370 (click-posn (posn-point posn
)))
371 (select-window (posn-window posn
))
372 (if (numberp click-posn
)
373 (kill-region (min (point) click-posn
)
374 (max (point) click-posn
)))))
376 (defun mouse-yank-at-click (click arg
)
377 "Insert the last stretch of killed text at the position clicked on.
378 Also move point to one end of the text thus inserted (normally the end).
379 Prefix arguments are interpreted as with \\[yank].
380 If `mouse-yank-at-point' is non-nil, insert at point
381 regardless of where you click."
383 (or mouse-yank-at-point
(mouse-set-point click
))
384 (setq this-command
'yank
)
387 (defun mouse-kill-ring-save (click)
388 "Copy the region between point and the mouse click in the kill ring.
389 This does not delete the region; it acts like \\[kill-ring-save]."
391 (mouse-set-mark-fast click
)
392 (kill-ring-save (point) (mark t
))
395 ;;; This function used to delete the text between point and the mouse
396 ;;; whenever it was equal to the front of the kill ring, but some
397 ;;; people found that confusing.
399 ;;; A list (TEXT START END), describing the text and position of the last
400 ;;; invocation of mouse-save-then-kill.
401 (defvar mouse-save-then-kill-posn nil
)
403 (defun mouse-save-then-kill-delete-region (beg end
)
404 ;; We must make our own undo boundaries
405 ;; because they happen automatically only for the current buffer.
407 (if (or (= beg end
) (eq buffer-undo-list t
))
408 ;; If we have no undo list in this buffer,
410 (delete-region beg end
)
411 ;; Delete, but make the undo-list entry share with the kill ring.
412 ;; First, delete just one char, so in case buffer is being modified
413 ;; for the first time, the undo list records that fact.
415 (+ beg
(if (> end beg
) 1 -
1)))
416 (let ((buffer-undo-list buffer-undo-list
))
417 ;; Undo that deletion--but don't change the undo list!
418 (primitive-undo 1 buffer-undo-list
)
419 ;; Now delete the rest of the specified region,
420 ;; but don't record it.
421 (setq buffer-undo-list t
)
422 (if (/= (length (car kill-ring
)) (- (max end beg
) (min end beg
)))
423 (error "Lossage in mouse-save-then-kill-delete-region"))
424 (delete-region beg end
))
425 (let ((tail buffer-undo-list
))
426 ;; Search back in buffer-undo-list for the string
427 ;; that came from deleting one character.
428 (while (and tail
(not (stringp (car (car tail
)))))
429 (setq tail
(cdr tail
)))
430 ;; Replace it with an entry for the entire deleted text.
432 (setcar tail
(cons (car kill-ring
) (min beg end
))))))
435 (defun mouse-save-then-kill (click)
436 "Save text to point in kill ring; the second time, kill the text.
437 If the text between point and the mouse is the same as what's
438 at the front of the kill ring, this deletes the text.
439 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
440 which prepares for a second click to delete the text.
442 If you have selected words or lines, this command extends the
443 selection through the word or line clicked on. If you do this
444 again in a different position, it extends the selection again.
445 If you do this twice in the same position, the selection is killed."
447 (mouse-minibuffer-check click
)
448 (let ((click-posn (posn-point (event-start click
)))
449 ;; Don't let a subsequent kill command append to this one:
450 ;; prevent setting this-command to kill-region.
451 (this-command this-command
))
452 (if (> (mod mouse-selection-click-count
3) 0)
453 (if (not (and (eq last-command
'mouse-save-then-kill
)
455 (car (cdr-safe (cdr-safe mouse-save-then-kill-posn
))))))
456 ;; Find both ends of the object selected by this click.
458 (mouse-start-end click-posn click-posn
459 mouse-selection-click-count
)))
460 ;; Move whichever end is closer to the click.
461 ;; That's what xterm does, and it seems reasonable.
462 (if (< (abs (- click-posn
(mark t
)))
463 (abs (- click-posn
(point))))
464 (set-mark (car range
))
465 (goto-char (nth 1 range
)))
466 ;; We have already put the old region in the kill ring.
467 ;; Replace it with the extended region.
468 ;; (It would be annoying to make a separate entry.)
469 (setcar kill-ring
(buffer-substring (point) (mark t
)))
470 (if interprogram-cut-function
471 (funcall interprogram-cut-function
(car kill-ring
)))
472 ;; Arrange for a repeated mouse-3 to kill this region.
473 (setq mouse-save-then-kill-posn
474 (list (car kill-ring
) (point) click-posn
))
476 ;; If we click this button again without moving it,
478 (mouse-save-then-kill-delete-region (point) (mark))
479 (setq mouse-selection-click-count
0)
480 (setq mouse-save-then-kill-posn nil
))
481 (if (and (eq last-command
'mouse-save-then-kill
)
482 mouse-save-then-kill-posn
483 (eq (car mouse-save-then-kill-posn
) (car kill-ring
))
484 (equal (cdr mouse-save-then-kill-posn
) (list (point) click-posn
)))
485 ;; If this is the second time we've called
486 ;; mouse-save-then-kill, delete the text from the buffer.
488 (mouse-save-then-kill-delete-region (point) (mark))
489 ;; After we kill, another click counts as "the first time".
490 (setq mouse-save-then-kill-posn nil
))
491 (if (or (and (eq last-command
'mouse-save-then-kill
)
492 mouse-save-then-kill-posn
)
493 (and mark-active transient-mark-mode
)
494 (and (eq last-command
'mouse-drag-region
)
495 (or mark-even-if-inactive
496 (not transient-mark-mode
))))
497 ;; We have a selection or suitable region, so adjust it.
498 (let* ((posn (event-start click
))
499 (new (posn-point posn
)))
500 (select-window (posn-window posn
))
503 ;; Move whichever end of the region is closer to the click.
504 ;; That is what xterm does, and it seems reasonable.
505 (if (< (abs (- new
(point))) (abs (- new
(mark t
))))
508 (setq deactivate-mark nil
)))
509 (setcar kill-ring
(buffer-substring (point) (mark t
)))
510 (if interprogram-cut-function
511 (funcall interprogram-cut-function
(car kill-ring
))))
512 ;; We just have point, so set mark here.
513 (mouse-set-mark-fast click
)
514 (kill-ring-save (point) (mark t
))
516 (setq mouse-save-then-kill-posn
517 (list (car kill-ring
) (point) click-posn
))))))
519 (global-set-key [M-mouse-1
] 'mouse-start-secondary
)
520 (global-set-key [M-drag-mouse-1
] 'mouse-set-secondary
)
521 (global-set-key [M-down-mouse-1
] 'mouse-drag-secondary
)
522 (global-set-key [M-mouse-3
] 'mouse-secondary-save-then-kill
)
523 (global-set-key [M-mouse-2
] 'mouse-yank-secondary
)
525 ;; An overlay which records the current secondary selection
526 ;; or else is deleted when there is no secondary selection.
528 (defvar mouse-secondary-overlay nil
)
530 ;; A marker which records the specified first end for a secondary selection.
532 (defvar mouse-secondary-start nil
)
534 (defun mouse-start-secondary (click)
535 "Set one end of the secondary selection to the position clicked on.
536 Use \\[mouse-secondary-save-then-kill] to set the other end
537 and complete the secondary selection."
539 (mouse-minibuffer-check click
)
540 (let ((posn (event-start click
)))
542 (set-buffer (window-buffer (posn-window posn
)))
543 ;; Cancel any preexisting secondary selection.
544 (if mouse-secondary-overlay
545 (delete-overlay mouse-secondary-overlay
))
546 (if (numberp (posn-point posn
))
548 (or mouse-secondary-start
549 (setq mouse-secondary-start
(make-marker)))
550 (move-marker mouse-secondary-start
(posn-point posn
)))))))
552 (defun mouse-set-secondary (click)
553 "Set the secondary selection to the text that the mouse is dragged over.
554 This must be bound to a mouse drag event."
556 (mouse-minibuffer-check click
)
557 (let ((posn (event-start click
))
559 (end (event-end click
)))
561 (set-buffer (window-buffer (posn-window posn
)))
562 (if (numberp (posn-point posn
))
563 (setq beg
(posn-point posn
)))
564 (if mouse-secondary-overlay
565 (move-overlay mouse-secondary-overlay beg
(posn-point end
))
566 (setq mouse-secondary-overlay
(make-overlay beg
(posn-point end
))))
567 (overlay-put mouse-secondary-overlay
'face
'secondary-selection
))))
569 (defun mouse-drag-secondary (start-event)
570 "Set the secondary selection to the text that the mouse is dragged over.
571 Highlight the drag area as you move the mouse.
572 This must be bound to a button-down mouse event."
574 (mouse-minibuffer-check start-event
)
575 (let* ((start-posn (event-start start-event
))
576 (start-point (posn-point start-posn
))
577 (start-window (posn-window start-posn
))
578 (start-frame (window-frame start-window
))
579 (bounds (window-edges start-window
))
581 (bottom (if (window-minibuffer-p start-window
)
583 ;; Don't count the mode line.
584 (1- (nth 3 bounds
))))
585 (click-count (1- (event-click-count start-event
))))
587 (set-buffer (window-buffer start-window
))
588 (setq mouse-selection-click-count click-count
)
589 (or mouse-secondary-overlay
590 (setq mouse-secondary-overlay
591 (make-overlay (point) (point))))
592 (overlay-put mouse-secondary-overlay
'face
'secondary-selection
)
593 (if (> (mod click-count
3) 0)
594 ;; Double or triple press: make an initial selection
595 ;; of one word or line.
596 (let ((range (mouse-start-end start-point start-point click-count
)))
597 (set-marker mouse-secondary-start nil
)
598 (move-overlay mouse-secondary-overlay
1 1
599 (window-buffer start-window
))
600 (move-overlay mouse-secondary-overlay
(car range
) (nth 1 range
)
601 (window-buffer start-window
)))
602 ;; Single-press: cancel any preexisting secondary selection.
603 (or mouse-secondary-start
604 (setq mouse-secondary-start
(make-marker)))
605 (set-marker mouse-secondary-start start-point
)
606 (delete-overlay mouse-secondary-overlay
))
607 (let (event end end-point
)
610 (setq event
(read-event))
611 (or (mouse-movement-p event
)
612 (eq (car-safe event
) 'switch-frame
)))
614 (if (eq (car-safe event
) 'switch-frame
)
616 (setq end
(event-end event
)
617 end-point
(posn-point end
))
620 ;; Ignore switch-frame events.
621 ((eq (car-safe event
) 'switch-frame
))
623 ;; Are we moving within the original window?
624 ((and (eq (posn-window end
) start-window
)
625 (integer-or-marker-p end-point
))
626 (if (/= start-point end-point
)
627 (set-marker mouse-secondary-start nil
))
628 (let ((range (mouse-start-end start-point end-point
630 (move-overlay mouse-secondary-overlay
631 (car range
) (nth 1 range
))))
633 ;; Are we moving on a different window on the same frame?
634 ((and (windowp (posn-window end
))
635 (eq (window-frame (posn-window end
)) start-frame
))
637 (+ (nth 1 (window-edges (posn-window end
)))
638 (cdr (posn-col-row end
)))))
642 (- mouse-row top
) mouse-secondary-overlay start-point
))
644 (>= mouse-row bottom
))
645 (mouse-scroll-subr (1+ (- mouse-row bottom
))
646 mouse-drag-overlay start-point
)))))
649 (let ((mouse-y (cdr (cdr (mouse-position))))
650 (menu-bar-lines (or (cdr (assq 'menu-bar-lines
654 ;; Are we on the menu bar?
655 (and (integerp mouse-y
) (< mouse-y menu-bar-lines
)
656 (mouse-scroll-subr (- mouse-y menu-bar-lines
)
657 mouse-secondary-overlay start-point
))))))))
659 (if (and (eq (get (event-basic-type event
) 'event-kind
) 'mouse-click
)
660 (eq (posn-window (event-end event
)) start-window
)
661 (numberp (posn-point (event-end event
))))
662 (if (marker-position mouse-secondary-start
)
663 (save-window-excursion
664 (delete-overlay mouse-secondary-overlay
)
665 (x-set-selection 'SECONDARY nil
)
666 (select-window start-window
)
668 (goto-char mouse-secondary-start
)
672 (buffer-substring (overlay-start mouse-secondary-overlay
)
673 (overlay-end mouse-secondary-overlay
)))))))))
675 (defun mouse-yank-secondary (click)
676 "Insert the secondary selection at the position clicked on.
677 Move point to the end of the inserted text.
678 If `mouse-yank-at-point' is non-nil, insert at point
679 regardless of where you click."
681 (or mouse-yank-at-point
(mouse-set-point click
))
682 (insert (x-get-selection 'SECONDARY
)))
684 (defun mouse-kill-secondary ()
685 "Kill the text in the secondary selection.
686 This is intended more as a keyboard command than as a mouse command
687 but it can work as either one.
689 The current buffer (in case of keyboard use), or the buffer clicked on,
690 must be the one that the secondary selection is in. This requirement
691 is to prevent accidents."
693 (let* ((keys (this-command-keys))
694 (click (elt keys
(1- (length keys
)))))
695 (or (eq (overlay-buffer mouse-secondary-overlay
)
697 (window-buffer (posn-window (event-start click
)))
699 (error "Select or click on the buffer where the secondary selection is")))
701 (set-buffer (overlay-buffer mouse-secondary-overlay
))
702 (kill-region (overlay-start mouse-secondary-overlay
)
703 (overlay-end mouse-secondary-overlay
)))
704 (delete-overlay mouse-secondary-overlay
)
705 (x-set-selection 'SECONDARY nil
)
706 (setq mouse-secondary-overlay nil
))
708 (defun mouse-secondary-save-then-kill (click)
709 "Save text to point in kill ring; the second time, kill the text.
710 If the text between point and the mouse is the same as what's
711 at the front of the kill ring, this deletes the text.
712 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
713 which prepares for a second click to delete the text.
715 If you have selected words or lines, this command extends the
716 selection through the word or line clicked on. If you do this
717 again in a different position, it extends the selection again.
718 If you do this twice in the same position, the selection is killed."
720 (mouse-minibuffer-check click
)
721 (let ((posn (event-start click
))
722 (click-posn (posn-point (event-start click
)))
723 ;; Don't let a subsequent kill command append to this one:
724 ;; prevent setting this-command to kill-region.
725 (this-command this-command
))
726 (or (eq (window-buffer (posn-window posn
))
727 (or (and mouse-secondary-overlay
728 (overlay-buffer mouse-secondary-overlay
))
729 (if mouse-secondary-start
730 (marker-buffer mouse-secondary-start
))))
731 (error "Wrong buffer"))
733 (set-buffer (window-buffer (posn-window posn
)))
734 (if (> (mod mouse-selection-click-count
3) 0)
735 (if (not (and (eq last-command
'mouse-secondary-save-then-kill
)
737 (car (cdr-safe (cdr-safe mouse-save-then-kill-posn
))))))
738 ;; Find both ends of the object selected by this click.
740 (mouse-start-end click-posn click-posn
741 mouse-selection-click-count
)))
742 ;; Move whichever end is closer to the click.
743 ;; That's what xterm does, and it seems reasonable.
744 (if (< (abs (- click-posn
(overlay-start mouse-secondary-overlay
)))
745 (abs (- click-posn
(overlay-end mouse-secondary-overlay
))))
746 (move-overlay mouse-secondary-overlay
(car range
)
747 (overlay-end mouse-secondary-overlay
))
748 (move-overlay mouse-secondary-overlay
749 (overlay-start mouse-secondary-overlay
)
751 ;; We have already put the old region in the kill ring.
752 ;; Replace it with the extended region.
753 ;; (It would be annoying to make a separate entry.)
754 (setcar kill-ring
(buffer-substring
755 (overlay-start mouse-secondary-overlay
)
756 (overlay-end mouse-secondary-overlay
)))
757 (if interprogram-cut-function
758 (funcall interprogram-cut-function
(car kill-ring
)))
759 ;; Arrange for a repeated mouse-3 to kill this region.
760 (setq mouse-save-then-kill-posn
761 (list (car kill-ring
) (point) click-posn
)))
762 ;; If we click this button again without moving it,
765 (mouse-save-then-kill-delete-region
766 (overlay-start mouse-secondary-overlay
)
767 (overlay-end mouse-secondary-overlay
))
768 (setq mouse-save-then-kill-posn nil
)
769 (setq mouse-selection-click-count
0)
770 (delete-overlay mouse-secondary-overlay
)))
771 (if (and (eq last-command
'mouse-secondary-save-then-kill
)
772 mouse-save-then-kill-posn
773 (eq (car mouse-save-then-kill-posn
) (car kill-ring
))
774 (equal (cdr mouse-save-then-kill-posn
) (list (point) click-posn
)))
775 ;; If this is the second time we've called
776 ;; mouse-secondary-save-then-kill, delete the text from the buffer.
778 (mouse-save-then-kill-delete-region
779 (overlay-start mouse-secondary-overlay
)
780 (overlay-end mouse-secondary-overlay
))
781 (setq mouse-save-then-kill-posn nil
)
782 (delete-overlay mouse-secondary-overlay
))
783 (if (overlay-start mouse-secondary-overlay
)
784 ;; We have a selection, so adjust it.
786 (if (numberp click-posn
)
788 ;; Move whichever end of the region is closer to the click.
789 ;; That is what xterm does, and it seems reasonable.
790 (if (< (abs (- click-posn
(overlay-start mouse-secondary-overlay
)))
791 (abs (- click-posn
(overlay-end mouse-secondary-overlay
))))
792 (move-overlay mouse-secondary-overlay click-posn
793 (overlay-end mouse-secondary-overlay
))
794 (move-overlay mouse-secondary-overlay
795 (overlay-start mouse-secondary-overlay
)
797 (setq deactivate-mark nil
)))
798 (setcar kill-ring
(buffer-substring
799 (overlay-start mouse-secondary-overlay
)
800 (overlay-end mouse-secondary-overlay
)))
801 (if interprogram-cut-function
802 (funcall interprogram-cut-function
(car kill-ring
))))
803 (if mouse-secondary-start
804 ;; All we have is one end of a selection,
805 ;; so put the other end here.
806 (let ((start (+ 0 mouse-secondary-start
)))
807 (kill-ring-save start click-posn
)
808 (if mouse-secondary-overlay
809 (move-overlay mouse-secondary-overlay start click-posn
)
810 (setq mouse-secondary-overlay
(make-overlay start click-posn
)))
811 (overlay-put mouse-secondary-overlay
'face
'secondary-selection
))))
812 (setq mouse-save-then-kill-posn
813 (list (car kill-ring
) (point) click-posn
))))
814 (x-set-selection 'SECONDARY
815 (if (overlay-buffer mouse-secondary-overlay
)
817 (overlay-start mouse-secondary-overlay
)
818 (overlay-end mouse-secondary-overlay
)))))))
820 (defun mouse-buffer-menu (event)
821 "Pop up a menu of buffers for selection with the mouse.
822 This switches buffers in the window that you clicked on,
823 and selects that window."
825 (mouse-minibuffer-check event
)
828 (cons "Select Buffer"
829 (let ((tail (buffer-list))
833 (or (eq ?\
(aref (buffer-name (car tail
)) 0))
836 (length (buffer-name (car tail
))))))
837 (setq tail
(cdr tail
)))
838 (setq tail
(buffer-list))
840 (let ((elt (car tail
)))
841 (if (not (string-match "^ "
846 (format "%%%ds %%s%%s %%s"
849 (if (buffer-modified-p elt
)
853 (if buffer-read-only
"%" " "))
854 (or (buffer-file-name elt
) ""))
857 (setq tail
(cdr tail
)))
859 (let ((buf (x-popup-menu event menu
))
860 (window (posn-window (event-start event
))))
863 (or (framep window
) (select-window window
))
864 (switch-to-buffer buf
))))))
866 ;;; These need to be rewritten for the new scroll bar implementation.
868 ;;;!! ;; Commands for the scroll bar.
870 ;;;!! (defun mouse-scroll-down (click)
871 ;;;!! (interactive "@e")
872 ;;;!! (scroll-down (1+ (cdr (mouse-coords click)))))
874 ;;;!! (defun mouse-scroll-up (click)
875 ;;;!! (interactive "@e")
876 ;;;!! (scroll-up (1+ (cdr (mouse-coords click)))))
878 ;;;!! (defun mouse-scroll-down-full ()
879 ;;;!! (interactive "@")
880 ;;;!! (scroll-down nil))
882 ;;;!! (defun mouse-scroll-up-full ()
883 ;;;!! (interactive "@")
884 ;;;!! (scroll-up nil))
886 ;;;!! (defun mouse-scroll-move-cursor (click)
887 ;;;!! (interactive "@e")
888 ;;;!! (move-to-window-line (1+ (cdr (mouse-coords click)))))
890 ;;;!! (defun mouse-scroll-absolute (event)
891 ;;;!! (interactive "@e")
892 ;;;!! (let* ((pos (car event))
893 ;;;!! (position (car pos))
894 ;;;!! (length (car (cdr pos))))
895 ;;;!! (if (<= length 0) (setq length 1))
896 ;;;!! (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size)))))
897 ;;;!! (newpos (* (/ (* (/ (buffer-size) scale-factor)
900 ;;;!! scale-factor)))
901 ;;;!! (goto-char newpos)
902 ;;;!! (recenter '(4)))))
904 ;;;!! (defun mouse-scroll-left (click)
905 ;;;!! (interactive "@e")
906 ;;;!! (scroll-left (1+ (car (mouse-coords click)))))
908 ;;;!! (defun mouse-scroll-right (click)
909 ;;;!! (interactive "@e")
910 ;;;!! (scroll-right (1+ (car (mouse-coords click)))))
912 ;;;!! (defun mouse-scroll-left-full ()
913 ;;;!! (interactive "@")
914 ;;;!! (scroll-left nil))
916 ;;;!! (defun mouse-scroll-right-full ()
917 ;;;!! (interactive "@")
918 ;;;!! (scroll-right nil))
920 ;;;!! (defun mouse-scroll-move-cursor-horizontally (click)
921 ;;;!! (interactive "@e")
922 ;;;!! (move-to-column (1+ (car (mouse-coords click)))))
924 ;;;!! (defun mouse-scroll-absolute-horizontally (event)
925 ;;;!! (interactive "@e")
926 ;;;!! (let* ((pos (car event))
927 ;;;!! (position (car pos))
928 ;;;!! (length (car (cdr pos))))
929 ;;;!! (set-window-hscroll (selected-window) 33)))
931 ;;;!! (global-set-key [scroll-bar mouse-1] 'mouse-scroll-up)
932 ;;;!! (global-set-key [scroll-bar mouse-2] 'mouse-scroll-absolute)
933 ;;;!! (global-set-key [scroll-bar mouse-3] 'mouse-scroll-down)
935 ;;;!! (global-set-key [vertical-slider mouse-1] 'mouse-scroll-move-cursor)
936 ;;;!! (global-set-key [vertical-slider mouse-2] 'mouse-scroll-move-cursor)
937 ;;;!! (global-set-key [vertical-slider mouse-3] 'mouse-scroll-move-cursor)
939 ;;;!! (global-set-key [thumbup mouse-1] 'mouse-scroll-up-full)
940 ;;;!! (global-set-key [thumbup mouse-2] 'mouse-scroll-up-full)
941 ;;;!! (global-set-key [thumbup mouse-3] 'mouse-scroll-up-full)
943 ;;;!! (global-set-key [thumbdown mouse-1] 'mouse-scroll-down-full)
944 ;;;!! (global-set-key [thumbdown mouse-2] 'mouse-scroll-down-full)
945 ;;;!! (global-set-key [thumbdown mouse-3] 'mouse-scroll-down-full)
947 ;;;!! (global-set-key [horizontal-scroll-bar mouse-1] 'mouse-scroll-left)
948 ;;;!! (global-set-key [horizontal-scroll-bar mouse-2]
949 ;;;!! 'mouse-scroll-absolute-horizontally)
950 ;;;!! (global-set-key [horizontal-scroll-bar mouse-3] 'mouse-scroll-right)
952 ;;;!! (global-set-key [horizontal-slider mouse-1]
953 ;;;!! 'mouse-scroll-move-cursor-horizontally)
954 ;;;!! (global-set-key [horizontal-slider mouse-2]
955 ;;;!! 'mouse-scroll-move-cursor-horizontally)
956 ;;;!! (global-set-key [horizontal-slider mouse-3]
957 ;;;!! 'mouse-scroll-move-cursor-horizontally)
959 ;;;!! (global-set-key [thumbleft mouse-1] 'mouse-scroll-left-full)
960 ;;;!! (global-set-key [thumbleft mouse-2] 'mouse-scroll-left-full)
961 ;;;!! (global-set-key [thumbleft mouse-3] 'mouse-scroll-left-full)
963 ;;;!! (global-set-key [thumbright mouse-1] 'mouse-scroll-right-full)
964 ;;;!! (global-set-key [thumbright mouse-2] 'mouse-scroll-right-full)
965 ;;;!! (global-set-key [thumbright mouse-3] 'mouse-scroll-right-full)
967 ;;;!! (global-set-key [horizontal-scroll-bar S-mouse-2]
968 ;;;!! 'mouse-split-window-horizontally)
969 ;;;!! (global-set-key [mode-line S-mouse-2]
970 ;;;!! 'mouse-split-window-horizontally)
971 ;;;!! (global-set-key [vertical-scroll-bar S-mouse-2]
972 ;;;!! 'mouse-split-window)
975 ;;;!! ;;;; Here are experimental things being tested. Mouse events
976 ;;;!! ;;;; are of the form:
977 ;;;!! ;;;; ((x y) window screen-part key-sequence timestamp)
980 ;;;!! ;;;; Dynamically track mouse coordinates
983 ;;;!! ;;(defun track-mouse (event)
984 ;;;!! ;; "Track the coordinates, absolute and relative, of the mouse."
985 ;;;!! ;; (interactive "@e")
986 ;;;!! ;; (while mouse-grabbed
987 ;;;!! ;; (let* ((pos (read-mouse-position (selected-screen)))
988 ;;;!! ;; (abs-x (car pos))
989 ;;;!! ;; (abs-y (cdr pos))
990 ;;;!! ;; (relative-coordinate (coordinates-in-window-p
991 ;;;!! ;; (list (car pos) (cdr pos))
992 ;;;!! ;; (selected-window))))
993 ;;;!! ;; (if (consp relative-coordinate)
994 ;;;!! ;; (message "mouse: [%d %d], (%d %d)" abs-x abs-y
995 ;;;!! ;; (car relative-coordinate)
996 ;;;!! ;; (car (cdr relative-coordinate)))
997 ;;;!! ;; (message "mouse: [%d %d]" abs-x abs-y)))))
1000 ;;;!! ;; Dynamically put a box around the line indicated by point
1003 ;;;!! ;;(require 'backquote)
1005 ;;;!! ;;(defun mouse-select-buffer-line (event)
1006 ;;;!! ;; (interactive "@e")
1007 ;;;!! ;; (let ((relative-coordinate
1008 ;;;!! ;; (coordinates-in-window-p (car event) (selected-window)))
1009 ;;;!! ;; (abs-y (car (cdr (car event)))))
1010 ;;;!! ;; (if (consp relative-coordinate)
1012 ;;;!! ;; (save-excursion
1013 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
1014 ;;;!! ;; (x-draw-rectangle
1015 ;;;!! ;; (selected-screen)
1017 ;;;!! ;; (save-excursion
1018 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
1019 ;;;!! ;; (end-of-line)
1020 ;;;!! ;; (push-mark nil t)
1021 ;;;!! ;; (beginning-of-line)
1022 ;;;!! ;; (- (region-end) (region-beginning))) 1))
1023 ;;;!! ;; (sit-for 1)
1024 ;;;!! ;; (x-erase-rectangle (selected-screen))))))
1026 ;;;!! ;;(defvar last-line-drawn nil)
1027 ;;;!! ;;(defvar begin-delim "[^ \t]")
1028 ;;;!! ;;(defvar end-delim "[^ \t]")
1030 ;;;!! ;;(defun mouse-boxing (event)
1031 ;;;!! ;; (interactive "@e")
1032 ;;;!! ;; (save-excursion
1033 ;;;!! ;; (let ((screen (selected-screen)))
1034 ;;;!! ;; (while (= (x-mouse-events) 0)
1035 ;;;!! ;; (let* ((pos (read-mouse-position screen))
1036 ;;;!! ;; (abs-x (car pos))
1037 ;;;!! ;; (abs-y (cdr pos))
1038 ;;;!! ;; (relative-coordinate
1039 ;;;!! ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y)))
1040 ;;;!! ;; (selected-window)))
1041 ;;;!! ;; (begin-reg nil)
1042 ;;;!! ;; (end-reg nil)
1043 ;;;!! ;; (end-column nil)
1044 ;;;!! ;; (begin-column nil))
1045 ;;;!! ;; (if (and (consp relative-coordinate)
1046 ;;;!! ;; (or (not last-line-drawn)
1047 ;;;!! ;; (not (= last-line-drawn abs-y))))
1049 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
1050 ;;;!! ;; (if (= (following-char) 10)
1053 ;;;!! ;; (setq begin-reg (1- (re-search-forward end-delim)))
1054 ;;;!! ;; (setq begin-column (1- (current-column)))
1055 ;;;!! ;; (end-of-line)
1056 ;;;!! ;; (setq end-reg (1+ (re-search-backward begin-delim)))
1057 ;;;!! ;; (setq end-column (1+ (current-column)))
1058 ;;;!! ;; (message "%s" (buffer-substring begin-reg end-reg))
1059 ;;;!! ;; (x-draw-rectangle screen
1060 ;;;!! ;; (setq last-line-drawn abs-y)
1061 ;;;!! ;; begin-column
1062 ;;;!! ;; (- end-column begin-column) 1))))))))))
1064 ;;;!! ;;(defun mouse-erase-box ()
1065 ;;;!! ;; (interactive)
1066 ;;;!! ;; (if last-line-drawn
1068 ;;;!! ;; (x-erase-rectangle (selected-screen))
1069 ;;;!! ;; (setq last-line-drawn nil))))
1071 ;;;!! ;;; (defun test-x-rectangle ()
1072 ;;;!! ;;; (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap)))
1073 ;;;!! ;;; (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing)
1074 ;;;!! ;;; (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box))
1077 ;;;!! ;; Here is how to do double clicking in lisp. About to change.
1080 ;;;!! (defvar double-start nil)
1081 ;;;!! (defconst double-click-interval 300
1082 ;;;!! "Max ticks between clicks")
1084 ;;;!! (defun double-down (event)
1085 ;;;!! (interactive "@e")
1086 ;;;!! (if double-start
1087 ;;;!! (let ((interval (- (nth 4 event) double-start)))
1088 ;;;!! (if (< interval double-click-interval)
1090 ;;;!! (backward-up-list 1)
1091 ;;;!! ;; (message "Interval %d" interval)
1092 ;;;!! (sleep-for 1)))
1093 ;;;!! (setq double-start nil))
1094 ;;;!! (setq double-start (nth 4 event))))
1096 ;;;!! (defun double-up (event)
1097 ;;;!! (interactive "@e")
1098 ;;;!! (and double-start
1099 ;;;!! (> (- (nth 4 event ) double-start) double-click-interval)
1100 ;;;!! (setq double-start nil)))
1102 ;;;!! ;;; (defun x-test-doubleclick ()
1103 ;;;!! ;;; (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap)))
1104 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left 'double-down)
1105 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left-up 'double-up))
1108 ;;;!! ;; This scrolls while button is depressed. Use preferable in scroll bar.
1111 ;;;!! (defvar scrolled-lines 0)
1112 ;;;!! (defconst scroll-speed 1)
1114 ;;;!! (defun incr-scroll-down (event)
1115 ;;;!! (interactive "@e")
1116 ;;;!! (setq scrolled-lines 0)
1117 ;;;!! (incremental-scroll scroll-speed))
1119 ;;;!! (defun incr-scroll-up (event)
1120 ;;;!! (interactive "@e")
1121 ;;;!! (setq scrolled-lines 0)
1122 ;;;!! (incremental-scroll (- scroll-speed)))
1124 ;;;!! (defun incremental-scroll (n)
1125 ;;;!! (while (= (x-mouse-events) 0)
1126 ;;;!! (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
1127 ;;;!! (scroll-down n)
1128 ;;;!! (sit-for 300 t)))
1130 ;;;!! (defun incr-scroll-stop (event)
1131 ;;;!! (interactive "@e")
1132 ;;;!! (message "Scrolled %d lines" scrolled-lines)
1133 ;;;!! (setq scrolled-lines 0)
1134 ;;;!! (sleep-for 1))
1136 ;;;!! ;;; (defun x-testing-scroll ()
1137 ;;;!! ;;; (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix)))
1138 ;;;!! ;;; (define-key scrolling-map mouse-button-left 'incr-scroll-down)
1139 ;;;!! ;;; (define-key scrolling-map mouse-button-right 'incr-scroll-up)
1140 ;;;!! ;;; (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop)
1141 ;;;!! ;;; (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop)))
1144 ;;;!! ;; Some playthings suitable for picture mode? They need work.
1147 ;;;!! (defun mouse-kill-rectangle (event)
1148 ;;;!! "Kill the rectangle between point and the mouse cursor."
1149 ;;;!! (interactive "@e")
1150 ;;;!! (let ((point-save (point)))
1151 ;;;!! (save-excursion
1152 ;;;!! (mouse-set-point event)
1153 ;;;!! (push-mark nil t)
1154 ;;;!! (if (> point-save (point))
1155 ;;;!! (kill-rectangle (point) point-save)
1156 ;;;!! (kill-rectangle point-save (point))))))
1158 ;;;!! (defun mouse-open-rectangle (event)
1159 ;;;!! "Kill the rectangle between point and the mouse cursor."
1160 ;;;!! (interactive "@e")
1161 ;;;!! (let ((point-save (point)))
1162 ;;;!! (save-excursion
1163 ;;;!! (mouse-set-point event)
1164 ;;;!! (push-mark nil t)
1165 ;;;!! (if (> point-save (point))
1166 ;;;!! (open-rectangle (point) point-save)
1167 ;;;!! (open-rectangle point-save (point))))))
1169 ;;;!! ;; Must be a better way to do this.
1171 ;;;!! (defun mouse-multiple-insert (n char)
1172 ;;;!! (while (> n 0)
1174 ;;;!! (setq n (1- n))))
1176 ;;;!! ;; What this could do is not finalize until button was released.
1178 ;;;!! (defun mouse-move-text (event)
1179 ;;;!! "Move text from point to cursor position, inserting spaces."
1180 ;;;!! (interactive "@e")
1181 ;;;!! (let* ((relative-coordinate
1182 ;;;!! (coordinates-in-window-p (car event) (selected-window))))
1183 ;;;!! (if (consp relative-coordinate)
1184 ;;;!! (cond ((> (current-column) (car relative-coordinate))
1186 ;;;!! (- (car relative-coordinate) (current-column))))
1187 ;;;!! ((< (current-column) (car relative-coordinate))
1188 ;;;!! (mouse-multiple-insert
1189 ;;;!! (- (car relative-coordinate) (current-column)) " "))
1190 ;;;!! ((= (current-column) (car relative-coordinate)) (ding))))))
1192 ;; Choose a completion with the mouse.
1194 (defun mouse-choose-completion (event)
1195 "Click on an alternative in the `*Completions*' buffer to choose it."
1197 (let ((buffer (window-buffer))
1200 (set-buffer (window-buffer (posn-window (event-start event
))))
1201 (if completion-reference-buffer
1202 (setq buffer completion-reference-buffer
))
1204 (goto-char (posn-point (event-start event
)))
1205 (skip-chars-backward "^ \t\n")
1206 (let ((beg (point)))
1207 (skip-chars-forward "^ \t\n")
1208 (setq choice
(buffer-substring beg
(point))))))
1209 (let ((owindow (selected-window)))
1210 (select-window (posn-window (event-start event
)))
1212 (select-window owindow
))
1213 (choose-completion-string choice buffer
)))
1217 (defun font-menu-add-default ()
1218 (let* ((default (cdr (assq 'font
(frame-parameters (selected-frame)))))
1219 (font-alist x-fixed-font-alist
)
1220 (elt (or (assoc "Misc" font-alist
) (nth 1 font-alist
))))
1221 (if (assoc "Default" elt
)
1222 (delete (assoc "Default" elt
) elt
))
1224 (cons (list "Default"
1225 (cdr (assq 'font
(frame-parameters (selected-frame)))))
1228 (defvar x-fixed-font-alist
1231 ("6x10" "-misc-fixed-medium-r-normal--10-100-75-75-c-60-*-1" "6x10")
1232 ("6x12" "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-*-1" "6x12")
1233 ("6x13" "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-1" "6x13")
1235 "-b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-*-1")
1236 ("7x13" "-misc-fixed-medium-r-normal--13-120-75-75-c-70-*-1" "7x13")
1237 ("7x14" "-misc-fixed-medium-r-normal--14-130-75-75-c-70-*-1" "7x14")
1238 ("9x15" "-misc-fixed-medium-r-normal--15-140-*-*-c-*-*-1" "9x15")
1240 ("clean 8x8" "-schumacher-clean-medium-r-normal--*-80-*-*-c-*-*-1")
1241 ("clean 8x14" "-schumacher-clean-medium-r-normal--*-140-*-*-c-*-*-1")
1242 ("clean 8x10" "-schumacher-clean-medium-r-normal--*-100-*-*-c-*-*-1")
1243 ("clean 8x16" "-schumacher-clean-medium-r-normal--*-160-*-*-c-*-*-1")
1245 ("sony 8x16" "-sony-fixed-medium-r-normal--16-120-100-100-c-80-*-1")
1251 ;;; We don't seem to have these; who knows what they are.
1252 ;;; ("fg-18" "fg-18")
1253 ;;; ("fg-25" "fg-25")
1254 ;;; ("lucidasanstypewriter-12" "lucidasanstypewriter-12")
1255 ;;; ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14")
1256 ;;; ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24")
1257 ;;; ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1")
1258 ;;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*")
1260 ("8" "-adobe-courier-medium-r-normal--*-80-*-*-m-*-iso8859-1")
1261 ("10" "-adobe-courier-medium-r-normal--*-100-*-*-m-*-iso8859-1")
1262 ("12" "-adobe-courier-medium-r-normal--*-120-*-*-m-*-iso8859-1")
1263 ("14" "-adobe-courier-medium-r-normal--*-140-*-*-m-*-iso8859-1")
1264 ("18" "-adobe-courier-medium-r-normal--*-180-*-*-m-*-iso8859-1")
1265 ("24" "-adobe-courier-medium-r-normal--*-240-*-*-m-*-iso8859-1")
1266 ("8 bold" "-adobe-courier-bold-r-normal--*-80-*-*-m-*-iso8859-1")
1267 ("10 bold" "-adobe-courier-bold-r-normal--*-100-*-*-m-*-iso8859-1")
1268 ("12 bold" "-adobe-courier-bold-r-normal--*-120-*-*-m-*-iso8859-1")
1269 ("14 bold" "-adobe-courier-bold-r-normal--*-140-*-*-m-*-iso8859-1")
1270 ("18 bold" "-adobe-courier-bold-r-normal--*-180-*-*-m-*-iso8859-1")
1271 ("24 bold" "-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1")
1272 ("8 slant" "-adobe-courier-medium-o-normal--*-80-*-*-m-*-iso8859-1")
1273 ("10 slant" "-adobe-courier-medium-o-normal--*-100-*-*-m-*-iso8859-1")
1274 ("12 slant" "-adobe-courier-medium-o-normal--*-120-*-*-m-*-iso8859-1")
1275 ("14 slant" "-adobe-courier-medium-o-normal--*-140-*-*-m-*-iso8859-1")
1276 ("18 slant" "-adobe-courier-medium-o-normal--*-180-*-*-m-*-iso8859-1")
1277 ("24 slant" "-adobe-courier-medium-o-normal--*-240-*-*-m-*-iso8859-1")
1278 ("8 bold slant" "-adobe-courier-bold-o-normal--*-80-*-*-m-*-iso8859-1")
1279 ("10 bold slant" "-adobe-courier-bold-o-normal--*-100-*-*-m-*-iso8859-1")
1280 ("12 bold slant" "-adobe-courier-bold-o-normal--*-120-*-*-m-*-iso8859-1")
1281 ("14 bold slant" "-adobe-courier-bold-o-normal--*-140-*-*-m-*-iso8859-1")
1282 ("18 bold slant" "-adobe-courier-bold-o-normal--*-180-*-*-m-*-iso8859-1")
1283 ("24 bold slant" "-adobe-courier-bold-o-normal--*-240-*-*-m-*-iso8859-1"))
1285 "X fonts suitable for use in Emacs.")
1287 (defun mouse-set-font (&rest fonts
)
1288 "Select an emacs font from a list of known good fonts"
1290 (x-popup-menu last-nonmenu-event x-fixed-font-alist
))
1296 (modify-frame-parameters (selected-frame)
1297 (list (cons 'font
(car fonts
))))
1298 (setq font
(car fonts
))
1300 (error (setq fonts
(cdr fonts
)))))
1302 (error "Font not found")
1303 ;; Update some standard faces too.
1304 (set-face-font 'bold nil
(selected-frame))
1305 (make-face-bold 'bold
(selected-frame) t
)
1306 (set-face-font 'italic nil
(selected-frame))
1307 (make-face-italic 'italic
(selected-frame) t
)
1308 (set-face-font 'bold-italic nil
(selected-frame))
1309 (make-face-bold-italic 'bold-italic
(selected-frame) t
)
1310 ;; Update any nonstandard faces whose definition is
1311 ;; "a bold/italic/bold&italic version of the frame's font".
1312 (let ((rest global-face-data
))
1315 (if (listp (face-font (cdr (car rest
))))
1316 (let ((bold (memq 'bold
(face-font (cdr (car rest
)))))
1317 (italic (memq 'italic
(face-font (cdr (car rest
))))))
1318 (if (and bold italic
)
1319 (make-face-bold-italic (car (car rest
)) (selected-frame))
1321 (make-face-bold (car (car rest
)) (selected-frame))
1323 (make-face-italic (car (car rest
)) (selected-frame)))))))
1325 (setq rest
(cdr rest
))))))))
1327 ;;; Bindings for mouse commands.
1329 (define-key global-map
[down-mouse-1
] 'mouse-drag-region
)
1330 (global-set-key [mouse-1
] 'mouse-set-point
)
1331 (global-set-key [drag-mouse-1
] 'mouse-set-region
)
1333 ;; These are tested for in mouse-drag-region.
1334 (global-set-key [double-mouse-1
] 'mouse-set-point
)
1335 (global-set-key [triple-mouse-1
] 'mouse-set-point
)
1337 (global-set-key [mouse-2
] 'mouse-yank-at-click
)
1338 (global-set-key [mouse-3
] 'mouse-save-then-kill
)
1340 ;; By binding these to down-going events, we let the user use the up-going
1341 ;; event to make the selection, saving a click.
1342 (global-set-key [C-down-mouse-1
] 'mouse-buffer-menu
)
1343 (global-set-key [C-down-mouse-3
] 'mouse-set-font
)
1345 ;; Replaced with dragging mouse-1
1346 ;; (global-set-key [S-mouse-1] 'mouse-set-mark)
1348 (global-set-key [mode-line mouse-1
] 'mouse-select-window
)
1349 (global-set-key [mode-line mouse-2
] 'mouse-delete-other-windows
)
1350 (global-set-key [mode-line mouse-3
] 'mouse-delete-window
)
1351 (global-set-key [mode-line C-mouse-2
] 'mouse-split-window-horizontally
)
1355 ;;; mouse.el ends here