annotate lisp/viper/viper-mous.el @ 175:2d532a89d707 r20-3b14

Import from CVS: tag r20-3b14
author cvs
date Mon, 13 Aug 2007 09:50:14 +0200
parents 0132846995bd
children bfd6434d15b3
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 ;;; viper-mous.el --- mouse support for Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
24 (provide 'viper-mous)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; compiler pacifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (defvar double-click-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defvar mouse-track-multi-click-time)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
29 (defvar vip-search-start-marker)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
30 (defvar vip-local-search-start-marker)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
31 (defvar vip-search-history)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
32 (defvar vip-s-string)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
33 (defvar vip-re-search)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
34
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
35 ;; loading happens only in non-interactive compilation
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
36 ;; in order to spare non-viperized emacs from being viperized
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
37 (if noninteractive
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
38 (eval-when-compile
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
39 (let ((load-path (cons (expand-file-name ".") load-path)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
40 (or (featurep 'viper-util)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
41 (load "viper-util.el" nil nil 'nosuffix))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
42 (or (featurep 'viper-cmd)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
43 (load "viper-cmd.el" nil nil 'nosuffix))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
44 )))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
45 ;; end pacifier
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
46
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
47 (require 'viper-util)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
48
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
49
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
50 (defgroup viper-mouse nil
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
51 "Support for Viper special mouse-bound commands"
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
52 :prefix "vip-"
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
53 :group 'viper)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
54
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; Variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; Variable used for catching the switch-frame event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; If non-nil, indicates that previous-frame should be the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; one. Used by vip-mouse-click-get-word. Not a user option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar vip-frame-of-focus nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; Frame that was selected before the switch-frame event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defconst vip-current-frame-saved (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
66 (defcustom vip-surrounding-word-function 'vip-surrounding-word
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "*Function that determines what constitutes a word for clicking events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Takes two parameters: a COUNT, indicating how many words to return,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 and CLICK-COUNT, telling whether this is the first click, a double-click,
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
70 or a tripple-click."
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
71 :type 'boolean
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
72 :group 'viper-mouse)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; time interval in millisecond within which successive clicks are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; considered related
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
76 (defcustom vip-multiclick-timeout (if (vip-window-display-p)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
77 (if vip-xemacs-p
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
78 mouse-track-multi-click-time
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
79 double-click-time)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
80 500)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
81 "*Time interval in millisecond within which successive mouse clicks are
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
82 considered related."
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
83 :type 'integer
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
84 :group 'viper-mouse)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; current event click count; XEmacs only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvar vip-current-click-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; time stamp of the last click event; XEmacs only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defvar vip-last-click-event-timestamp 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; Local variable used to toggle wraparound search on click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (vip-deflocalvar vip-mouse-click-search-noerror t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; Local variable used to delimit search after wraparound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (vip-deflocalvar vip-mouse-click-search-limit nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; remembers prefix argument to pass along to commands invoked by second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; This is needed because in Emacs (not XEmacs), assigning to preix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; causes Emacs to count the second click as if it was a single click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defvar vip-global-prefix-argument 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; Code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defsubst vip-multiclick-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (not (vip-sit-for-short vip-multiclick-timeout t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; Returns window where click occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defsubst vip-mouse-click-window (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (if vip-xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (event-window click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (posn-window (event-start click))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; Returns window where click occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defsubst vip-mouse-click-frame (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (window-frame (vip-mouse-click-window click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; Returns the buffer of the window where click occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defsubst vip-mouse-click-window-buffer (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (window-buffer (vip-mouse-click-window click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; Returns the name of the buffer in the window where click occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defsubst vip-mouse-click-window-buffer-name (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (buffer-name (vip-mouse-click-window-buffer click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; Returns position of a click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defsubst vip-mouse-click-posn (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if vip-xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (event-point click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (posn-point (event-start click))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defun vip-surrounding-word (count click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 "Returns word surrounding point according to a heuristic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 COUNT indicates how many regions to return.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 If CLICK-COUNT is 1, `word' is a word in Vi sense.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 If CLICK-COUNT is 2,then `word' is a Word in Vi sense.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 If the character clicked on is a non-separator and is non-alphanumeric but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 is adjacent to an alphanumeric symbol, then it is considered alphanumeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 for the purpose of this command. If this character has a matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 character, such as `\(' is a match for `\)', then the matching character is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 also considered alphanumeric.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 For convenience, in Lisp modes, `-' is considered alphanumeric.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 If CLICK-COUNT is 3 or more, returns the line clicked on with leading and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 trailing space and tabs removed. In that case, the first argument, COUNT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 is ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (let ((modifiers "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 beg skip-flag result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 word-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (if (> click-count 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (vip-skip-all-separators-forward 'within-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (setq result (buffer-substring beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if (and (not (vip-looking-at-alphasep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (or (save-excursion (vip-backward-char-carefully)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (vip-looking-at-alpha))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (save-excursion (vip-forward-char-carefully)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (vip-looking-at-alpha))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (setq modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (cond ((looking-at "\\\\") "\\\\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ((looking-at "-") "C-C-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ((looking-at "[][]") "][")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ((looking-at "[()]") ")(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ((looking-at "[{}]") "{}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ((looking-at "[<>]") "<>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ((looking-at "[`']") "`'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ((looking-at "\\^") "\\^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ((vip-looking-at-separator) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (t (char-to-string (following-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; Add `-' to alphanum, if it wasn't added and if we are in Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (or (looking-at "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (not (string-match "lisp" (symbol-name major-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (setq modifiers (concat modifiers "C-C-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (cond ((> click-count 1) (vip-skip-nonseparators 'backward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ((vip-looking-at-alpha modifiers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (vip-skip-alpha-backward modifiers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ((not (vip-looking-at-alphasep modifiers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (vip-skip-nonalphasep-backward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (t (if (> click-count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (vip-skip-nonseparators 'backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (vip-skip-alpha-backward modifiers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq word-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq skip-flag nil) ; don't move 1 char forw the first time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (while (> count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if skip-flag (vip-forward-char-carefully 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq skip-flag t) ; now always move 1 char forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if (> click-count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (vip-skip-nonseparators 'forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (vip-skip-alpha-forward modifiers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setq count (1- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (setq result (buffer-substring word-beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ) ; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; XEmacs doesn't have set-text-properties, but there buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; doesn't return properties together with the string, so it's not needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (if vip-emacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (set-text-properties 0 (length result) nil result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun vip-mouse-click-get-word (click count click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "Returns word surrounding the position of a mouse click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Click may be in another window. Current window and buffer isn't changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 On single or double click, returns the word as determined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 `vip-surrounding-word-function'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (let ((click-word "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (click-pos (vip-mouse-click-posn click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (click-buf (vip-mouse-click-window-buffer click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (or (natnump count) (setq count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (or (natnump click-count) (setq click-count 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 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (if click-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (set-buffer click-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (goto-char click-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq click-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (funcall vip-surrounding-word-function count click-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (error "Click must be over a window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 click-word))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (defun vip-mouse-click-insert-word (click arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "Insert word clicked or double-clicked on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 With prefix argument, N, insert that many words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 This command must be bound to a mouse click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 The double-click action of the same mouse button must not be bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 \(or it must be bound to the same function\).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 See `vip-surrounding-word' for the definition of a word in this case."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (interactive "e\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if vip-frame-of-focus ;; to handle clicks in another frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (select-frame vip-frame-of-focus))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; turn arg into a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (cond ((integerp arg) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; prefix arg is a list when one hits C-u then command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ((and (listp arg) (integerp (car arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (setq arg (car arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (t (setq arg 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (let (click-count interrupting-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (vip-multiclick-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; This trick checks if there is a pending mouse event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; if so, we use this latter event and discard the current mouse click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; If the next pending event is not a mouse event, we execute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; the current mouse event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq interrupting-event (vip-read-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (vip-mouse-event-p last-input-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (progn ;; interrupted wait
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (setq vip-global-prefix-argument arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; count this click for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (vip-event-click-count click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; uninterrupted wait or the interrupting event wasn't a mouse event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq click-count (vip-event-click-count click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if (> click-count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (setq arg vip-global-prefix-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 vip-global-prefix-argument nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (insert (vip-mouse-click-get-word click arg click-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (and interrupting-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (eventp interrupting-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (not (vip-mouse-event-p interrupting-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (vip-set-unread-command-events interrupting-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; arg is an event. accepts symbols and numbers, too
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun vip-mouse-event-p (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (if (eventp event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (string-match "\\(mouse-\\|frame\\|screen\\|track\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (prin1-to-string (vip-event-key event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; XEmacs has no double-click events. So, we must simulate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; So, we have to simulate event-click-count.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun vip-event-click-count (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if vip-xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; if more than 1 second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (if (> (- (event-timestamp click) vip-last-click-event-timestamp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 vip-multiclick-timeout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (setq vip-current-click-count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq vip-last-click-event-timestamp (event-timestamp click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 vip-current-click-count (1+ vip-current-click-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (event-click-count click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (defun vip-mouse-click-search-word (click arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "Find the word clicked or double-clicked on. Word may be in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 With prefix argument, N, search for N-th occurrence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 This command must be bound to a mouse click. The double-click action of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 same button must not be bound \(or it must be bound to the same function\).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 See `vip-surrounding-word' for the details on what constitutes a word for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 this command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (interactive "e\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (if vip-frame-of-focus ;; to handle clicks in another frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (select-frame vip-frame-of-focus))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (let (click-word click-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (previous-search-string vip-s-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (vip-multiclick-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; This trick checks if there is a pending mouse event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; if so, we use this latter event and discard the current mouse click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; If the next pending event is not a mouse event, we execute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; the current mouse event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (vip-read-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (vip-mouse-event-p last-input-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (progn ;; interrupted wait
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setq vip-global-prefix-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (or vip-global-prefix-argument arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; remember command that was before the multiclick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (setq this-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; make sure we counted this event---needed for XEmacs only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (vip-event-click-count click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; uninterrupted wait
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (setq click-count (vip-event-click-count click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (setq click-word (vip-mouse-click-get-word click nil click-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (if (> click-count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (setq arg vip-global-prefix-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 vip-global-prefix-argument nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (setq arg (or arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (vip-deactivate-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (if (or (not (string= click-word vip-s-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (not (markerp vip-search-start-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (not (equal (marker-buffer vip-search-start-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (not (eq last-command 'vip-mouse-click-search-word)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq vip-search-start-marker (point-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 vip-local-search-start-marker vip-search-start-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 vip-mouse-click-search-noerror t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 vip-mouse-click-search-limit nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; make search string known to Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq vip-s-string (if vip-re-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (regexp-quote click-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 click-word))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (if (not (string= vip-s-string (car vip-search-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (setq vip-search-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (cons vip-s-string vip-search-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (push-mark nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (vip-forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (if (not (search-forward click-word vip-mouse-click-search-limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 vip-mouse-click-search-noerror))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq vip-mouse-click-search-noerror nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (setq vip-mouse-click-search-limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (markerp vip-local-search-start-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (marker-buffer vip-local-search-start-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (goto-char vip-local-search-start-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (vip-line-pos 'end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (search-forward click-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 vip-mouse-click-search-limit nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (message "Searching for: %s" vip-s-string)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
387 (if (<= arg 1) ; found the right occurrence of the pattern
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
388 (progn
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
389 (vip-adjust-window)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
390 (vip-flash-search-pattern)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (error (beep 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if (or (not (string= click-word previous-search-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (not (eq last-command 'vip-mouse-click-search-word)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (message "`%s': String not found in %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 vip-s-string (buffer-name (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 "`%s': Last occurrence in %s. Back to beginning of search"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 click-word (buffer-name (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq arg 1) ;; to terminate the loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (sit-for 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (setq vip-mouse-click-search-noerror t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq vip-mouse-click-search-limit nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (if (and (markerp vip-local-search-start-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (marker-buffer vip-local-search-start-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (goto-char vip-local-search-start-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defun vip-mouse-catch-frame-switch (event arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 "Catch the event of switching frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 Usually is bound to a 'down-mouse' event to work properly. See sample
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 82
diff changeset
413 bindings in the Viper manual."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (interactive "e\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (setq vip-frame-of-focus nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; pass prefix arg along to vip-mouse-click-search/insert-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (setq prefix-arg arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if (eq last-command 'handle-switch-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (setq vip-frame-of-focus vip-current-frame-saved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; make Emacs forget that it executed vip-mouse-catch-frame-switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (setq this-command last-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;; Called just before switching frames. Saves the old selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; Sets last-command to handle-switch-frame (this is done automatically in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;; Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; The semantics of switching frames is different in Emacs and XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; In Emacs, if you select-frame A while mouse is over frame B and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; start typing, input goes to frame B, which becomes selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; In XEmacs, input will go to frame A. This may be a bug in one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; Emacsen, but also may be a design decision.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; Also, in Emacs sending input to frame B generates handle-switch-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;; event, while in XEmacs it doesn't.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; All this accounts for the difference in the behavior of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; vip-mouse-click-* commands when you click in a frame other than the one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; that was the last to receive input. In Emacs, focus will be in frame A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;; until you do something other than vip-mouse-click-* command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;; In XEmacs, you have to manually select frame B (with the mouse click) in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; order to shift focus to frame B.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (defsubst vip-remember-current-frame (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (setq last-command 'handle-switch-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 vip-current-frame-saved (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
444 ;;; Local Variables:
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
445 ;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
446 ;;; End:
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
447
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;;; viper-mous.el ends here