annotate lisp/mouse.el @ 8064:d04a39ce4f1d

(mouse-scroll-subr): Don't do anything special at eob. (mouse-drag-region): Don't treat scrolling differently at eob. (mouse-drag-secondary): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Sat, 25 Jun 1994 23:48:04 +0000
parents 76118755a179
children de6f0cdfd332
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; mouse.el --- window system-independent mouse support.
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
2
7298
4fd40bd394fe Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 7021
diff changeset
3 ;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
840
113281b361ec *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 791
diff changeset
4
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
5 ;; Maintainer: FSF
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
6 ;; Keywords: hardware
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
7
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
8 ;;; This file is part of GNU Emacs.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
11 ;;; it under the terms of the GNU General Public License as published by
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
12 ;;; the Free Software Foundation; either version 2, or (at your option)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
13 ;;; any later version.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
18 ;;; GNU General Public License for more details.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
20 ;;; You should have received a copy of the GNU General Public License
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
22 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
2308
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
24 ;;; Commentary:
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
25
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
26 ;; This package provides various useful commands (including help
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
27 ;; system access) through the mouse. All this code assumes that mouse
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
28 ;; interpretation has been abstracted into Emacs input events.
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
29 ;;
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
30 ;; The code is rather X-dependent.
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
31
2232
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2070
diff changeset
32 ;;; Code:
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2070
diff changeset
33
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
34 ;;; Utility functions.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
35
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
36 ;;; Indent track-mouse like progn.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
37 (put 'track-mouse 'lisp-indent-function 0)
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
39 (defvar mouse-yank-at-point nil
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
40 "*If non-nil, mouse yank commands yank at point instead of at click.")
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
41
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
42 (defun mouse-minibuffer-check (event)
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
43 (let ((w (posn-window (event-start event))))
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
44 (and (window-minibuffer-p w)
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
45 (not (minibuffer-window-active-p w))
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
46 (error "Minibuffer window is not active"))))
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
47
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
48 (defun mouse-delete-window (click)
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
49 "Delete the window you click on.
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
50 This must be bound to a mouse click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
51 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
52 (mouse-minibuffer-check click)
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
53 (delete-window (posn-window (event-start click))))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
54
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
55 (defun mouse-select-window (click)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
56 "Select the window clicked on; don't move point."
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
57 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
58 (mouse-minibuffer-check click)
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
59 (let ((oframe (selected-frame))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
60 (frame (window-frame (posn-window (event-start click)))))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
61 (select-window (posn-window (event-start click)))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
62 (raise-frame frame)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
63 (select-frame frame)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
64 (or (eq frame oframe)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
65 (set-mouse-position (selected-frame) (1- (frame-width)) 0))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
66 (unfocus-frame)))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
67
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
68 (defun mouse-tear-off-window (click)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
69 "Delete the window clicked on, and create a new frame displaying its buffer."
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
70 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
71 (mouse-minibuffer-check click)
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
72 (let* ((window (posn-window (event-start click)))
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
73 (buf (window-buffer window))
7363
f35fe65c9755 (mouse-tear-off-window): Change new-frame to make-frame.
Karl Heuer <kwzh@gnu.org>
parents: 7302
diff changeset
74 (frame (make-frame)))
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
75 (select-frame frame)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
76 (switch-to-buffer buf)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
77 (delete-window window)))
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
78
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
79 (defun mouse-delete-other-windows ()
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
80 "Delete all window except the one you click on."
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
81 (interactive "@")
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (delete-other-windows))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
84 (defun mouse-split-window-vertically (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
85 "Select Emacs window mouse is on, then split it vertically in half.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
86 The window is split at the line clicked on.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
87 This command must be bound to a mouse click."
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
88 (interactive "@e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
89 (mouse-minibuffer-check click)
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
90 (let ((start (event-start click)))
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
91 (select-window (posn-window start))
7637
cc55e77a9819 (mouse-split-window-vertically): Treat scroll bar events just like others.
Richard M. Stallman <rms@gnu.org>
parents: 7593
diff changeset
92 (let ((new-height (1+ (cdr (posn-col-row (event-end click)))))
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
93 (first-line window-min-height)
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
94 (last-line (- (window-height) window-min-height)))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
95 (if (< last-line first-line)
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
96 (error "window too short to split")
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
97 (split-window-vertically
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
98 (min (max new-height first-line) last-line))))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
100 (defun mouse-split-window-horizontally (click)
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
101 "Select Emacs window mouse is on, then split it horizontally in half.
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
102 The window is split at the column clicked on.
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
103 This command must be bound to a mouse click."
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
104 (interactive "@e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
105 (mouse-minibuffer-check click)
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
106 (let ((start (event-start click)))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
107 (select-window (posn-window start))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
108 (let ((new-width (1+ (car (posn-col-row (event-end click)))))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
109 (first-col window-min-width)
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
110 (last-col (- (window-width) window-min-width)))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
111 (if (< last-col first-col)
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
112 (error "window too narrow to split")
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
113 (split-window-horizontally
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
114 (min (max new-width first-col) last-col))))))
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
115
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
116 (defun mouse-set-point (event)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
117 "Move point to the position clicked on with the mouse.
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
118 This should be bound to a mouse click event type."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
119 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
120 (mouse-minibuffer-check event)
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
121 ;; Use event-end in case called from mouse-drag-region.
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
122 ;; If EVENT is a click, event-end and event-start give same value.
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
123 (let ((posn (event-end event)))
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
124 (select-window (posn-window posn))
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
125 (if (numberp (posn-point posn))
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
126 (goto-char (posn-point posn)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
128 (defun mouse-set-region (click)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
129 "Set the region to the text dragged over, and copy to kill ring.
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
130 This should be bound to a mouse drag event."
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
131 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
132 (mouse-minibuffer-check click)
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
133 (let ((posn (event-start click))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
134 (end (event-end click)))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
135 (select-window (posn-window posn))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
136 (if (numberp (posn-point posn))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
137 (goto-char (posn-point posn)))
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
138 ;; If mark is highlighted, no need to bounce the cursor.
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
139 (or (and transient-mark-mode
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
140 (eq (framep (selected-frame)) 'x))
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
141 (sit-for 1))
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
142 (push-mark)
2802
02c75b605550 (mouse-set-region): Call set-mark to activate mark.
Richard M. Stallman <rms@gnu.org>
parents: 2799
diff changeset
143 (set-mark (point))
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
144 (if (numberp (posn-point end))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
145 (goto-char (posn-point end)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
146 ;; Don't set this-command to kill-region, so that a following
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
147 ;; C-w will not double the text in the kill ring.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
148 (let (this-command)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
149 (copy-region-as-kill (mark) (point)))))
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
150
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
151 (defvar mouse-scroll-delay 0.25
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
152 "*The pause between scroll steps caused by mouse drags, in seconds.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
153 If you drag the mouse beyond the edge of a window, Emacs scrolls the
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
154 window to bring the text beyond that edge into view, with a delay of
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
155 this many seconds between scroll steps. Scrolling stops when you move
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
156 the mouse back into the window, or release the button.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
157 This variable's value may be non-integral.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
158 Setting this to zero causes Emacs to scroll as fast as it can.")
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
159
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
160 (defun mouse-scroll-subr (window jump &optional overlay start)
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
161 "Scroll the window WINDOW, JUMP lines at a time, until new input arrives.
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
162 If OVERLAY is an overlay, let it stretch from START to the far edge of
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
163 the newly visible text.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
164 Upon exit, point is at the far edge of the newly visible text."
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
165 (let ((opoint (point)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
166 (while (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
167 (goto-char (window-start window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
168 (if (not (zerop (vertical-motion jump window)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
169 (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
170 (set-window-start window (point))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
171 (if (natnump jump)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
172 (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
173 (goto-char (window-end window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
174 ;; window-end doesn't reflect the window's new
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
175 ;; start position until the next redisplay. Hurrah.
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
176 (vertical-motion (1- jump) window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
177 (goto-char (window-start window)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
178 (if overlay
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
179 (move-overlay overlay start (point)))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
180 (setq eobp (eobp))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
181 ;; Now that we have scrolled WINDOW properly,
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
182 ;; put point back where it was for the redisplay
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
183 ;; so that we don't mess up the selected window.
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
184 (or (eq window (selected-window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
185 (goto-char opoint))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
186 (sit-for mouse-scroll-delay)))))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
187 (or (eq window (selected-window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
188 (goto-char opoint))))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
189
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
190 (defvar mouse-drag-overlay (make-overlay 1 1))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
191 (overlay-put mouse-drag-overlay 'face 'region)
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
192
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
193 (defvar mouse-selection-click-count 0)
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
194
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
195 (defun mouse-drag-region (start-event)
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
196 "Set the region to the text that the mouse is dragged over.
4532
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
197 Highlight the drag area as you move the mouse.
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
198 This must be bound to a button-down mouse event.
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
199 In Transient Mark mode, the highlighting remains once you
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
200 release the mouse button. Otherwise, it does not."
3566
dc2b64ef30dc (mouse-drag-region-1): Un-comment-out this function.
Richard M. Stallman <rms@gnu.org>
parents: 3420
diff changeset
201 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
202 (mouse-minibuffer-check start-event)
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
203 (let* ((start-posn (event-start start-event))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
204 (start-point (posn-point start-posn))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
205 (start-window (posn-window start-posn))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
206 (start-frame (window-frame start-window))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
207 (bounds (window-edges start-window))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
208 (top (nth 1 bounds))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
209 (bottom (if (window-minibuffer-p start-window)
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
210 (nth 3 bounds)
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
211 ;; Don't count the mode line.
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
212 (1- (nth 3 bounds))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
213 (click-count (1- (event-click-count start-event))))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
214 (setq mouse-selection-click-count click-count)
4490
8362b57424dc (mouse-set-point): Error if click in inactive minibuffer.
Richard M. Stallman <rms@gnu.org>
parents: 4472
diff changeset
215 (mouse-set-point start-event)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
216 (let ((range (mouse-start-end start-point start-point click-count)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
217 (move-overlay mouse-drag-overlay (car range) (nth 1 range)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
218 (window-buffer start-window)))
4200
3f5f55401364 (mouse-drag-region): Use deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents: 4081
diff changeset
219 (deactivate-mark)
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
220 (let (event end end-point)
3566
dc2b64ef30dc (mouse-drag-region-1): Un-comment-out this function.
Richard M. Stallman <rms@gnu.org>
parents: 3420
diff changeset
221 (track-mouse
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
222 (while (progn
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
223 (setq event (read-event))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
224 (or (mouse-movement-p event)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
225 (eq (car-safe event) 'switch-frame)))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
226 (if (eq (car-safe event) 'switch-frame)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
227 nil
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
228 (setq end (event-end event)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
229 end-point (posn-point end))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
230
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
231 (cond
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
232
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
233 ;; Ignore switch-frame events.
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
234 ((eq (car-safe event) 'switch-frame))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
235
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
236 ;; Are we moving within the original window?
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
237 ((and (eq (posn-window end) start-window)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
238 (integer-or-marker-p end-point))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
239 (goto-char end-point)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
240 (let ((range (mouse-start-end start-point (point) click-count)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
241 (move-overlay mouse-drag-overlay (car range) (nth 1 range))))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
242
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
243 (t
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
244 (let ((mouse-row (cdr (cdr (mouse-position)))))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
245 (cond
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
246 ((null mouse-row))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
247 ((< mouse-row top)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
248 (mouse-scroll-subr start-window (- mouse-row top)
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
249 mouse-drag-overlay start-point))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
250 ((>= mouse-row bottom)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
251 (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
252 mouse-drag-overlay start-point)))))))))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
253 (if (consp event)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
254 ;;; When we scroll into the mode line or menu bar, or out of the window,
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
255 ;;; we get events that don't fit these criteria.
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
256 ;;; (eq (get (event-basic-type event) 'event-kind) 'mouse-click)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
257 ;;; (eq (posn-window (event-end event)) start-window)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
258 ;;; (numberp (posn-point (event-end event)))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
259 (let ((fun (key-binding (vector (car event)))))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
260 (if (not (= (overlay-start mouse-drag-overlay)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
261 (overlay-end mouse-drag-overlay)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
262 (let (last-command)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
263 (push-mark (overlay-start mouse-drag-overlay) t t)
4906
e3f09fe7f08f (mouse-drag-region): Set this-command to mouse-set-point
Richard M. Stallman <rms@gnu.org>
parents: 4788
diff changeset
264 (goto-char (overlay-end mouse-drag-overlay))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
265 (copy-region-as-kill (point) (mark t)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
266 (goto-char (overlay-end mouse-drag-overlay))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
267 (setq this-command 'mouse-set-point))))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
268 (delete-overlay mouse-drag-overlay))))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
269
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
270 ;; Commands to handle xterm-style multiple clicks.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
271
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
272 (defun mouse-skip-word (dir)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
273 "Skip over word, over whitespace, or over identical punctuation.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
274 If DIR is positive skip forward; if negative, skip backward."
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
275 (let* ((char (following-char))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
276 (syntax (char-to-string (char-syntax char))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
277 (if (or (string= syntax "w") (string= syntax " "))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
278 (if (< dir 0)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
279 (skip-syntax-backward syntax)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
280 (skip-syntax-forward syntax))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
281 (if (< dir 0)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
282 (while (and (not (bobp)) (= (preceding-char) char))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
283 (forward-char -1))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
284 (while (and (not (eobp)) (= (following-char) char))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
285 (forward-char 1))))))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
286
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
287 ;; Return a list of region bounds based on START and END according to MODE.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
288 ;; If MODE is 0 then set point to (min START END), mark to (max START END).
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
289 ;; If MODE is 1 then set point to start of word at (min START END),
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
290 ;; mark to end of word at (max START END).
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
291 ;; If MODE is 2 then do the same for lines.
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
292 (defun mouse-start-end (start end mode)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
293 (if (> start end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
294 (let ((temp start))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
295 (setq start end
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
296 end temp)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
297 (setq mode (mod mode 3))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
298 (cond ((= mode 0)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
299 (list start end))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
300 ((and (= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
301 (= start end)
5869
91dcabd87088 (mouse-start-end): Check START rather than point for being at eob.
Karl Heuer <kwzh@gnu.org>
parents: 5799
diff changeset
302 (char-after start)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
303 (= (char-syntax (char-after start)) ?\())
5879
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
304 (list start
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
305 (save-excursion
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
306 (goto-char start)
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
307 (forward-sexp 1)
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
308 (point))))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
309 ((and (= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
310 (= start end)
5869
91dcabd87088 (mouse-start-end): Check START rather than point for being at eob.
Karl Heuer <kwzh@gnu.org>
parents: 5799
diff changeset
311 (char-after start)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
312 (= (char-syntax (char-after start)) ?\)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
313 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
314 (goto-char (1+ start))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
315 (backward-sexp 1)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
316 (point))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
317 (1+ start)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
318 ((= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
319 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
320 (goto-char start)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
321 (mouse-skip-word -1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
322 (point))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
323 (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
324 (goto-char end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
325 (mouse-skip-word 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
326 (point))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
327 ((= mode 2)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
328 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
329 (goto-char start)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
330 (beginning-of-line 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
331 (point))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
332 (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
333 (goto-char end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
334 (forward-line 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
335 (point))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
336
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
337 ;; Subroutine: set the mark where CLICK happened,
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
338 ;; but don't do anything else.
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
339 (defun mouse-set-mark-fast (click)
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
340 (mouse-minibuffer-check click)
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
341 (let ((posn (event-start click)))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
342 (select-window (posn-window posn))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
343 (if (numberp (posn-point posn))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
344 (push-mark (posn-point posn) t t))))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
345
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
346 ;; Momentarily show where the mark is, if highlighting doesn't show it.
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
347 (defun mouse-show-mark ()
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
348 (or transient-mark-mode
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
349 (save-excursion
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
350 (goto-char (mark t))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
351 (sit-for 1))))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
352
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
353 (defun mouse-set-mark (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
354 "Set mark at the position clicked on with the mouse.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
355 Display cursor at that position for a second.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
356 This must be bound to a mouse click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
357 (interactive "e")
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (let ((point-save (point)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (unwind-protect
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
360 (progn (mouse-set-point click)
3119
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
361 (push-mark nil t t)
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
362 (or transient-mark-mode
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
363 (sit-for 1)))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (goto-char point-save))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
366 (defun mouse-kill (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
367 "Kill the region between point and the mouse click.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
368 The text is saved in the kill ring, as with \\[kill-region]."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
369 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
370 (mouse-minibuffer-check click)
6301
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
371 (let* ((posn (event-start click))
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
372 (click-posn (posn-point posn)))
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
373 (select-window (posn-window posn))
1039
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
374 (if (numberp click-posn)
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
375 (kill-region (min (point) click-posn)
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
376 (max (point) click-posn)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
378 (defun mouse-yank-at-click (click arg)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
379 "Insert the last stretch of killed text at the position clicked on.
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
380 Also move point to one end of the text thus inserted (normally the end).
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
381 Prefix arguments are interpreted as with \\[yank].
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
382 If `mouse-yank-at-point' is non-nil, insert at point
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
383 regardless of where you click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
384 (interactive "e\nP")
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
385 (or mouse-yank-at-point (mouse-set-point click))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
386 (setq this-command 'yank)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
387 (yank arg))
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
388
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
389 (defun mouse-kill-ring-save (click)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
390 "Copy the region between point and the mouse click in the kill ring.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
391 This does not delete the region; it acts like \\[kill-ring-save]."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
392 (interactive "e")
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
393 (mouse-set-mark-fast click)
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
394 (kill-ring-save (point) (mark t))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
395 (mouse-show-mark))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
397 ;;; This function used to delete the text between point and the mouse
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
398 ;;; whenever it was equal to the front of the kill ring, but some
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
399 ;;; people found that confusing.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
400
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
401 ;;; A list (TEXT START END), describing the text and position of the last
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
402 ;;; invocation of mouse-save-then-kill.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
403 (defvar mouse-save-then-kill-posn nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
404
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
405 (defun mouse-save-then-kill-delete-region (beg end)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
406 ;; We must make our own undo boundaries
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
407 ;; because they happen automatically only for the current buffer.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
408 (undo-boundary)
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
409 (if (or (= beg end) (eq buffer-undo-list t))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
410 ;; If we have no undo list in this buffer,
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
411 ;; just delete.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
412 (delete-region beg end)
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
413 ;; Delete, but make the undo-list entry share with the kill ring.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
414 ;; First, delete just one char, so in case buffer is being modified
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
415 ;; for the first time, the undo list records that fact.
7866
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
416 (let (before-change-function after-change-function
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
417 before-change-functions after-change-functions)
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
418 (delete-region beg
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
419 (+ beg (if (> end beg) 1 -1))))
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
420 (let ((buffer-undo-list buffer-undo-list))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
421 ;; Undo that deletion--but don't change the undo list!
7866
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
422 (let (before-change-function after-change-function
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
423 before-change-functions after-change-functions)
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
424 (primitive-undo 1 buffer-undo-list))
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
425 ;; Now delete the rest of the specified region,
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
426 ;; but don't record it.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
427 (setq buffer-undo-list t)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
428 (if (/= (length (car kill-ring)) (- (max end beg) (min end beg)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
429 (error "Lossage in mouse-save-then-kill-delete-region"))
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
430 (delete-region beg end))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
431 (let ((tail buffer-undo-list))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
432 ;; Search back in buffer-undo-list for the string
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
433 ;; that came from deleting one character.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
434 (while (and tail (not (stringp (car (car tail)))))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
435 (setq tail (cdr tail)))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
436 ;; Replace it with an entry for the entire deleted text.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
437 (and tail
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
438 (setcar tail (cons (car kill-ring) (min beg end))))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
439 (undo-boundary))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
440
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
441 (defun mouse-save-then-kill (click)
1765
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
442 "Save text to point in kill ring; the second time, kill the text.
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
443 If the text between point and the mouse is the same as what's
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
444 at the front of the kill ring, this deletes the text.
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
445 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
446 which prepares for a second click to delete the text.
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
447
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
448 If you have selected words or lines, this command extends the
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
449 selection through the word or line clicked on. If you do this
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
450 again in a different position, it extends the selection again.
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
451 If you do this twice in the same position, the selection is killed."
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
452 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
453 (mouse-minibuffer-check click)
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
454 (let ((click-posn (posn-point (event-start click)))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
455 ;; Don't let a subsequent kill command append to this one:
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
456 ;; prevent setting this-command to kill-region.
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
457 (this-command this-command))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
458 (if (> (mod mouse-selection-click-count 3) 0)
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
459 (if (not (and (eq last-command 'mouse-save-then-kill)
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
460 (equal click-posn
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
461 (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
462 ;; Find both ends of the object selected by this click.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
463 (let* ((range
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
464 (mouse-start-end click-posn click-posn
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
465 mouse-selection-click-count)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
466 ;; Move whichever end is closer to the click.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
467 ;; That's what xterm does, and it seems reasonable.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
468 (if (< (abs (- click-posn (mark t)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
469 (abs (- click-posn (point))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
470 (set-mark (car range))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
471 (goto-char (nth 1 range)))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
472 ;; We have already put the old region in the kill ring.
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
473 ;; Replace it with the extended region.
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
474 ;; (It would be annoying to make a separate entry.)
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
475 (setcar kill-ring (buffer-substring (point) (mark t)))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
476 (if interprogram-cut-function
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
477 (funcall interprogram-cut-function (car kill-ring)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
478 ;; Arrange for a repeated mouse-3 to kill this region.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
479 (setq mouse-save-then-kill-posn
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
480 (list (car kill-ring) (point) click-posn))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
481 (mouse-show-mark))
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
482 ;; If we click this button again without moving it,
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
483 ;; that time kill.
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
484 (mouse-save-then-kill-delete-region (point) (mark))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
485 (setq mouse-selection-click-count 0)
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
486 (setq mouse-save-then-kill-posn nil))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
487 (if (and (eq last-command 'mouse-save-then-kill)
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
488 mouse-save-then-kill-posn
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
489 (eq (car mouse-save-then-kill-posn) (car kill-ring))
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
490 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
491 ;; If this is the second time we've called
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
492 ;; mouse-save-then-kill, delete the text from the buffer.
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
493 (progn
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
494 (mouse-save-then-kill-delete-region (point) (mark))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
495 ;; After we kill, another click counts as "the first time".
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
496 (setq mouse-save-then-kill-posn nil))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
497 (if (or (and (eq last-command 'mouse-save-then-kill)
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
498 mouse-save-then-kill-posn)
4906
e3f09fe7f08f (mouse-drag-region): Set this-command to mouse-set-point
Richard M. Stallman <rms@gnu.org>
parents: 4788
diff changeset
499 (and mark-active transient-mark-mode)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
500 (and (eq last-command 'mouse-drag-region)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
501 (or mark-even-if-inactive
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
502 (not transient-mark-mode))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
503 ;; We have a selection or suitable region, so adjust it.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
504 (let* ((posn (event-start click))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
505 (new (posn-point posn)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
506 (select-window (posn-window posn))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
507 (if (numberp new)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
508 (progn
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
509 ;; Move whichever end of the region is closer to the click.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
510 ;; That is what xterm does, and it seems reasonable.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
511 (if (< (abs (- new (point))) (abs (- new (mark t))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
512 (goto-char new)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
513 (set-mark new))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
514 (setq deactivate-mark nil)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
515 (setcar kill-ring (buffer-substring (point) (mark t)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
516 (if interprogram-cut-function
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
517 (funcall interprogram-cut-function (car kill-ring))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
518 ;; We just have point, so set mark here.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
519 (mouse-set-mark-fast click)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
520 (kill-ring-save (point) (mark t))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
521 (mouse-show-mark))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
522 (setq mouse-save-then-kill-posn
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
523 (list (car kill-ring) (point) click-posn))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
524
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
525 (global-set-key [M-mouse-1] 'mouse-start-secondary)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
526 (global-set-key [M-drag-mouse-1] 'mouse-set-secondary)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
527 (global-set-key [M-down-mouse-1] 'mouse-drag-secondary)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
528 (global-set-key [M-mouse-3] 'mouse-secondary-save-then-kill)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
529 (global-set-key [M-mouse-2] 'mouse-yank-secondary)
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
530
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
531 ;; An overlay which records the current secondary selection
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
532 ;; or else is deleted when there is no secondary selection.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
533 ;; May be nil.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
534 (defvar mouse-secondary-overlay nil)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
535
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
536 ;; A marker which records the specified first end for a secondary selection.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
537 ;; May be nil.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
538 (defvar mouse-secondary-start nil)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
539
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
540 (defun mouse-start-secondary (click)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
541 "Set one end of the secondary selection to the position clicked on.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
542 Use \\[mouse-secondary-save-then-kill] to set the other end
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
543 and complete the secondary selection."
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
544 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
545 (mouse-minibuffer-check click)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
546 (let ((posn (event-start click)))
3823
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
547 (save-excursion
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
548 (set-buffer (window-buffer (posn-window posn)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
549 ;; Cancel any preexisting secondary selection.
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
550 (if mouse-secondary-overlay
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
551 (delete-overlay mouse-secondary-overlay))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
552 (if (numberp (posn-point posn))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
553 (progn
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
554 (or mouse-secondary-start
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
555 (setq mouse-secondary-start (make-marker)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
556 (move-marker mouse-secondary-start (posn-point posn)))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
557
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
558 (defun mouse-set-secondary (click)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
559 "Set the secondary selection to the text that the mouse is dragged over.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
560 This must be bound to a mouse drag event."
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
561 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
562 (mouse-minibuffer-check click)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
563 (let ((posn (event-start click))
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
564 beg
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
565 (end (event-end click)))
3823
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
566 (save-excursion
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
567 (set-buffer (window-buffer (posn-window posn)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
568 (if (numberp (posn-point posn))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
569 (setq beg (posn-point posn)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
570 (if mouse-secondary-overlay
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
571 (move-overlay mouse-secondary-overlay beg (posn-point end))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
572 (setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
573 (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
574
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
575 (defun mouse-drag-secondary (start-event)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
576 "Set the secondary selection to the text that the mouse is dragged over.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
577 Highlight the drag area as you move the mouse.
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
578 This must be bound to a button-down mouse event."
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
579 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
580 (mouse-minibuffer-check start-event)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
581 (let* ((start-posn (event-start start-event))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
582 (start-point (posn-point start-posn))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
583 (start-window (posn-window start-posn))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
584 (start-frame (window-frame start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
585 (bounds (window-edges start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
586 (top (nth 1 bounds))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
587 (bottom (if (window-minibuffer-p start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
588 (nth 3 bounds)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
589 ;; Don't count the mode line.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
590 (1- (nth 3 bounds))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
591 (click-count (1- (event-click-count start-event))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
592 (save-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
593 (set-buffer (window-buffer start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
594 (setq mouse-selection-click-count click-count)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
595 (or mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
596 (setq mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
597 (make-overlay (point) (point))))
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
598 (overlay-put mouse-secondary-overlay 'face 'secondary-selection)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
599 (if (> (mod click-count 3) 0)
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
600 ;; Double or triple press: make an initial selection
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
601 ;; of one word or line.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
602 (let ((range (mouse-start-end start-point start-point click-count)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
603 (set-marker mouse-secondary-start nil)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
604 (move-overlay mouse-secondary-overlay 1 1
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
605 (window-buffer start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
606 (move-overlay mouse-secondary-overlay (car range) (nth 1 range)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
607 (window-buffer start-window)))
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
608 ;; Single-press: cancel any preexisting secondary selection.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
609 (or mouse-secondary-start
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
610 (setq mouse-secondary-start (make-marker)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
611 (set-marker mouse-secondary-start start-point)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
612 (delete-overlay mouse-secondary-overlay))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
613 (let (event end end-point)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
614 (track-mouse
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
615 (while (progn
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
616 (setq event (read-event))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
617 (or (mouse-movement-p event)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
618 (eq (car-safe event) 'switch-frame)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
619
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
620 (if (eq (car-safe event) 'switch-frame)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
621 nil
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
622 (setq end (event-end event)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
623 end-point (posn-point end))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
624 (cond
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
625
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
626 ;; Ignore switch-frame events.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
627 ((eq (car-safe event) 'switch-frame))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
628
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
629 ;; Are we moving within the original window?
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
630 ((and (eq (posn-window end) start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
631 (integer-or-marker-p end-point))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
632 (if (/= start-point end-point)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
633 (set-marker mouse-secondary-start nil))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
634 (let ((range (mouse-start-end start-point end-point
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
635 click-count)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
636 (move-overlay mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
637 (car range) (nth 1 range))))
7588
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
638 (t
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
639 (let ((mouse-row (cdr (cdr (mouse-position)))))
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
640 (cond
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
641 ((null mouse-row))
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
642 ((< mouse-row top)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
643 (mouse-scroll-subr start-window (- mouse-row top)
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
644 mouse-secondary-overlay start-point))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
645 ((>= mouse-row bottom)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
646 (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
7588
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
647 mouse-secondary-overlay start-point)))))))))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
648
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
649 (if (consp event)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
650 ;;; (eq (get (event-basic-type event) 'event-kind) 'mouse-click)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
651 ;;; (eq (posn-window (event-end event)) start-window)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
652 ;;; (numberp (posn-point (event-end event)))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
653 (if (marker-position mouse-secondary-start)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
654 (save-window-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
655 (delete-overlay mouse-secondary-overlay)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
656 (x-set-selection 'SECONDARY nil)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
657 (select-window start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
658 (save-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
659 (goto-char mouse-secondary-start)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
660 (sit-for 1)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
661 (x-set-selection
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
662 'SECONDARY
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
663 (buffer-substring (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
664 (overlay-end mouse-secondary-overlay)))))))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
665
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
666 (defun mouse-yank-secondary (click)
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
667 "Insert the secondary selection at the position clicked on.
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
668 Move point to the end of the inserted text.
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
669 If `mouse-yank-at-point' is non-nil, insert at point
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
670 regardless of where you click."
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
671 (interactive "e")
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
672 (or mouse-yank-at-point (mouse-set-point click))
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
673 (insert (x-get-selection 'SECONDARY)))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
674
5280
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
675 (defun mouse-kill-secondary ()
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
676 "Kill the text in the secondary selection.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
677 This is intended more as a keyboard command than as a mouse command
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
678 but it can work as either one.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
679
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
680 The current buffer (in case of keyboard use), or the buffer clicked on,
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
681 must be the one that the secondary selection is in. This requirement
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
682 is to prevent accidents."
5280
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
683 (interactive)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
684 (let* ((keys (this-command-keys))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
685 (click (elt keys (1- (length keys)))))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
686 (or (eq (overlay-buffer mouse-secondary-overlay)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
687 (if (listp click)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
688 (window-buffer (posn-window (event-start click)))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
689 (current-buffer)))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
690 (error "Select or click on the buffer where the secondary selection is")))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
691 (save-excursion
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
692 (set-buffer (overlay-buffer mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
693 (kill-region (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
694 (overlay-end mouse-secondary-overlay)))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
695 (delete-overlay mouse-secondary-overlay)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
696 (x-set-selection 'SECONDARY nil)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
697 (setq mouse-secondary-overlay nil))
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
698
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
699 (defun mouse-secondary-save-then-kill (click)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
700 "Save text to point in kill ring; the second time, kill the text.
7302
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
701 You must use this in a buffer where you have recently done \\[mouse-start-secondary].
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
702 If the text between where you did \\[mouse-start-secondary] and where
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
703 you use this command matches the text at the front of the kill ring,
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
704 this command deletes the text.
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
705 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
7302
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
706 which prepares for a second click with this command to delete the text.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
707
7302
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
708 If you have already made a secondary selection in that buffer,
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
709 this command extends or retracts the selection to where you click.
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
710 If you do this again in a different position, it extends or retracts
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
711 again. If you do this twice in the same position, it kills the selection."
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
712 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
713 (mouse-minibuffer-check click)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
714 (let ((posn (event-start click))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
715 (click-posn (posn-point (event-start click)))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
716 ;; Don't let a subsequent kill command append to this one:
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
717 ;; prevent setting this-command to kill-region.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
718 (this-command this-command))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
719 (or (eq (window-buffer (posn-window posn))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
720 (or (and mouse-secondary-overlay
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
721 (overlay-buffer mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
722 (if mouse-secondary-start
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
723 (marker-buffer mouse-secondary-start))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
724 (error "Wrong buffer"))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
725 (save-excursion
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
726 (set-buffer (window-buffer (posn-window posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
727 (if (> (mod mouse-selection-click-count 3) 0)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
728 (if (not (and (eq last-command 'mouse-secondary-save-then-kill)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
729 (equal click-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
730 (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
731 ;; Find both ends of the object selected by this click.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
732 (let* ((range
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
733 (mouse-start-end click-posn click-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
734 mouse-selection-click-count)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
735 ;; Move whichever end is closer to the click.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
736 ;; That's what xterm does, and it seems reasonable.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
737 (if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
738 (abs (- click-posn (overlay-end mouse-secondary-overlay))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
739 (move-overlay mouse-secondary-overlay (car range)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
740 (overlay-end mouse-secondary-overlay))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
741 (move-overlay mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
742 (overlay-start mouse-secondary-overlay)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
743 (nth 1 range)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
744 ;; We have already put the old region in the kill ring.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
745 ;; Replace it with the extended region.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
746 ;; (It would be annoying to make a separate entry.)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
747 (setcar kill-ring (buffer-substring
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
748 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
749 (overlay-end mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
750 (if interprogram-cut-function
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
751 (funcall interprogram-cut-function (car kill-ring)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
752 ;; Arrange for a repeated mouse-3 to kill this region.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
753 (setq mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
754 (list (car kill-ring) (point) click-posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
755 ;; If we click this button again without moving it,
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
756 ;; that time kill.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
757 (progn
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
758 (mouse-save-then-kill-delete-region
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
759 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
760 (overlay-end mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
761 (setq mouse-save-then-kill-posn nil)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
762 (setq mouse-selection-click-count 0)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
763 (delete-overlay mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
764 (if (and (eq last-command 'mouse-secondary-save-then-kill)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
765 mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
766 (eq (car mouse-save-then-kill-posn) (car kill-ring))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
767 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
768 ;; If this is the second time we've called
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
769 ;; mouse-secondary-save-then-kill, delete the text from the buffer.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
770 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
771 (mouse-save-then-kill-delete-region
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
772 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
773 (overlay-end mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
774 (setq mouse-save-then-kill-posn nil)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
775 (delete-overlay mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
776 (if (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
777 ;; We have a selection, so adjust it.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
778 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
779 (if (numberp click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
780 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
781 ;; Move whichever end of the region is closer to the click.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
782 ;; That is what xterm does, and it seems reasonable.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
783 (if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
784 (abs (- click-posn (overlay-end mouse-secondary-overlay))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
785 (move-overlay mouse-secondary-overlay click-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
786 (overlay-end mouse-secondary-overlay))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
787 (move-overlay mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
788 (overlay-start mouse-secondary-overlay)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
789 click-posn))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
790 (setq deactivate-mark nil)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
791 (setcar kill-ring (buffer-substring
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
792 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
793 (overlay-end mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
794 (if interprogram-cut-function
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
795 (funcall interprogram-cut-function (car kill-ring))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
796 (if mouse-secondary-start
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
797 ;; All we have is one end of a selection,
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
798 ;; so put the other end here.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
799 (let ((start (+ 0 mouse-secondary-start)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
800 (kill-ring-save start click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
801 (if mouse-secondary-overlay
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
802 (move-overlay mouse-secondary-overlay start click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
803 (setq mouse-secondary-overlay (make-overlay start click-posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
804 (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
805 (setq mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
806 (list (car kill-ring) (point) click-posn))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
807 (x-set-selection 'SECONDARY
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
808 (if (overlay-buffer mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
809 (buffer-substring
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
810 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
811 (overlay-end mouse-secondary-overlay)))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
812
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
813 (defun mouse-buffer-menu (event)
1728
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
814 "Pop up a menu of buffers for selection with the mouse.
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
815 This switches buffers in the window that you clicked on,
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
816 and selects that window."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
817 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
818 (mouse-minibuffer-check event)
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
819 (let ((menu
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
820 (list "Buffer Menu"
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
821 (cons "Select Buffer"
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
822 (let ((tail (buffer-list))
3899
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
823 (maxbuf 0)
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
824 head)
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
825 (while tail
3899
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
826 (or (eq ?\ (aref (buffer-name (car tail)) 0))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
827 (setq maxbuf
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
828 (max maxbuf
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
829 (length (buffer-name (car tail))))))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
830 (setq tail (cdr tail)))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
831 (setq tail (buffer-list))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
832 (while tail
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
833 (let ((elt (car tail)))
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
834 (if (not (string-match "^ "
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
835 (buffer-name elt)))
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
836 (setq head (cons
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
837 (cons
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
838 (format
3899
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
839 (format "%%%ds %%s%%s %%s"
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
840 maxbuf)
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
841 (buffer-name elt)
3899
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
842 (if (buffer-modified-p elt)
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
843 "*" " ")
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
844 (save-excursion
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
845 (set-buffer elt)
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
846 (if buffer-read-only "%" " "))
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
847 (or (buffer-file-name elt) ""))
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
848 elt)
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
849 head))))
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
850 (setq tail (cdr tail)))
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
851 (reverse head))))))
1728
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
852 (let ((buf (x-popup-menu event menu))
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
853 (window (posn-window (event-start event))))
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
854 (if buf
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
855 (progn
3420
08adfe96ca93 (mouse-buffer-menu): Don't select the event's window,
Richard M. Stallman <rms@gnu.org>
parents: 3231
diff changeset
856 (or (framep window) (select-window window))
1728
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
857 (switch-to-buffer buf))))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
859 ;;; These need to be rewritten for the new scroll bar implementation.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
861 ;;;!! ;; Commands for the scroll bar.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
862 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
863 ;;;!! (defun mouse-scroll-down (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
864 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
865 ;;;!! (scroll-down (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
866 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
867 ;;;!! (defun mouse-scroll-up (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
868 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
869 ;;;!! (scroll-up (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
870 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
871 ;;;!! (defun mouse-scroll-down-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
872 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
873 ;;;!! (scroll-down nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
874 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
875 ;;;!! (defun mouse-scroll-up-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
876 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
877 ;;;!! (scroll-up nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
878 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
879 ;;;!! (defun mouse-scroll-move-cursor (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
880 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
881 ;;;!! (move-to-window-line (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
882 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
883 ;;;!! (defun mouse-scroll-absolute (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
884 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
885 ;;;!! (let* ((pos (car event))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
886 ;;;!! (position (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
887 ;;;!! (length (car (cdr pos))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
888 ;;;!! (if (<= length 0) (setq length 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
889 ;;;!! (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
890 ;;;!! (newpos (* (/ (* (/ (buffer-size) scale-factor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
891 ;;;!! position)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
892 ;;;!! length)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
893 ;;;!! scale-factor)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
894 ;;;!! (goto-char newpos)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
895 ;;;!! (recenter '(4)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
896 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
897 ;;;!! (defun mouse-scroll-left (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
898 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
899 ;;;!! (scroll-left (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
900 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
901 ;;;!! (defun mouse-scroll-right (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
902 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
903 ;;;!! (scroll-right (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
904 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
905 ;;;!! (defun mouse-scroll-left-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
906 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
907 ;;;!! (scroll-left nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
908 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
909 ;;;!! (defun mouse-scroll-right-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
910 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
911 ;;;!! (scroll-right nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
912 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
913 ;;;!! (defun mouse-scroll-move-cursor-horizontally (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
914 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
915 ;;;!! (move-to-column (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
916 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
917 ;;;!! (defun mouse-scroll-absolute-horizontally (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
918 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
919 ;;;!! (let* ((pos (car event))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
920 ;;;!! (position (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
921 ;;;!! (length (car (cdr pos))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
922 ;;;!! (set-window-hscroll (selected-window) 33)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
923 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
924 ;;;!! (global-set-key [scroll-bar mouse-1] 'mouse-scroll-up)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
925 ;;;!! (global-set-key [scroll-bar mouse-2] 'mouse-scroll-absolute)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
926 ;;;!! (global-set-key [scroll-bar mouse-3] 'mouse-scroll-down)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
927 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
928 ;;;!! (global-set-key [vertical-slider mouse-1] 'mouse-scroll-move-cursor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
929 ;;;!! (global-set-key [vertical-slider mouse-2] 'mouse-scroll-move-cursor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
930 ;;;!! (global-set-key [vertical-slider mouse-3] 'mouse-scroll-move-cursor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
931 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
932 ;;;!! (global-set-key [thumbup mouse-1] 'mouse-scroll-up-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
933 ;;;!! (global-set-key [thumbup mouse-2] 'mouse-scroll-up-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
934 ;;;!! (global-set-key [thumbup mouse-3] 'mouse-scroll-up-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
935 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
936 ;;;!! (global-set-key [thumbdown mouse-1] 'mouse-scroll-down-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
937 ;;;!! (global-set-key [thumbdown mouse-2] 'mouse-scroll-down-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
938 ;;;!! (global-set-key [thumbdown mouse-3] 'mouse-scroll-down-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
939 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
940 ;;;!! (global-set-key [horizontal-scroll-bar mouse-1] 'mouse-scroll-left)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
941 ;;;!! (global-set-key [horizontal-scroll-bar mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
942 ;;;!! 'mouse-scroll-absolute-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
943 ;;;!! (global-set-key [horizontal-scroll-bar mouse-3] 'mouse-scroll-right)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
944 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
945 ;;;!! (global-set-key [horizontal-slider mouse-1]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
946 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
947 ;;;!! (global-set-key [horizontal-slider mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
948 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
949 ;;;!! (global-set-key [horizontal-slider mouse-3]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
950 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
951 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
952 ;;;!! (global-set-key [thumbleft mouse-1] 'mouse-scroll-left-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
953 ;;;!! (global-set-key [thumbleft mouse-2] 'mouse-scroll-left-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
954 ;;;!! (global-set-key [thumbleft mouse-3] 'mouse-scroll-left-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
955 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
956 ;;;!! (global-set-key [thumbright mouse-1] 'mouse-scroll-right-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
957 ;;;!! (global-set-key [thumbright mouse-2] 'mouse-scroll-right-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
958 ;;;!! (global-set-key [thumbright mouse-3] 'mouse-scroll-right-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
959 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
960 ;;;!! (global-set-key [horizontal-scroll-bar S-mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
961 ;;;!! 'mouse-split-window-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
962 ;;;!! (global-set-key [mode-line S-mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
963 ;;;!! 'mouse-split-window-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
964 ;;;!! (global-set-key [vertical-scroll-bar S-mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
965 ;;;!! 'mouse-split-window)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
966
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
967 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
968 ;;;!! ;;;; Here are experimental things being tested. Mouse events
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
969 ;;;!! ;;;; are of the form:
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
970 ;;;!! ;;;; ((x y) window screen-part key-sequence timestamp)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
971 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
972 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
973 ;;;!! ;;;; Dynamically track mouse coordinates
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
974 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
975 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
976 ;;;!! ;;(defun track-mouse (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
977 ;;;!! ;; "Track the coordinates, absolute and relative, of the mouse."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
978 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
979 ;;;!! ;; (while mouse-grabbed
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
980 ;;;!! ;; (let* ((pos (read-mouse-position (selected-screen)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
981 ;;;!! ;; (abs-x (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
982 ;;;!! ;; (abs-y (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
983 ;;;!! ;; (relative-coordinate (coordinates-in-window-p
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
984 ;;;!! ;; (list (car pos) (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
985 ;;;!! ;; (selected-window))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
986 ;;;!! ;; (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
987 ;;;!! ;; (message "mouse: [%d %d], (%d %d)" abs-x abs-y
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
988 ;;;!! ;; (car relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
989 ;;;!! ;; (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
990 ;;;!! ;; (message "mouse: [%d %d]" abs-x abs-y)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
991 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
992 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
993 ;;;!! ;; Dynamically put a box around the line indicated by point
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
994 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
995 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
996 ;;;!! ;;(require 'backquote)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
997 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
998 ;;;!! ;;(defun mouse-select-buffer-line (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
999 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1000 ;;;!! ;; (let ((relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1001 ;;;!! ;; (coordinates-in-window-p (car event) (selected-window)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1002 ;;;!! ;; (abs-y (car (cdr (car event)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1003 ;;;!! ;; (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1004 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1005 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1006 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1007 ;;;!! ;; (x-draw-rectangle
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1008 ;;;!! ;; (selected-screen)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1009 ;;;!! ;; abs-y 0
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1010 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1011 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1012 ;;;!! ;; (end-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1013 ;;;!! ;; (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1014 ;;;!! ;; (beginning-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1015 ;;;!! ;; (- (region-end) (region-beginning))) 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1016 ;;;!! ;; (sit-for 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1017 ;;;!! ;; (x-erase-rectangle (selected-screen))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1018 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1019 ;;;!! ;;(defvar last-line-drawn nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1020 ;;;!! ;;(defvar begin-delim "[^ \t]")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1021 ;;;!! ;;(defvar end-delim "[^ \t]")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1022 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1023 ;;;!! ;;(defun mouse-boxing (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1024 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1025 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1026 ;;;!! ;; (let ((screen (selected-screen)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1027 ;;;!! ;; (while (= (x-mouse-events) 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1028 ;;;!! ;; (let* ((pos (read-mouse-position screen))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1029 ;;;!! ;; (abs-x (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1030 ;;;!! ;; (abs-y (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1031 ;;;!! ;; (relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1032 ;;;!! ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1033 ;;;!! ;; (selected-window)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1034 ;;;!! ;; (begin-reg nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1035 ;;;!! ;; (end-reg nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1036 ;;;!! ;; (end-column nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1037 ;;;!! ;; (begin-column nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1038 ;;;!! ;; (if (and (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1039 ;;;!! ;; (or (not last-line-drawn)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1040 ;;;!! ;; (not (= last-line-drawn abs-y))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1041 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1042 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1043 ;;;!! ;; (if (= (following-char) 10)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1044 ;;;!! ;; ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1045 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1046 ;;;!! ;; (setq begin-reg (1- (re-search-forward end-delim)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1047 ;;;!! ;; (setq begin-column (1- (current-column)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1048 ;;;!! ;; (end-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1049 ;;;!! ;; (setq end-reg (1+ (re-search-backward begin-delim)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1050 ;;;!! ;; (setq end-column (1+ (current-column)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1051 ;;;!! ;; (message "%s" (buffer-substring begin-reg end-reg))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1052 ;;;!! ;; (x-draw-rectangle screen
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1053 ;;;!! ;; (setq last-line-drawn abs-y)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1054 ;;;!! ;; begin-column
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1055 ;;;!! ;; (- end-column begin-column) 1))))))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1056 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1057 ;;;!! ;;(defun mouse-erase-box ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1058 ;;;!! ;; (interactive)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1059 ;;;!! ;; (if last-line-drawn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1060 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1061 ;;;!! ;; (x-erase-rectangle (selected-screen))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1062 ;;;!! ;; (setq last-line-drawn nil))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1063 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1064 ;;;!! ;;; (defun test-x-rectangle ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1065 ;;;!! ;;; (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1066 ;;;!! ;;; (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1067 ;;;!! ;;; (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1068 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1069 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1070 ;;;!! ;; Here is how to do double clicking in lisp. About to change.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1071 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1072 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1073 ;;;!! (defvar double-start nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1074 ;;;!! (defconst double-click-interval 300
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1075 ;;;!! "Max ticks between clicks")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1076 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1077 ;;;!! (defun double-down (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1078 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1079 ;;;!! (if double-start
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1080 ;;;!! (let ((interval (- (nth 4 event) double-start)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1081 ;;;!! (if (< interval double-click-interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1082 ;;;!! (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1083 ;;;!! (backward-up-list 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1084 ;;;!! ;; (message "Interval %d" interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1085 ;;;!! (sleep-for 1)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1086 ;;;!! (setq double-start nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1087 ;;;!! (setq double-start (nth 4 event))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1088 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1089 ;;;!! (defun double-up (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1090 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1091 ;;;!! (and double-start
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1092 ;;;!! (> (- (nth 4 event ) double-start) double-click-interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1093 ;;;!! (setq double-start nil)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1094 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1095 ;;;!! ;;; (defun x-test-doubleclick ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1096 ;;;!! ;;; (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1097 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left 'double-down)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1098 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left-up 'double-up))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1099 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1100 ;;;!! ;;
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1101 ;;;!! ;; This scrolls while button is depressed. Use preferable in scroll bar.
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1102 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1103 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1104 ;;;!! (defvar scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1105 ;;;!! (defconst scroll-speed 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1106 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1107 ;;;!! (defun incr-scroll-down (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1108 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1109 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1110 ;;;!! (incremental-scroll scroll-speed))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1111 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1112 ;;;!! (defun incr-scroll-up (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1113 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1114 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1115 ;;;!! (incremental-scroll (- scroll-speed)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1116 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1117 ;;;!! (defun incremental-scroll (n)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1118 ;;;!! (while (= (x-mouse-events) 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1119 ;;;!! (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1120 ;;;!! (scroll-down n)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1121 ;;;!! (sit-for 300 t)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1122 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1123 ;;;!! (defun incr-scroll-stop (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1124 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1125 ;;;!! (message "Scrolled %d lines" scrolled-lines)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1126 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1127 ;;;!! (sleep-for 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1128 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1129 ;;;!! ;;; (defun x-testing-scroll ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1130 ;;;!! ;;; (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1131 ;;;!! ;;; (define-key scrolling-map mouse-button-left 'incr-scroll-down)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1132 ;;;!! ;;; (define-key scrolling-map mouse-button-right 'incr-scroll-up)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1133 ;;;!! ;;; (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1134 ;;;!! ;;; (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1135 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1136 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1137 ;;;!! ;; Some playthings suitable for picture mode? They need work.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1138 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1139 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1140 ;;;!! (defun mouse-kill-rectangle (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1141 ;;;!! "Kill the rectangle between point and the mouse cursor."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1142 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1143 ;;;!! (let ((point-save (point)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1144 ;;;!! (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1145 ;;;!! (mouse-set-point event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1146 ;;;!! (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1147 ;;;!! (if (> point-save (point))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1148 ;;;!! (kill-rectangle (point) point-save)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1149 ;;;!! (kill-rectangle point-save (point))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1150 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1151 ;;;!! (defun mouse-open-rectangle (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1152 ;;;!! "Kill the rectangle between point and the mouse cursor."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1153 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1154 ;;;!! (let ((point-save (point)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1155 ;;;!! (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1156 ;;;!! (mouse-set-point event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1157 ;;;!! (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1158 ;;;!! (if (> point-save (point))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1159 ;;;!! (open-rectangle (point) point-save)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1160 ;;;!! (open-rectangle point-save (point))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1161 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1162 ;;;!! ;; Must be a better way to do this.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1163 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1164 ;;;!! (defun mouse-multiple-insert (n char)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1165 ;;;!! (while (> n 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1166 ;;;!! (insert char)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1167 ;;;!! (setq n (1- n))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1168 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1169 ;;;!! ;; What this could do is not finalize until button was released.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1170 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1171 ;;;!! (defun mouse-move-text (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1172 ;;;!! "Move text from point to cursor position, inserting spaces."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1173 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1174 ;;;!! (let* ((relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1175 ;;;!! (coordinates-in-window-p (car event) (selected-window))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1176 ;;;!! (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1177 ;;;!! (cond ((> (current-column) (car relative-coordinate))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1178 ;;;!! (delete-char
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1179 ;;;!! (- (car relative-coordinate) (current-column))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1180 ;;;!! ((< (current-column) (car relative-coordinate))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1181 ;;;!! (mouse-multiple-insert
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1182 ;;;!! (- (car relative-coordinate) (current-column)) " "))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1183 ;;;!! ((= (current-column) (car relative-coordinate)) (ding))))))
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1184
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1185 ;; Choose a completion with the mouse.
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1186
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1187 (defun mouse-choose-completion (event)
4371
fb0e37e7afae (mouse-choose-completion): Actually choose that alternative,
Richard M. Stallman <rms@gnu.org>
parents: 4294
diff changeset
1188 "Click on an alternative in the `*Completions*' buffer to choose it."
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1189 (interactive "e")
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1190 (let ((buffer (window-buffer))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1191 choice)
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1192 (save-excursion
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1193 (set-buffer (window-buffer (posn-window (event-start event))))
6163
f349bcb0ff59 (mouse-choose-completion): Use that as the buffer to edit.
Richard M. Stallman <rms@gnu.org>
parents: 6090
diff changeset
1194 (if completion-reference-buffer
f349bcb0ff59 (mouse-choose-completion): Use that as the buffer to edit.
Richard M. Stallman <rms@gnu.org>
parents: 6090
diff changeset
1195 (setq buffer completion-reference-buffer))
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1196 (save-excursion
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1197 (goto-char (posn-point (event-start event)))
7593
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1198 (let (beg end)
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1199 (skip-chars-forward "^ \t\n")
7593
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1200 (while (looking-at " [^ \n\t]")
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1201 (forward-char 1)
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1202 (skip-chars-forward "^ \t\n"))
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1203 (setq end (point))
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1204 (skip-chars-backward "^ \t\n")
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1205 (while (and (= (preceding-char) ?\ )
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1206 (not (and (> (point) (1+ (point-min)))
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1207 (= (char-after (- (point) 2)) ?\ ))))
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1208 (backward-char 1)
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1209 (skip-chars-backward "^ \t\n"))
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1210 (setq beg (point))
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1211 (setq choice (buffer-substring beg end)))))
6231
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1212 (let ((owindow (selected-window)))
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1213 (select-window (posn-window (event-start event)))
7794
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1214 (if (and (one-window-p t 'selected-frame)
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1215 (window-dedicated-p (selected-window)))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1216 ;; This is a special buffer's frame
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1217 (iconify-frame (selected-frame))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1218 (or (window-dedicated-p (selected-window))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1219 (bury-buffer)))
6231
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1220 (select-window owindow))
6548
2b0355912ba6 (mouse-choose-completion): Use choose-completion-string.
Richard M. Stallman <rms@gnu.org>
parents: 6301
diff changeset
1221 (choose-completion-string choice buffer)))
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1222
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1223 ;; Font selection.
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1224
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1225 (defun font-menu-add-default ()
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1226 (let* ((default (cdr (assq 'font (frame-parameters (selected-frame)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1227 (font-alist x-fixed-font-alist)
4563
b9118969ce28 (font-menu-add-default): Use list, not cons, for new elt.
Richard M. Stallman <rms@gnu.org>
parents: 4562
diff changeset
1228 (elt (or (assoc "Misc" font-alist) (nth 1 font-alist))))
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1229 (if (assoc "Default" elt)
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1230 (delete (assoc "Default" elt) elt))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1231 (setcdr elt
4562
477fbf60722b (font-menu-add-default): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 4554
diff changeset
1232 (cons (list "Default"
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1233 (cdr (assq 'font (frame-parameters (selected-frame)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1234 (cdr elt)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1235
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1236 (defvar x-fixed-font-alist
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1237 '("Font menu"
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1238 ("Misc"
6867
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1239 ("6x10" "-misc-fixed-medium-r-normal--10-100-75-75-c-60-*-1" "6x10")
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1240 ("6x12" "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-*-1" "6x12")
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1241 ("6x13" "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-1" "6x13")
4274
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1242 ("lucida 13"
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1243 "-b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-*-1")
6867
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1244 ("7x13" "-misc-fixed-medium-r-normal--13-120-75-75-c-70-*-1" "7x13")
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1245 ("7x14" "-misc-fixed-medium-r-normal--14-130-75-75-c-70-*-1" "7x14")
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1246 ("9x15" "-misc-fixed-medium-r-normal--15-140-*-*-c-*-*-1" "9x15")
4274
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1247 ("")
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1248 ("clean 8x8" "-schumacher-clean-medium-r-normal--*-80-*-*-c-*-*-1")
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1249 ("clean 8x14" "-schumacher-clean-medium-r-normal--*-140-*-*-c-*-*-1")
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1250 ("clean 8x10" "-schumacher-clean-medium-r-normal--*-100-*-*-c-*-*-1")
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1251 ("clean 8x16" "-schumacher-clean-medium-r-normal--*-160-*-*-c-*-*-1")
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1252 ("")
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1253 ("sony 8x16" "-sony-fixed-medium-r-normal--16-120-100-100-c-80-*-1")
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1254 ("")
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1255 ("fixed" "fixed")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1256 ("10x20" "10x20")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1257 ("11x18" "11x18")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1258 ("12x24" "12x24"))
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1259 ;;; We don't seem to have these; who knows what they are.
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1260 ;;; ("fg-18" "fg-18")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1261 ;;; ("fg-25" "fg-25")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1262 ;;; ("lucidasanstypewriter-12" "lucidasanstypewriter-12")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1263 ;;; ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1264 ;;; ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1265 ;;; ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1266 ;;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1267 ("Courier"
3231
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1268 ("8" "-adobe-courier-medium-r-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1269 ("10" "-adobe-courier-medium-r-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1270 ("12" "-adobe-courier-medium-r-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1271 ("14" "-adobe-courier-medium-r-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1272 ("18" "-adobe-courier-medium-r-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1273 ("24" "-adobe-courier-medium-r-normal--*-240-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1274 ("8 bold" "-adobe-courier-bold-r-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1275 ("10 bold" "-adobe-courier-bold-r-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1276 ("12 bold" "-adobe-courier-bold-r-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1277 ("14 bold" "-adobe-courier-bold-r-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1278 ("18 bold" "-adobe-courier-bold-r-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1279 ("24 bold" "-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1280 ("8 slant" "-adobe-courier-medium-o-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1281 ("10 slant" "-adobe-courier-medium-o-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1282 ("12 slant" "-adobe-courier-medium-o-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1283 ("14 slant" "-adobe-courier-medium-o-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1284 ("18 slant" "-adobe-courier-medium-o-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1285 ("24 slant" "-adobe-courier-medium-o-normal--*-240-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1286 ("8 bold slant" "-adobe-courier-bold-o-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1287 ("10 bold slant" "-adobe-courier-bold-o-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1288 ("12 bold slant" "-adobe-courier-bold-o-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1289 ("14 bold slant" "-adobe-courier-bold-o-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1290 ("18 bold slant" "-adobe-courier-bold-o-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1291 ("24 bold slant" "-adobe-courier-bold-o-normal--*-240-*-*-m-*-iso8859-1"))
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1292 )
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1293 "X fonts suitable for use in Emacs.")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1294
6867
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1295 (defun mouse-set-font (&rest fonts)
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1296 "Select an emacs font from a list of known good fonts"
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1297 (interactive
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1298 (x-popup-menu last-nonmenu-event x-fixed-font-alist))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1299 (if fonts
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1300 (let (font)
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1301 (while fonts
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1302 (condition-case nil
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1303 (progn
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1304 (set-default-font (car fonts))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1305 (setq font (car fonts))
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1306 (setq fonts nil))
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1307 (error
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1308 (setq fonts (cdr fonts)))))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1309 (if (null font)
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1310 (error "Font not found")))))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1311
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1312 ;;; Bindings for mouse commands.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1313
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
1314 (define-key global-map [down-mouse-1] 'mouse-drag-region)
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1315 (global-set-key [mouse-1] 'mouse-set-point)
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
1316 (global-set-key [drag-mouse-1] 'mouse-set-region)
1057
d9775f33488d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1056
diff changeset
1317
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1318 ;; These are tested for in mouse-drag-region.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1319 (global-set-key [double-mouse-1] 'mouse-set-point)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1320 (global-set-key [triple-mouse-1] 'mouse-set-point)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1321
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1322 (global-set-key [mouse-2] 'mouse-yank-at-click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1323 (global-set-key [mouse-3] 'mouse-save-then-kill)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
1324
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1325 ;; By binding these to down-going events, we let the user use the up-going
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1326 ;; event to make the selection, saving a click.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1327 (global-set-key [C-down-mouse-1] 'mouse-buffer-menu)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1328 (global-set-key [C-down-mouse-3] 'mouse-set-font)
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1329
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1330 ;; Replaced with dragging mouse-1
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1331 ;; (global-set-key [S-mouse-1] 'mouse-set-mark)
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
1332
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
1333 (global-set-key [mode-line mouse-1] 'mouse-select-window)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
1334 (global-set-key [mode-line mouse-2] 'mouse-delete-other-windows)
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1335 (global-set-key [mode-line mouse-3] 'mouse-delete-window)
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
1336 (global-set-key [mode-line C-mouse-2] 'mouse-split-window-horizontally)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1337
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1338 (provide 'mouse)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1339
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1340 ;;; mouse.el ends here