annotate lisp/prim/mouse.el @ 193:f53b5ca2e663 r20-3b23

Import from CVS: tag r20-3b23
author cvs
date Mon, 13 Aug 2007 09:58:30 +0200
parents 3d6bfa290dbd
children acd284d43ca1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; mouse.el --- window system-independent mouse support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Keywords: hardware
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1988, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Copyright (C) 1995 Tinker Systems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
23 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Synched up with: Not synched with FSF. Almost completely divergent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (provide 'mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (global-set-key 'button1 'mouse-track)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (global-set-key '(shift button1) 'mouse-track-adjust)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (global-set-key '(control button1) 'mouse-track-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (global-set-key '(control shift button1) 'mouse-track-delete-and-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (global-set-key '(meta button1) 'mouse-track-do-rectangle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
35 ;; enable drag regions (ograf@fga.de)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
36 (if (or (featurep 'offix) ;; do we have DnD support?
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
37 (featurep 'cde))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
38 (global-set-key 'button2 'mouse-drag-or-yank)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
39 (global-set-key 'button2 'mouse-yank))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
41 (defcustom mouse-track-rectangle-p nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "*If true, then dragging out a region with the mouse selects rectangles
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
43 instead of simple start/end regions."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
44 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
45 :group 'mouse)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
47 (defcustom mouse-yank-at-point nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "*If non-nil, the function `mouse-yank' will yank text at the cursor location.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 Otherwise, the cursor will be moved to the location of the pointer click before
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
50 text is inserted."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
51 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
52 :group 'mouse)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
54 (defvar mouse-yank-function 'mouse-consolidated-yank
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "Function that is called upon by `mouse-yank' to actually insert text.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
57 (defun mouse-consolidated-yank ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
58 (interactive)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
59 (case (device-type)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
60 (x (x-yank-function))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
61 (tty (yank))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
62 (otherwise (yank))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 120
diff changeset
63
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun mouse-select ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "Select Emacs window the mouse is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (interactive "@"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defun mouse-delete-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "Delete the Emacs window the mouse is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (defun mouse-keep-one-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "Select Emacs window mouse is on, then kill all other Emacs windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (delete-other-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun mouse-select-and-split ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "Select Emacs window mouse is on, then split it vertically in half."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (split-window-vertically nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun mouse-set-point (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "Select Emacs window mouse is on, and move point to mouse position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (let ((window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (pos (event-point event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (close-pos (event-closest-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (or window (error "not in a window"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (if (and pos (> pos 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; If the event was over a text char, it's easy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (goto-char (max (min pos (point-max)) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if (and close-pos (> close-pos 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (goto-char (max (min close-pos (point-max)) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; When the event occurs outside of the frame directly to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; left or right of a modeline, close-point is nil, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; event-over-modeline is also nil. That will drop us to this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; point. So instead of erroring, just return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defun mouse-yank (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 "Paste text with the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 If the variable `mouse-yank-at-point' is nil, then pasting occurs at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 location of the click; otherwise, pasting occurs at the current cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 location."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (and (not mouse-yank-at-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (mouse-set-point event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (funcall mouse-yank-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defun click-inside-extent-p (click extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "Returns non-nil if the button event is within the bounds of the primary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 selection-extent, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (let ((ewin (event-window click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (epnt (event-point click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (and ewin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 epnt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (eq (window-buffer ewin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (extent-object extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (> epnt (extent-start-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (> (extent-end-position extent) epnt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defun click-inside-selection-p (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (or (click-inside-extent-p click primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (click-inside-extent-p click zmacs-region-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun point-inside-extent-p (extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "Returns non-nil if the point is within or just after the bounds of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 primary selection-extent, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (and extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (eq (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (extent-object extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (> (point) (extent-start-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (>= (extent-end-position extent) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (defun point-inside-selection-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (or (point-inside-extent-p primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (point-inside-extent-p zmacs-region-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
148 (defun mouse-drag-or-yank (event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
149 "Either drag or paste the current selection. If the variable
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
150 `mouse-yank-at-point' is non-nil, then moves the cursor to the location of
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
151 the click before pasting.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
152 This functions has to be improved. Until now it is just a (working) test."
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
153 ;; by ograf@fga.de
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
154 (interactive "e")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
155 (if (click-inside-extent-p event zmacs-region-extent)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
156 ;; okay, this is a drag
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
157 (cond ((featurep 'offix)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
158 (offix-start-drag-region event
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
159 (extent-start-position zmacs-region-extent)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
160 (extent-end-position zmacs-region-extent)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
161 ((featurep 'cde)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
162 ;; should also work with CDE
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
163 (cde-start-drag
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
164 (extent-start-position zmacs-region-extent)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
165 (extent-end-position zmacs-region-extent)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
166 (t ding))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
167 ;; no drag, call region-funct
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
168 (and (not mouse-yank-at-point)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
169 (mouse-set-point event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
170 (funcall mouse-yank-function))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
171 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun mouse-eval-sexp (click force-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Evaluate the sexp under the mouse. Usually, this is the last sexp before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 the click, but if you click on a left paren, then it is the sexp beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 with the paren that is evaluated. Also, since strings evaluate to themselves,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 they're fed to re-search-forward and the matched region is highlighted until
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 the mouse button is released.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 Perhaps the most useful thing about this function is that the evaluation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 the expression which is clicked upon is relative not to the window where you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 click, but to the current window and the current position of point. Thus,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 you can use `mouse-eval-sexp' to interactively test code that acts upon a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 buffer...something you cannot do with the standard `eval-last-sexp' function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 It's also fantastic for debugging regular expressions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (interactive "e\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (let (exp val result-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (setq exp (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (mouse-set-point click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (or (looking-at "(") (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (read (point-marker))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (cond ((stringp exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (if (setq val (re-search-forward exp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (let* ((oo (make-extent (match-beginning 0) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (set-extent-face oo 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (set-extent-priority oo 1000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; wait for button release...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (setq unread-command-event (next-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (delete-extent oo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (message "Regex \"%s\" not found" exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (ding nil 'quiet)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (t (setq val (if (fboundp 'eval-interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (eval-interactive exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (eval exp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (setq result-str (prin1-to-string val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; #### -- need better test
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (if (and (not force-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (<= (length result-str) (window-width (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (message "%s" result-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (with-output-to-temp-buffer "*Mouse-Eval*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (pprint val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (error (prin1 val))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (defun mouse-line-length (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 "Print the length of the line indicated by the pointer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (message "Line length: %d" (- (progn (end-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (progn (beginning-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (sleep-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (defun mouse-set-mark (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 "Select Emacs window mouse is on, and set mark at mouse position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 Display cursor at that position for a second."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let ((point-save (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (progn (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (push-mark nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (sit-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (goto-char point-save))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (defun mouse-scroll (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 "Scroll point to the mouse position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (scroll-right (event-x event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun mouse-del-char (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "Delete the char pointed to by the mouse."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (delete-char 1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun mouse-kill-line (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "Kill the line pointed to by the mouse."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (kill-line nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defun mouse-bury-buffer (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "Bury the buffer pointed to by the mouse, thus selecting the next one."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (save-selected-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (select-window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (bury-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defun mouse-unbury-buffer (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "Unbury and select the most recently buried buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (save-selected-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (select-window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let* ((bufs (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (entry (1- (length bufs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (while (not (setq val (nth entry bufs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 val (and (/= (aref (buffer-name val) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq entry (1- entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (switch-to-buffer val))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defun narrow-window-to-region (m n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "Narrow window to region between point and last mark"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (eq (selected-window) (next-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (split-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (goto-char m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if (eq (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if (zerop (minibuffer-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (next-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (shrink-window (- (- (window-height) (count-lines m n)) 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defun mouse-window-to-region (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 "Narrow window to region between cursor and mouse pointer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let ((point-save (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (progn (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (push-mark nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (sit-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (goto-char point-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (narrow-window-to-region (region-beginning) (region-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (defun mouse-ignore ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "Don't do anything."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (interactive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; Commands for the scroll bar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;; #### this stuff has never ever been used and should be junked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;; Vertical bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun mouse-scroll-down (nlines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (interactive "@p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (scroll-down nlines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (defun mouse-scroll-up (nlines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (interactive "@p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (scroll-up nlines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (defun mouse-scroll-down-full ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (scroll-down nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (defun mouse-scroll-up-full ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (scroll-up nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defun mouse-scroll-move-cursor (nlines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (interactive "@p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (move-to-window-line nlines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun mouse-scroll-absolute (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (let* ((position (event-x event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (length (event-y event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (size (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (scale-factor (max 1 (/ 8000000 size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (newpos (* (/ (* (/ size scale-factor) position) length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 scale-factor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (goto-char newpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (recenter '(4))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;; These scroll while the invoking button is depressed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (defvar scrolled-lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defvar scroll-speed 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defun incr-scroll-down (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (setq scrolled-lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (incremental-scroll scroll-speed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defun incr-scroll-up (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq scrolled-lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (incremental-scroll (- scroll-speed)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun incremental-scroll (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (let ((down t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (while down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (sit-for mouse-track-scroll-delay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (cond ((input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (let ((event (next-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if (or (button-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (button-release-event-p event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (setq down nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (dispatch-event event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (scroll-down n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun incr-scroll-stop (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (setq scrolled-lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (sleep-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (defun mouse-scroll-left (ncolumns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (interactive "@p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (scroll-left ncolumns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defun mouse-scroll-right (ncolumns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (interactive "@p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (scroll-right ncolumns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (defun mouse-scroll-left-full ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (scroll-left nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (defun mouse-scroll-right-full ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (interactive "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (scroll-right nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (defun mouse-scroll-move-cursor-horizontally (ncolumns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (interactive "@p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (move-to-column ncolumns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (defun mouse-scroll-absolute-horizontally (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 "Junk me, please."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (set-window-hscroll (selected-window) 33))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;;; mouse/selection tracking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;;; generalized mouse-track
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
432 (defvar default-mouse-track-normalize-point-function
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
433 'default-mouse-track-normalize-point
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
434 "Function called to normalize position of point.
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
435 Called with two arguments: TYPE depends on the number of times that the
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
436 mouse has been clicked and is a member of `default-mouse-track-type-list',
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
437 FORWARDP determines the direction in which the point should be moved.")
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
438
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (defvar mouse-track-down-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 "Function or functions called when the user presses the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 This hook is invoked by `mouse-track'; thus, it will not be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 for any buttons with a different binding. The functions will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 called with two arguments: the button-press event and a click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 count (see `mouse-track-click-hook').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 If any function returns non-nil, the remaining functions will not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Note that most applications should take action when the mouse is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 released, not when it is pressed.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (defvar mouse-track-drag-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 "Function or functions called when the user drags the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 This hook is invoked by `mouse-track'; thus, it will not be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 for any buttons with a different binding. The functions will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 called with three arguments: the mouse-motion event, a click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 count (see `mouse-track-click-hook'), and whether the call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 this hook occurred as a result of a drag timeout (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 `mouse-track-scroll-delay').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 If any function returns non-nil, the remaining functions will not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 Note that no calls to this function will be made until the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 initiates a drag (i.e. moves the mouse more than a certain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 threshold in either the X or the Y direction, as defined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 `mouse-track-x-threshold' and `mouse-track-y-threshold').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 See also `mouse-track-drag-up-hook'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (defvar mouse-track-drag-up-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 "Function or functions called when the user finishes a drag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 This hook is invoked by `mouse-track'; thus, it will not be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 for any buttons with a different binding. The functions will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 called with two arguments: the button-press event and a click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 count (see `mouse-track-click-hook').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 If any function returns non-nil, the remaining functions will not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 Note that this hook will not be invoked unless the user has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 initiated a drag, i.e. moved the mouse more than a certain threshold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (see `mouse-track-drag-hook'). When this function is invoked,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 `mouse-track-drag-hook' will have been invoked at least once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 See also `mouse-track-click-hook'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (defvar mouse-track-click-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 "Function or functions called when the user clicks the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 `Clicking' means pressing and releasing the mouse without having
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 initiated a drag (i.e. without having moved more than a certain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 threshold -- see `mouse-track-drag-hook').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 This hook is invoked by `mouse-track'; thus, it will not be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 for any buttons with a different binding. The functions will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 called with two arguments: the button-release event and a click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 count, which specifies the number of times that the mouse has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 clicked in a series of clicks, each of which is separated by at most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 `mouse-track-multi-click-time'. This can be used to implement actions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 that are called on double clicks, triple clicks, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 If any function returns non-nil, the remaining functions will not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 See also `mouse-track-drag-up-hook.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (defvar mouse-track-up-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 "Function or functions called when the user releases the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 This hook is invoked by `mouse-track'; thus, it will not be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 for any buttons with a different binding. The functions will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 called with two arguments: the button-release event and a click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 count (see `mouse-track-click-hook').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 For many applications, it is more appropriate to use one or both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 of `mouse-track-click-hook' and `mouse-track-drag-up-hook'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defvar mouse-track-cleanup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 "Function or functions called when `mouse-track' terminates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 This hook will be called in all circumstances, even upon a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 non-local exit out of `mouse-track', and so is useful for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 doing cleanup work such as removing extents that may have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 been created during the operation of `mouse-track'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 Unlike all of the other mouse-track hooks, this is a \"normal\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 hook: the hook functions are called with no arguments, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 all hook functions are called regardless of their return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 values.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
529 (defcustom mouse-track-multi-click-time 400
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
530 "*Maximum number of milliseconds allowed between clicks for a multi-click.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
531 See `mouse-track-click-hook'."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
532 :type 'integer
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
533 :group 'mouse)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
535 (defcustom mouse-track-scroll-delay 100
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 "Maximum of milliseconds between calls to `mouse-track-drag-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 If the user is dragging the mouse (i.e. the button is held down and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 a drag has been initiated) and does not move the mouse for this many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 milliseconds, the hook will be called with t as the value of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 WAS-TIMEOUT parameter. This can be used to implement scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 in a selection when the user drags the mouse out the window it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 was in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
544 A value of nil disables the timeout feature."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
545 :type '(choice integer (const :tag "Disabled" nil))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
546 :group 'mouse)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (defvar mouse-track-x-threshold '(face-width 'default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 "Minimum number of pixels in the X direction for a drag to be initiated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 If the mouse is moved more than either the X or Y threshold while the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 button is held down (see also `mouse-track-y-threshold'), then a drag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 is initiated; otherwise the gesture is considered to be a click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 See `mouse-track'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 The value should be either a number of a form to be evaluated to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 produce a number.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defvar mouse-track-y-threshold '(face-height 'default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 "Minimum number of pixels in the Y direction for a drag to be initiated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 If the mouse is moved more than either the X or Y threshold while the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 button is held down (see also `mouse-track-x-threshold'), then a drag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 is initiated; otherwise the gesture is considered to be a click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 See `mouse-track'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 The value should be either a number of a form to be evaluated to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 produce a number.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; these variables are private to mouse-track.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (defvar mouse-track-up-time nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defvar mouse-track-up-x nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (defvar mouse-track-up-y nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (defvar mouse-track-timeout-id nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (defvar mouse-track-click-count nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (defun mouse-track-set-timeout (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (if mouse-track-timeout-id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (disable-timeout mouse-track-timeout-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (if mouse-track-scroll-delay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq mouse-track-timeout-id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (add-timeout (/ mouse-track-scroll-delay 1000.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 'mouse-track-scroll-undefined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (copy-event event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (defun mouse-track-run-hook (hook event &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; ugh, can't use run-special-hook-with-args because we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;; have to get the value using symbol-value-in-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; Doing a save-excursion/set-buffer is wrong because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; the hook might want to change the buffer, but just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; doing a set-buffer is wrong because the hook might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; not want to change the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (let ((buffer (event-buffer event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (if mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (let ((value (symbol-value-in-buffer hook buffer nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (if (and (listp value) (not (eq (car value) 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (let (retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (while (and value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (not (setq retval (apply (car value) event args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (setq value (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (apply value event args))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (defun mouse-track-scroll-undefined (random)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; the old implementation didn't actually define this function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;; and in normal use it won't ever be called because the timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; will either be removed before it fires or will be picked off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ;; with next-event and not dispatched. However, if you're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; attempting to debug a click-hook (which is pretty damn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;; difficult to do), this function may get called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (defun mouse-track (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 "Make a selection with the mouse. This should be bound to a mouse button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 The behavior of XEmacs during mouse selection is customizable using various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 hooks and variables: see `mouse-track-click-hook', `mouse-track-drag-hook',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 `mouse-track-drag-up-hook', `mouse-track-down-hook', `mouse-track-up-hook',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 `mouse-track-cleanup-hook', `mouse-track-multi-click-time',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 `mouse-track-scroll-delay', `mouse-track-x-threshold', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 `mouse-track-y-threshold'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 Default handlers are provided to implement standard selecting/positioning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 behavior. You can explicitly request this default behavior, and override
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 any custom-supplied handlers, by using the function `mouse-track-default'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 instead of `mouse-track'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 Default behavior is as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 If you click-and-drag, the selection will be set to the region between the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 point of the initial click and the point at which you release the button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 These positions need not be ordered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 If you click-and-release without moving the mouse, then the point is moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 and the selection is disowned (there will be no selection owner). The mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 will be set to the previous position of point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 If you double-click, the selection will extend by symbols instead of by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 characters. If you triple-click, the selection will extend by lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 If you drag the mouse off the top or bottom of the window, you can select
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 pieces of text which are larger than the visible part of the buffer; the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 buffer will scroll as necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 The selected text becomes the current X Selection. The point will be left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 at the position at which you released the button, and the mark will be left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 at the initial click position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (let ((mouse-down t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (xthresh (eval mouse-track-x-threshold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (ythresh (eval mouse-track-y-threshold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (orig-x (event-x-pixel event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (orig-y (event-y-pixel event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (mouse-grabbed-buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 mouse-moved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (if (or (not mouse-track-up-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (not mouse-track-up-y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (not mouse-track-up-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (> (- (event-timestamp event) mouse-track-up-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 mouse-track-multi-click-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (> (abs (- mouse-track-up-x orig-x)) xthresh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (> (abs (- mouse-track-up-y orig-y)) ythresh))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (setq mouse-track-click-count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (setq mouse-track-click-count (1+ mouse-track-click-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if (not (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (error "Not over a window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (mouse-track-run-hook 'mouse-track-down-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 event mouse-track-click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (while mouse-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (setq event (next-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (cond ((motion-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (if (and (not mouse-moved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (or (> (abs (- (event-x-pixel event) orig-x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 xthresh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (> (abs (- (event-y-pixel event) orig-y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ythresh)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (setq mouse-moved t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (if mouse-moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (mouse-track-run-hook 'mouse-track-drag-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 event mouse-track-click-count nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (mouse-track-set-timeout event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ((and (timeout-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (eq (event-function event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 'mouse-track-scroll-undefined))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (if mouse-moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (mouse-track-run-hook 'mouse-track-drag-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (event-object event) mouse-track-click-count t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (mouse-track-set-timeout (event-object event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 ((button-release-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (setq mouse-track-up-time (event-timestamp event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (setq mouse-track-up-x (event-x-pixel event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (setq mouse-track-up-y (event-y-pixel event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (setq mouse-down nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (mouse-track-run-hook 'mouse-track-up-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 event mouse-track-click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (if mouse-moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (mouse-track-run-hook 'mouse-track-drag-up-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 event mouse-track-click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (mouse-track-run-hook 'mouse-track-click-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 event mouse-track-click-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ((key-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (error "Selection aborted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (dispatch-event event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 ;; protected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (if mouse-track-timeout-id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (disable-timeout mouse-track-timeout-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (setq mouse-track-timeout-id nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (run-hooks 'mouse-track-cleanup-hook))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 ;;;;;;;;;;;; default handlers: new version of mouse-track
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (defvar default-mouse-track-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (defvar default-mouse-track-type-list '(char word line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (defvar default-mouse-track-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (defvar default-mouse-track-extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (defvar default-mouse-track-adjust nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (defvar default-mouse-track-min-anchor nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (defvar default-mouse-track-max-anchor nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (defvar default-mouse-track-result nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (defvar default-mouse-track-down-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (defun default-mouse-track-set-point-in-window (event window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (if (not (and (not (event-over-modeline-p event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (eq (event-window event) window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (let ((p (event-closest-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (and p (pos-visible-in-window-p p window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (defun default-mouse-track-scroll-and-set-point (event window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (let ((edges (window-pixel-edges window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (row (event-y-pixel event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (height (face-height 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (cond ((< (abs (- row (nth 1 edges))) (abs (- row (nth 3 edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;; closer to window's top than to bottom, so move up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (let ((delta (max 1 (/ (- (nth 1 edges) row) height))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (condition-case () (scroll-down delta) (error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (goto-char (window-start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 ((>= (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ;; scroll by one line if over the modeline or a clipped line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (let ((delta (if (or (event-over-modeline-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (< row (nth 3 edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (+ (/ (- row (nth 3 edges)) height) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (close-pos (event-closest-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (condition-case () (scroll-up delta) (error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (if (and close-pos (pos-visible-in-window-p close-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (goto-char close-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (goto-char (window-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (vertical-motion delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;; window-end reports the end of the clipped line, even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;; scroll-on-clipped-lines is t. compensate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 ;; (If window-end gets fixed this can be removed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (if (not (pos-visible-in-window-p (max (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (vertical-motion -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (condition-case () (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (error (end-of-line)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 ;; This remembers the last position at which the user clicked, for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 ;; benefit of mouse-track-adjust (for example, button1; scroll until the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ;; position of the click is off the frame; then Sh-button1 to select the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ;; new region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (defvar default-mouse-track-previous-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (defun default-mouse-track-set-point (event window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (if (default-mouse-track-set-point-in-window event window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (default-mouse-track-scroll-and-set-point event window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (defsubst default-mouse-track-beginning-of-word (symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (let ((word-constituent (cond ((eq symbolp t) "\\w\\|\\s_\\|\\s'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 ((null symbolp) "\\w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (t "[^ \t\n]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (white-space "[ \t]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (cond ((bobp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ((looking-at word-constituent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (while (and (not (bobp)) (looking-at word-constituent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (backward-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (if (or (not (bobp)) (not (looking-at word-constituent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (forward-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ((looking-at white-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (while (looking-at white-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (backward-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (forward-char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (defun default-mouse-track-end-of-word (symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (let ((word-constituent (cond ((eq symbolp t) "\\w\\|\\s_\\|\\s'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ((null symbolp) "\\w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (t "[^ \t\n]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (white-space "[ \t]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (cond ((looking-at word-constituent) ; word or symbol constituent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (while (looking-at word-constituent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (forward-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ((looking-at white-space) ; word or symbol constituent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (while (looking-at white-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (forward-char))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (defun default-mouse-track-normalize-point (type forwardp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (cond ((eq type 'word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ;; trap the beginning and end of buffer errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (condition-case ()
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
814 (progn
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
815 (setq type (char-syntax (char-after (point))))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
816 (if forwardp
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
817 (if (= type ?\()
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
818 (goto-char (scan-sexps (point) 1))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
819 (if (= type ?\))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
820 (forward-char 1)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
821 (default-mouse-track-end-of-word t)))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
822 (if (= type ?\))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
823 (goto-char (scan-sexps (1+ (point)) -1))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
824 (default-mouse-track-beginning-of-word t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (error ())))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ((eq type 'line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (if forwardp (end-of-line) (beginning-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ((eq type 'buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (if forwardp (end-of-buffer) (beginning-of-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (defun default-mouse-track-next-move (min-anchor max-anchor extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (let ((anchor (if (<= (point) min-anchor) max-anchor min-anchor)))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
833 (funcall default-mouse-track-normalize-point-function
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
834 default-mouse-track-type (> (point) anchor))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (if (consp extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (default-mouse-track-next-move-rect anchor (point) extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (if extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (if (<= anchor (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (set-extent-endpoints extent anchor (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (set-extent-endpoints extent (point) anchor))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (defun default-mouse-track-next-move-rect (start end extents &optional pad-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (if (< end start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (let ((tmp start)) (setq start end end tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ((= start end) ; never delete the last remaining extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (mapcar 'delete-extent (cdr extents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (setcdr extents nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (set-extent-endpoints (car extents) start start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (let ((indent-tabs-mode nil) ; if pad-p, don't use tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (rest extents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 left right last p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (setq right (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (setq left (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (if (< right left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (let ((tmp left))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (setq left right right tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (setq start (- start (- right left))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 end (+ end (- right left)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ;; End may have been set to a value greater than point-max if drag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ;; or movement extends to end of buffer, so reset it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (setq end (min end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (narrow-to-region (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (while (and rest (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (move-to-column right pad-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (set-extent-endpoints (car rest) p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ;; this code used to look at the return value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ;; of forward-line, but that doesn't work because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; forward-line has bogus behavior: If you're on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; the last line of a buffer but not at the very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; end, forward-line will move you to the very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; end and return 0 instead of 1, like it should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ;; the result was frequent infinite loops here,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 ;; creating very large numbers of extents at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 ;; the same position. There was an N^2 sorting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 ;; algorithm in extents.c for extents at a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 ;; particular position, and the result was very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 ;; bad news.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (move-to-column left pad-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (setq last rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 rest (cdr rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (cond (rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (mapcar 'delete-extent rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (setcdr last nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ((not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (move-to-column right pad-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (let ((e (make-extent p (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (set-extent-face e (extent-face (car extents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (set-extent-priority e (extent-priority (car extents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (setcdr last (cons e nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (setq last (cdr last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (move-to-column left pad-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (defun default-mouse-track-has-selection-p (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (and (or (not (eq 'x (console-type (selected-console))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (x-selection-owner-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (extent-live-p primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (not (extent-detached-p primary-selection-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (eq buffer (extent-object primary-selection-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (defun default-mouse-track-anchor (adjust previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (if adjust
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (if (default-mouse-track-has-selection-p (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (let ((start (extent-start-position primary-selection-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (end (extent-end-position primary-selection-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (cond ((< (point) start) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ((> (point) end) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ((> (- (point) start) (- end (point))) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (t end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (defun default-mouse-track-maybe-own-selection (pair type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (let ((start (car pair))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (end (cdr pair)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (or (= start end) (push-mark (if (= (point) start) end start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (cond (zmacs-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (if (= start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ;; #### UTTER KLUDGE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ;; If we don't have this sit-for here, then triple-clicking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ;; will result in the line not being highlighted as it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;; should. What appears to be happening is this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;; -- each time the button goes down, the selection is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;; disowned (see comment "remove the existing selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; to unclutter the display", below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ;; -- this causes a SelectionClear event to be sent to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ;; XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;; -- each time the button goes up except the first, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ;; selection is owned again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 ;; -- later, XEmacs processes the SelectionClear event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; The selection code attempts to keep track of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ;; time that it last asserted the selection, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ;; compare it to the time of the SelectionClear event,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ;; to see if it's a bogus notification or not (as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ;; is the case here). However, for some unknown
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 ;; reason this doesn't work in the triple-clicking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ;; case, and the selection code bogusly thinks this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;; SelectionClear event is the real thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 ;; -- putting the sit-for in causes the pending
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;; SelectionClear events to get processed before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 ;; the selection is reasserted, so everything works
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 ;; out OK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ;; Presumably(?) this means there is a weird timing bug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 ;; in the selection code, but there's not a chance in hell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 ;; that I have the patience to track it down. Blame the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ;; designers of X for fucking everything up so badly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 ;; This was originally a sit-for 0 but that wasn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 ;; sufficient to make things work. Even this isn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; always sufficient but it seems to give something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; approaching a 99% success rate. Making it higher yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ;; would help guarantee success with the price that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 ;; delay would start to become noticable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (sit-for 0.15 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (zmacs-activate-region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ((eq 'x (console-type (selected-console)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (if (= start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (x-disown-selection type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (if (consp default-mouse-track-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 ;; own the rectangular region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;; this is a hack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (let ((r default-mouse-track-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (set-buffer (get-buffer-create " *rect yank temp buf*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (while r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (insert (extent-string (car r)) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (setq r (cdr r)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (x-own-selection (buffer-substring (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (kill-buffer (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (x-own-selection (cons (set-marker (make-marker) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (set-marker (make-marker) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 type)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (if (and (eq 'x (console-type (selected-console)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (not (= start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;; I guess cutbuffers should do something with rectangles too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; does anybody use them?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (x-store-cutbuffer (buffer-substring start end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (defun default-mouse-track-deal-with-down-event (click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (let ((event default-mouse-track-down-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (if (null event) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (select-frame (event-frame event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (let ((adjust default-mouse-track-adjust)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ;; ####When you click on the splash-screen,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 ;; event-{closest-,}point can be out of bounds. Should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 ;; event-closest-point really be allowed to return a bad
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 ;; position like that? Maybe pixel_to_glyph_translation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 ;; needs to invalidate its cache when the buffer changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 ;; -dkindred@cs.cmu.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (close-pos (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (set-buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (let ((p (event-closest-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (and p (min (max p (point-min)) (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 extent previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (if (not (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (error "not over window?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (setq default-mouse-track-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (nth (mod (1- click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (length default-mouse-track-type-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 default-mouse-track-type-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (setq default-mouse-track-window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 ;; Note that the extent used here is NOT the extent which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ;; ends up as the value of zmacs-region-extent - this one is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ;; just during mouse-dragging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (setq default-mouse-track-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (make-extent close-pos close-pos (event-buffer event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (setq extent default-mouse-track-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (set-extent-face extent 'zmacs-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ;; While the selection is being dragged out, give the selection extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 ;; slightly higher priority than any mouse-highlighted extent, so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 ;; the exact endpoints of the selection will be visible while the mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ;; is down. Normally, the selection and mouse highlighting have the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ;; same priority, so that conflicts between the two of them are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;; resolved by the usual size-and-endpoint-comparison method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (set-extent-priority extent (1+ mouse-highlight-priority))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (if mouse-track-rectangle-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (setq default-mouse-track-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (list default-mouse-track-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (setq previous-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (if (and adjust
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (markerp default-mouse-track-previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (eq (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (marker-buffer default-mouse-track-previous-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (marker-position default-mouse-track-previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (default-mouse-track-set-point event default-mouse-track-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (if (not adjust)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (if (markerp default-mouse-track-previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (set-marker default-mouse-track-previous-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (setq default-mouse-track-previous-point (point-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; adjust point to a word or line boundary if appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (let ((anchor (default-mouse-track-anchor adjust previous-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (setq default-mouse-track-min-anchor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (save-excursion (goto-char anchor)
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
1058 (funcall
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
1059 default-mouse-track-normalize-point-function
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 default-mouse-track-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (setq default-mouse-track-max-anchor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (save-excursion (goto-char anchor)
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
1064 (funcall
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 110
diff changeset
1065 default-mouse-track-normalize-point-function
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 default-mouse-track-type t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 ;; remove the existing selection to unclutter the display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (if (not adjust)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (cond (zmacs-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (zmacs-deactivate-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 ((eq 'x (console-type (selected-console)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (x-disown-selection)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (setq default-mouse-track-down-event nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (defun default-mouse-track-down-hook (event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (setq default-mouse-track-down-event (copy-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1081 (defun default-mouse-track-cleanup-extents-hook ()
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1082 (remove-hook 'pre-command-hook 'default-mouse-track-cleanup-extents-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (let ((extent default-mouse-track-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (if (consp extent) ; rectangle-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (mapcar 'delete-extent extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (if extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (delete-extent extent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1089 (defun default-mouse-track-cleanup-hook ()
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1090 (if zmacs-regions
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1091 (funcall 'default-mouse-track-cleanup-extents-hook)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1092 (let ((extent default-mouse-track-extent)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1093 (func #'(lambda (e)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1094 (and (extent-live-p e)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 104
diff changeset
1095 (set-extent-face e 'primary-selection)))))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1096 (add-hook 'pre-command-hook 'default-mouse-track-cleanup-extents-hook)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1097 (if (consp extent) ; rectangle-p
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1098 (mapcar func extent)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1099 (if extent
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1100 (funcall func extent))))))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 74
diff changeset
1101
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (defun default-mouse-track-cleanup-extent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (let ((dead-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (or (not (extent-live-p x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (extent-detached-p x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (extent default-mouse-track-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (if (consp extent)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1109 (if (funcall dead-func extent)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (let (newval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (mapcar (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (if (not (funcall dead-func x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (setq newval (cons x newval)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (setq default-mouse-track-extent (nreverse newval))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (if (funcall dead-func extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (setq default-mouse-track-extent nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (defun default-mouse-track-drag-hook (event click-count was-timeout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (default-mouse-track-deal-with-down-event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (default-mouse-track-set-point event default-mouse-track-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (default-mouse-track-cleanup-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (default-mouse-track-next-move default-mouse-track-min-anchor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 default-mouse-track-max-anchor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 default-mouse-track-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (defun default-mouse-track-return-dragged-selection (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (default-mouse-track-cleanup-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (let ((extent default-mouse-track-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (default-mouse-track-set-point-in-window event default-mouse-track-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (default-mouse-track-next-move default-mouse-track-min-anchor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 default-mouse-track-max-anchor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (cond ((consp extent) ; rectangle-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (let ((first (car extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (last (car (setq extent (nreverse extent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 ;; nreverse is destructive so we need to reset this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (setq default-mouse-track-extent extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (setq result (cons (extent-start-position first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (extent-end-position last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 ;; kludge to fix up region when dragging backwards...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (if (and (/= (point) (extent-start-position first))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (/= (point) (extent-end-position last))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (= (point) (extent-end-position first)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (goto-char (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (setq result (cons (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (extent-end-position extent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ;; Minor kludge: if we're selecting in line-mode, include the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;; final newline. It's hard to do this in *-normalize-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (if (and result (eq default-mouse-track-type 'line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (let ((end-p (= (point) (cdr result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (goto-char (cdr result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (setcdr result (1+ (cdr result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (goto-char (if end-p (cdr result) (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ;;; ;; Minor kludge sub 2. If in char mode, and we drag the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;;; ;; mouse past EOL, include the newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 ;;; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 ;;; ;; Major problem: can't easily distinguish between being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 ;;; ;; just past the last char on a line, and well past it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ;;; ;; to determine whether or not to include it in the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 ;;; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;;; (if nil ; (eq default-mouse-track-type 'char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;;; (let ((after-end-p (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;;; (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;;; (> (point) (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;;; (if after-end-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ;;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;;; (setcdr result (1+ (cdr result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ;;; (goto-char (cdr result))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (defun default-mouse-track-drag-up-hook (event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (let ((result (default-mouse-track-return-dragged-selection event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (if result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (default-mouse-track-maybe-own-selection result 'PRIMARY)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (defun default-mouse-track-click-hook (event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (default-mouse-track-drag-hook event click-count nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (default-mouse-track-drag-up-hook event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (add-hook 'mouse-track-down-hook 'default-mouse-track-down-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (add-hook 'mouse-track-drag-hook 'default-mouse-track-drag-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (add-hook 'mouse-track-drag-up-hook 'default-mouse-track-drag-up-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (add-hook 'mouse-track-click-hook 'default-mouse-track-click-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (add-hook 'mouse-track-cleanup-hook 'default-mouse-track-cleanup-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;;;;;;;;;;;; other mouse-track stuff (mostly associated with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;;;;;;;;;;;; default handlers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (defun mouse-track-default (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 "Invoke `mouse-track' with only the default handlers active."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (let ((mouse-track-down-hook 'default-mouse-track-down-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (mouse-track-drag-hook 'default-mouse-track-drag-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (mouse-track-drag-up-hook 'default-mouse-track-drag-up-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (mouse-track-click-hook 'default-mouse-track-click-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (mouse-track-cleanup-hook 'default-mouse-track-cleanup-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (mouse-track event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (defun mouse-track-do-rectangle (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 "Like `mouse-track' but selects rectangles instead of regions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (let ((mouse-track-rectangle-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (mouse-track event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (defun mouse-track-adjust (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 "Extend the existing selection. This should be bound to a mouse button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 The selection will be enlarged or shrunk so that the point of the mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 click is one of its endpoints. This function in fact behaves fairly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 similarly to `mouse-track', but begins by extending the existing selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (or creating a new selection from the previous text cursor position to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 the current mouse position) instead of creating a new, empty selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 The mouse-track handlers are run from this command just like from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 `mouse-track'. Therefore, do not call this command from a mouse-track
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 handler!"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (let ((default-mouse-track-adjust t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (mouse-track event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (defun mouse-track-adjust-default (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 "Extend the existing selection, using only the default handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 This is just like `mouse-track-adjust' but will override any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 custom mouse-track handlers that the user may have installed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (let ((default-mouse-track-adjust t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (mouse-track-default event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (defvar mouse-track-insert-selected-region nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (defun mouse-track-insert-drag-up-hook (event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (setq mouse-track-insert-selected-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (default-mouse-track-return-dragged-selection event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (defun mouse-track-insert (event &optional delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 "Make a selection with the mouse and insert it at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 This is exactly the same as the `mouse-track' command on \\[mouse-track],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 except that point is not moved; the selected text is immediately inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 after being selected\; and the selection is immediately disowned afterwards."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (interactive "*e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (setq mouse-track-insert-selected-region nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (let ((mouse-track-drag-up-hook 'mouse-track-insert-drag-up-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (mouse-track-click-hook 'mouse-track-insert-click-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (mouse-track event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (if (consp mouse-track-insert-selected-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (let ((pair mouse-track-insert-selected-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (setq s (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (buffer-substring (car pair) (cdr pair))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (if delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (kill-region (car pair) (cdr pair)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (or (null s) (equal s "") (insert s))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (defun mouse-track-insert-click-hook (event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (default-mouse-track-drag-hook event click-count nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (mouse-track-insert-drag-up-hook event click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (defun mouse-track-delete-and-insert (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 "Make a selection with the mouse and insert it at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 This is exactly the same as the `mouse-track' command on \\[mouse-track],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 except that point is not moved; the selected text is immediately inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 after being selected\; and the text of the selection is deleted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (interactive "*e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (mouse-track-insert event t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (defvar inhibit-help-echo nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 "Inhibits display of `help-echo' extent properties in the minibuffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (defvar last-help-echo-object nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (defvar help-echo-owns-message nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (defun clear-help-echo (&optional ignored-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (if help-echo-owns-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (setq help-echo-owns-message nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 last-help-echo-object nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (clear-message 'help-echo))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (defun show-help-echo (mess)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 ;; (clear-help-echo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (setq help-echo-owns-message t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (display-message 'help-echo mess))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (add-hook 'mouse-leave-frame-hook 'clear-help-echo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (defun default-mouse-motion-handler (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 "For use as the value of `mouse-motion-handler'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 This implements the various pointer-shape variables,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 as well as extent highlighting, help-echo, toolbar up/down,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 and `mode-motion-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (let* ((frame (or (event-frame event) (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (point (and buffer (event-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (modeline-point (and buffer (event-modeline-position event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (extent (and point (extent-at point buffer 'mouse-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (glyph1 (event-glyph-extent event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (glyph (and glyph1 (extent-live-p glyph1) glyph1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (user-pointer1 (or (and glyph (extent-property glyph 'pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (and point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (extent-at point buffer 'pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (and modeline-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (extent-at modeline-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (symbol-value-in-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 'generated-modeline-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 buffer) 'pointer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (user-pointer (and user-pointer1 (extent-live-p user-pointer1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (extent-property user-pointer1 'pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (button (event-toolbar-button event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (help (or (and glyph (extent-property glyph 'help-echo) glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (and button (not (null (toolbar-button-help-string button)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (and point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (extent-at point buffer 'help-echo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (and modeline-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (extent-at modeline-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (symbol-value-in-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 'generated-modeline-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 buffer) 'help-echo)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 ;; vars is a list of glyph variables to check for a pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 ;; value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (vars (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 ;; Checking if button is non-nil is not sufficent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ;; since the pointer could be over a blank portion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 ;; of the toolbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ((event-over-toolbar-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 '(toolbar-pointer-glyph nontext-pointer-glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 text-pointer-glyph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 ((or extent glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 '(selection-pointer-glyph text-pointer-glyph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 ((event-over-modeline-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 '(modeline-pointer-glyph nontext-pointer-glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 text-pointer-glyph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (point '(text-pointer-glyph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (buffer '(nontext-pointer-glyph text-pointer-glyph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (t '(modeline-pointer-glyph nontext-pointer-glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 text-pointer-glyph))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (if (and user-pointer (glyphp user-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (setq vars (cons 'user-pointer vars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (while (and vars (not (pointer-image-instance-p pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (setq pointer (glyph-image-instance (symbol-value (car vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (or window frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 vars (cdr vars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (if (pointer-image-instance-p pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (set-frame-pointer frame pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 ;; If last-pressed-toolbar-button is not nil, then check and see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; if we have moved to a new button and adjust the down flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;; accordingly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (if (and (featurep 'toolbar) toolbar-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (if (not (eq last-pressed-toolbar-button button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (release-previous-toolbar-button event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (and button (press-toolbar-button event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (cond (extent (highlight-extent extent t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (glyph (highlight-extent glyph t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (t (highlight-extent nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (cond ((extentp help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (or inhibit-help-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (eq help last-help-echo-object) ;save some time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (let ((hprop (extent-property help 'help-echo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (setq last-help-echo-object help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (or (stringp hprop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (setq hprop (funcall hprop help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (and hprop (show-help-echo hprop)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 ((and (featurep 'toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (toolbar-button-p help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (toolbar-button-enabled-p help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (or (not toolbar-help-enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (eq help last-help-echo-object) ;save some time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (let ((hstring (toolbar-button-help-string button)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (setq last-help-echo-object help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (or (stringp hstring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (setq hstring (funcall hstring help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (show-help-echo hstring))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (last-help-echo-object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (clear-help-echo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (if mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (if (and buffer (symbol-value-in-buffer 'mode-motion-hook buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (run-hook-with-args 'mode-motion-hook event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 ;; If the mode-motion-hook created a highlightable extent around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 ;; the mouse-point, highlight it right away. Otherwise it wouldn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 ;; be highlighted until the *next* motion event came in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (if (and point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (null extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (setq extent (extent-at point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (event-buffer event) ; not buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 'mouse-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (highlight-extent extent t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (setq mouse-motion-handler 'default-mouse-motion-handler)