annotate lisp/viper/viper-mous.el @ 199:169c0442b401 r20-3b26

Import from CVS: tag r20-3b26
author cvs
date Mon, 13 Aug 2007 10:00:33 +0200
parents acd284d43ca1
children
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)
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
29 (defvar viper-search-start-marker)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
30 (defvar viper-local-search-start-marker)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
31 (defvar viper-search-history)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
32 (defvar viper-s-string)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
33 (defvar viper-re-search)
80
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"
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
52 :prefix "viper-"
175
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
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
60 ;; one. Used by viper-mouse-click-get-word. Not a user option.
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
61 (defvar viper-frame-of-focus nil)
0
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.
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
64 (defconst viper-current-frame-saved (selected-frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
66 (defcustom viper-surrounding-word-function 'viper-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
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
76 (defcustom viper-multiclick-timeout (if (viper-window-display-p)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
77 (if viper-xemacs-p
175
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
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
87 (defvar viper-current-click-count 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; time stamp of the last click event; XEmacs only
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
89 (defvar viper-last-click-event-timestamp 0)
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.
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
92 (viper-deflocalvar viper-mouse-click-search-noerror t)
0
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.
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
95 (viper-deflocalvar viper-mouse-click-search-limit nil)
0
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
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
101 (defvar viper-global-prefix-argument nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
102
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
103
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
104 ;; same keys, but parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
105 (defvar viper-mouse-up-search-key-parsed nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
106 (defvar viper-mouse-down-search-key-parsed nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
107 (defvar viper-mouse-up-insert-key-parsed nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
108 (defvar viper-mouse-down-insert-key-parsed nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
109
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; Code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
115 (defsubst viper-multiclick-p ()
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
116 (not (viper-sit-for-short viper-multiclick-timeout t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; Returns window where click occurs
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
119 (defsubst viper-mouse-click-window (click)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
120 (if viper-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (event-window click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (posn-window (event-start 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 window where click occurs
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
125 (defsubst viper-mouse-click-frame (click)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
126 (window-frame (viper-mouse-click-window click)))
0
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 the buffer of the window where click occurs
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
129 (defsubst viper-mouse-click-window-buffer (click)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
130 (window-buffer (viper-mouse-click-window click)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; Returns the name of the buffer in the window where click occurs
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
133 (defsubst viper-mouse-click-window-buffer-name (click)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
134 (buffer-name (viper-mouse-click-window-buffer click)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; Returns position of a click
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
137 (defsubst viper-mouse-click-posn (click)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
138 (if viper-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (event-point click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (posn-point (event-start click))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
143 (defun viper-surrounding-word (count click-count)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 "Returns word surrounding point according to a heuristic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 COUNT indicates how many regions to return.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 If CLICK-COUNT is 1, `word' is a word in Vi sense.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 If CLICK-COUNT is 2,then `word' is a Word in Vi sense.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 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
149 is adjacent to an alphanumeric symbol, then it is considered alphanumeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 for the purpose of this command. If this character has a matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 character, such as `\(' is a match for `\)', then the matching character is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 also considered alphanumeric.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 For convenience, in Lisp modes, `-' is considered alphanumeric.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 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
156 trailing space and tabs removed. In that case, the first argument, COUNT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 is ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (let ((modifiers "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 beg skip-flag result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 word-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if (> click-count 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (beginning-of-line)
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
164 (viper-skip-all-separators-forward 'within-line)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq result (buffer-substring beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
169 (if (and (not (viper-looking-at-alphasep))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
170 (or (save-excursion (viper-backward-char-carefully)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
171 (viper-looking-at-alpha))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
172 (save-excursion (viper-forward-char-carefully)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
173 (viper-looking-at-alpha))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (setq modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (cond ((looking-at "\\\\") "\\\\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ((looking-at "-") "C-C-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ((looking-at "[][]") "][")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ((looking-at "[()]") ")(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ((looking-at "[{}]") "{}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ((looking-at "[<>]") "<>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ((looking-at "[`']") "`'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ((looking-at "\\^") "\\^")
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
183 ((viper-looking-at-separator) "")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (t (char-to-string (following-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; 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
188 (or (looking-at "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (not (string-match "lisp" (symbol-name major-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq modifiers (concat modifiers "C-C-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (save-excursion
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
194 (cond ((> click-count 1) (viper-skip-nonseparators 'backward))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
195 ((viper-looking-at-alpha modifiers)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
196 (viper-skip-alpha-backward modifiers))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
197 ((not (viper-looking-at-alphasep modifiers))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
198 (viper-skip-nonalphasep-backward))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (t (if (> click-count 1)
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
200 (viper-skip-nonseparators 'backward)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
201 (viper-skip-alpha-backward modifiers))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (setq word-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (setq skip-flag nil) ; don't move 1 char forw the first time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (while (> count 0)
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
207 (if skip-flag (viper-forward-char-carefully 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (setq skip-flag t) ; now always move 1 char forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if (> click-count 1)
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
210 (viper-skip-nonseparators 'forward)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
211 (viper-skip-alpha-forward modifiers))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq count (1- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (setq result (buffer-substring word-beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ) ; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;; XEmacs doesn't have set-text-properties, but there buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;; doesn't return properties together with the string, so it's not needed.
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
218 (if viper-emacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (set-text-properties 0 (length result) nil result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
224 (defun viper-mouse-click-get-word (click count click-count)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 "Returns word surrounding the position of a mouse click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 Click may be in another window. Current window and buffer isn't changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 On single or double click, returns the word as determined by
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
228 `viper-surrounding-word-function'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let ((click-word "")
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
231 (click-pos (viper-mouse-click-posn click))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
232 (click-buf (viper-mouse-click-window-buffer click)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (or (natnump count) (setq count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (or (natnump click-count) (setq click-count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (if click-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (set-buffer click-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (goto-char click-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (setq click-word
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
244 (funcall viper-surrounding-word-function count click-count)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (error "Click must be over a window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 click-word))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
249 (defun viper-mouse-click-insert-word (click arg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "Insert word clicked or double-clicked on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 With prefix argument, N, insert that many words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 This command must be bound to a mouse click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 The double-click action of the same mouse button must not be bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 \(or it must be bound to the same function\).
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
255 See `viper-surrounding-word' for the definition of a word in this case."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (interactive "e\nP")
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
257 (if viper-frame-of-focus ;; to handle clicks in another frame
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
258 (select-frame viper-frame-of-focus))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
259 (if (or (not (eq (key-binding viper-mouse-down-insert-key-parsed)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
260 'viper-mouse-catch-frame-switch))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
261 (not (eq (key-binding viper-mouse-up-insert-key-parsed)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
262 'viper-mouse-click-insert-word))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
263 (and viper-xemacs-p (not (event-over-text-area-p click))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
264 () ; do nothing, if binding isn't right or not over text
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
265 ;; turn arg into a number
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
266 (cond ((integerp arg) nil)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
267 ;; prefix arg is a list when one hits C-u then command
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
268 ((and (listp arg) (integerp (car arg)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
269 (setq arg (car arg)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
270 (t (setq arg 1)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
271
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
272 (if (not (eq (key-binding viper-mouse-down-insert-key-parsed)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
273 'viper-mouse-catch-frame-switch))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
274 () ; do nothing
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
275 (let (click-count interrupting-event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
276 (if (and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
277 (viper-multiclick-p)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
278 ;; This trick checks if there is a pending mouse event if so, we
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
279 ;; use this latter event and discard the current mouse click If
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
280 ;; the next pending event is not a mouse event, we execute the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
281 ;; current mouse event
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
282 (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
283 (setq interrupting-event (viper-read-event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
284 (viper-mouse-event-p last-input-event)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
285 (progn ; interrupted wait
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
286 (setq viper-global-prefix-argument arg)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
287 ;; count this click for XEmacs
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
288 (viper-event-click-count click))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
289 ;; uninterrupted wait or the interrupting event wasn't a mouse event
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
290 (setq click-count (viper-event-click-count click))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
291 (if (> click-count 1)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
292 (setq arg viper-global-prefix-argument
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
293 viper-global-prefix-argument nil))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
294 (insert (viper-mouse-click-get-word click arg click-count))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
295 (if (and interrupting-event
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
296 (eventp interrupting-event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
297 (not (viper-mouse-event-p interrupting-event)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
298 (viper-set-unread-command-events interrupting-event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
299 )))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; arg is an event. accepts symbols and numbers, too
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
302 (defun viper-mouse-event-p (event)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (if (eventp event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (string-match "\\(mouse-\\|frame\\|screen\\|track\\)"
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
305 (prin1-to-string (viper-event-key event)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; XEmacs has no double-click events. So, we must simulate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; So, we have to simulate event-click-count.
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
309 (defun viper-event-click-count (click)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
310 (if viper-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; if more than 1 second
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
313 (if (> (- (event-timestamp click) viper-last-click-event-timestamp)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
314 viper-multiclick-timeout)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
315 (setq viper-current-click-count 0))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
316 (setq viper-last-click-event-timestamp (event-timestamp click)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
317 viper-current-click-count (1+ viper-current-click-count)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (event-click-count click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
322 (defun viper-mouse-click-search-word (click arg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "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
324 With prefix argument, N, search for N-th occurrence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 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
326 same button must not be bound \(or it must be bound to the same function\).
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
327 See `viper-surrounding-word' for the details on what constitutes a word for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 this command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (interactive "e\nP")
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
330 (if viper-frame-of-focus ;; to handle clicks in another frame
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
331 (select-frame viper-frame-of-focus))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
332 (if (or (not (eq (key-binding viper-mouse-down-search-key-parsed)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
333 'viper-mouse-catch-frame-switch))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
334 (not (eq (key-binding viper-mouse-up-search-key-parsed)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
335 'viper-mouse-click-search-word))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
336 (and viper-xemacs-p (not (event-over-text-area-p click))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 181
diff changeset
337 () ; do nothing, if binding isn't right or not over text
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
338 (let ((previous-search-string viper-s-string)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
339 click-word click-count)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
341 (if (and
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
342 (viper-multiclick-p)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
343 ;; This trick checks if there is a pending mouse event if so, we use
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
344 ;; this latter event and discard the current mouse click If the next
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
345 ;; pending event is not a mouse event, we execute the current mouse
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
346 ;; event
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
347 (progn
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
348 (viper-read-event)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
349 (viper-mouse-event-p last-input-event)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
350 (progn ; interrupted wait
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
351 (setq viper-global-prefix-argument
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
352 (or viper-global-prefix-argument arg))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
353 ;; remember command that was before the multiclick
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
354 (setq this-command last-command)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
355 ;; make sure we counted this event---needed for XEmacs only
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
356 (viper-event-click-count click))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
357 ;; uninterrupted wait
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
358 (setq click-count (viper-event-click-count click))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
359 (setq click-word (viper-mouse-click-get-word click nil click-count))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
360
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
361 (if (> click-count 1)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
362 (setq arg viper-global-prefix-argument
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
363 viper-global-prefix-argument nil))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
364 (setq arg (or arg 1))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
365
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
366 (viper-deactivate-mark)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
367 (if (or (not (string= click-word viper-s-string))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
368 (not (markerp viper-search-start-marker))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
369 (not (equal (marker-buffer viper-search-start-marker)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
370 (current-buffer)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
371 (not (eq last-command 'viper-mouse-click-search-word)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (progn
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
373 (setq viper-search-start-marker (point-marker)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
374 viper-local-search-start-marker viper-search-start-marker
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
375 viper-mouse-click-search-noerror t
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
376 viper-mouse-click-search-limit nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
377
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
378 ;; make search string known to Viper
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
379 (setq viper-s-string (if viper-re-search
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
380 (regexp-quote click-word)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
381 click-word))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
382 (if (not (string= viper-s-string (car viper-search-history)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
383 (setq viper-search-history
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
384 (cons viper-s-string viper-search-history)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
385 ))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
386
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
387 (push-mark nil t)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
388 (while (> arg 0)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
389 (viper-forward-word 1)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
390 (condition-case nil
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
391 (progn
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
392 (if (not (search-forward
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
393 click-word viper-mouse-click-search-limit
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
394 viper-mouse-click-search-noerror))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
395 (progn
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
396 (setq viper-mouse-click-search-noerror nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
397 (setq viper-mouse-click-search-limit
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
398 (save-excursion
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
399 (if (and
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
400 (markerp viper-local-search-start-marker)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
401 (marker-buffer viper-local-search-start-marker))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
402 (goto-char viper-local-search-start-marker))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
403 (viper-line-pos 'end)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
404
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
405 (goto-char (point-min))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
406 (search-forward click-word
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
407 viper-mouse-click-search-limit nil)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
408 (goto-char (match-beginning 0))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
409 (message "Searching for: %s" viper-s-string)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
410 (if (<= arg 1) ; found the right occurrence of the pattern
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
411 (progn
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
412 (viper-adjust-window)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
413 (viper-flash-search-pattern)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
414 )
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
415 (error (beep 1)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
416 (if (or (not (string= click-word previous-search-string))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
417 (not (eq last-command 'viper-mouse-click-search-word)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
418 (message "`%s': String not found in %s"
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
419 viper-s-string (buffer-name (current-buffer)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
420 (message
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
421 "`%s': Last occurrence in %s. Back to beginning of search"
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
422 click-word (buffer-name (current-buffer)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
423 (setq arg 1) ;; to terminate the loop
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
424 (sit-for 2))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
425 (setq viper-mouse-click-search-noerror t)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
426 (setq viper-mouse-click-search-limit nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
427 (if (and (markerp viper-local-search-start-marker)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
428 (marker-buffer viper-local-search-start-marker))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
429 (goto-char viper-local-search-start-marker))))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
430 (setq arg (1- arg)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
431 ))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
433 (defun viper-mouse-catch-frame-switch (event arg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 "Catch the event of switching frame.
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
435 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
436 bindings in the Viper manual."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (interactive "e\nP")
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
438 (setq viper-frame-of-focus nil)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
439 ;; pass prefix arg along to viper-mouse-click-search/insert-word
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (setq prefix-arg arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if (eq last-command 'handle-switch-frame)
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
442 (setq viper-frame-of-focus viper-current-frame-saved))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
443 ;; make Emacs forget that it executed viper-mouse-catch-frame-switch
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq this-command last-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; Called just before switching frames. Saves the old selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; Sets last-command to handle-switch-frame (this is done automatically in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;; The semantics of switching frames is different in Emacs and XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; 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
451 ;; start typing, input goes to frame B, which becomes selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; 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
453 ;; Emacsen, but also may be a design decision.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; Also, in Emacs sending input to frame B generates handle-switch-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; event, while in XEmacs it doesn't.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;; All this accounts for the difference in the behavior of
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
457 ;; viper-mouse-click-* commands when you click in a frame other than the one
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; that was the last to receive input. In Emacs, focus will be in frame A
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
459 ;; until you do something other than viper-mouse-click-* command.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; 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
461 ;; order to shift focus to frame B.
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
462 (defsubst viper-remember-current-frame (frame)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (setq last-command 'handle-switch-frame
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
464 viper-current-frame-saved (selected-frame)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
465
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
466
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
467 ;; The key is of the form (MODIFIER ... BUTTON-NUMBER)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
468 ;; Converts into a valid mouse button spec for the appropriate version of
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
469 ;; Emacs. EVENT-TYPE is either `up' or `down'. Up returns button-up key; down
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
470 ;; returns button-down key.
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
471 (defun viper-parse-mouse-key (key-var event-type)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
472 (let ((key (eval key-var))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
473 button-spec meta-spec shift-spec control-spec key-spec)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
474 (if (null key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
475 ;; just return nil
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
476 ()
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
477 (setq button-spec
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
478 (cond ((memq 1 key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
479 (if viper-emacs-p
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
480 (if (eq 'up event-type)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
481 "mouse-1" "down-mouse-1")
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
482 (if (eq 'up event-type)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
483 'button1up 'button1)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
484 ((memq 2 key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
485 (if viper-emacs-p
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
486 (if (eq 'up event-type)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
487 "mouse-2" "down-mouse-2")
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
488 (if (eq 'up event-type)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
489 'button2up 'button2)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
490 ((memq 3 key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
491 (if viper-emacs-p
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
492 (if (eq 'up event-type)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
493 "mouse-3" "down-mouse-3")
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
494 (if (eq 'up event-type)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
495 'button3up 'button3)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
496 (t (error
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
497 "%S: invalid button number, %S" key-var key)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
498 meta-spec
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
499 (if (memq 'meta key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
500 (if viper-emacs-p "M-" 'meta)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
501 (if viper-emacs-p "" nil))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
502 shift-spec
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
503 (if (memq 'shift key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
504 (if viper-emacs-p "S-" 'shift)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
505 (if viper-emacs-p "" nil))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
506 control-spec
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
507 (if (memq 'control key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
508 (if viper-emacs-p "C-" 'control)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
509 (if viper-emacs-p "" nil)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
510
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
511 (setq key-spec (if viper-emacs-p
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
512 (vector
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
513 (intern
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
514 (concat
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
515 control-spec meta-spec shift-spec button-spec)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
516 (vector
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
517 (delq
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
518 nil
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
519 (list
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
520 control-spec meta-spec shift-spec button-spec)))))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
521 )))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
522
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
523 (defun viper-unbind-mouse-search-key ()
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
524 (if viper-mouse-up-search-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
525 (global-unset-key viper-mouse-up-search-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
526 (if viper-mouse-down-search-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
527 (global-unset-key viper-mouse-down-search-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
528 (setq viper-mouse-up-search-key-parsed nil
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
529 viper-mouse-down-search-key-parsed nil))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
530
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
531 (defun viper-unbind-mouse-insert-key ()
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
532 (if viper-mouse-up-insert-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
533 (global-unset-key viper-mouse-up-insert-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
534 (if viper-mouse-down-insert-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
535 (global-unset-key viper-mouse-down-insert-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
536 (setq viper-mouse-up-insert-key-parsed nil
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
537 viper-mouse-down-insert-key-parsed nil))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
538
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
539 ;; If FORCE, bind even if this mouse action is already bound to something else
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
540 (defun viper-bind-mouse-search-key (&optional force)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
541 (setq viper-mouse-up-search-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
542 (viper-parse-mouse-key 'viper-mouse-search-key 'up)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
543 viper-mouse-down-search-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
544 (viper-parse-mouse-key 'viper-mouse-search-key 'down))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
545 (cond ((or (null viper-mouse-up-search-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
546 (null viper-mouse-down-search-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
547 nil) ; just quit
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
548 ((and (null force)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
549 (key-binding viper-mouse-up-search-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
550 (not (eq (key-binding viper-mouse-up-search-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
551 'viper-mouse-click-search-word)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
552 (message
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
553 "%S already bound to a mouse event. Viper mouse-search feature disabled"
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
554 viper-mouse-up-search-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
555 ((and (null force)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
556 (key-binding viper-mouse-down-search-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
557 (not (eq (key-binding viper-mouse-down-search-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
558 'viper-mouse-catch-frame-switch)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
559 (message
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
560 "%S already bound to a mouse event. Viper mouse-search feature disabled"
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
561 viper-mouse-down-search-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
562 (t
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
563 (global-set-key viper-mouse-up-search-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
564 'viper-mouse-click-search-word)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
565 (global-set-key viper-mouse-down-search-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
566 'viper-mouse-catch-frame-switch))))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
567
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
568 ;; If FORCE, bind even if this mouse action is already bound to something else
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
569 (defun viper-bind-mouse-insert-key (&optional force)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
570 (setq viper-mouse-up-insert-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
571 (viper-parse-mouse-key 'viper-mouse-insert-key 'up)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
572 viper-mouse-down-insert-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
573 (viper-parse-mouse-key 'viper-mouse-insert-key 'down))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
574 (cond ((or (null viper-mouse-up-insert-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
575 (null viper-mouse-down-insert-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
576 nil) ; just quit
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
577 ((and (null force)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
578 (key-binding viper-mouse-up-insert-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
579 (not (eq (key-binding viper-mouse-up-insert-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
580 'viper-mouse-click-insert-word)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
581 (message
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
582 "%S already bound to a mouse event. Viper mouse-insert feature disabled"
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
583 viper-mouse-up-insert-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
584 ((and (null force)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
585 (key-binding viper-mouse-down-insert-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
586 (not (eq (key-binding viper-mouse-down-insert-key-parsed)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
587 'viper-mouse-catch-frame-switch)))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
588 (message
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
589 "%S already bound to a mouse event. Viper mouse-insert feature disabled"
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
590 viper-mouse-down-insert-key-parsed))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
591 (t
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
592 (global-set-key viper-mouse-up-insert-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
593 'viper-mouse-click-insert-word)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
594 (global-set-key viper-mouse-down-insert-key-parsed
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
595 'viper-mouse-catch-frame-switch))))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
596
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
597 (defun viper-reset-mouse-search-key (symb val)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
598 (viper-unbind-mouse-search-key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
599 (set symb val)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
600 (viper-bind-mouse-search-key 'force))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
601
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
602 (defun viper-reset-mouse-insert-key (symb val)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
603 (viper-unbind-mouse-insert-key)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
604 (set symb val)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
605 (viper-bind-mouse-insert-key 'force))
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
606
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
607
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
608 (defcustom viper-mouse-search-key '(meta shift 1)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
609 "*Key used to click-search in Viper.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
610 This must be a list that specifies the mouse button and modifiers.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
611 The supported modifiers are `meta', `shift', and `control'.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
612 For instance, `(meta shift 1)' means that holding the meta and shift
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
613 keys down and clicking on a word with mouse button 1
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
614 will search for that word in the buffer that was current before the click.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
615 This buffer may be different from the one where the click occurred."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
616 :type '(list (set :inline t :tag "Modifiers" :format "%t: %v"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
617 (const :format "%v " meta)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
618 (const :format "%v " shift)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
619 (const control))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
620 (integer :tag "Button"))
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
621 :set 'viper-reset-mouse-search-key
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
622 :group 'viper-mouse)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
623
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
624 (defcustom viper-mouse-insert-key '(meta shift 2)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
625 "*Key used to click-insert in Viper.
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
626 Must be a list that specifies the mouse button and modifiers.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
627 The supported modifiers are `meta', `shift', and `control'.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
628 For instance, `(meta shift 2)' means that holding the meta and shift keys
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
629 down, and clicking on a word with mouse button 2, will insert that word
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
630 at the cursor in the buffer that was current just before the click.
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
631 This buffer may be different from the one where the click occurred."
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
632 :type '(list (set :inline t :tag "Modifiers" :format "%t: %v"
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
633 (const :format "%v " meta)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
634 (const :format "%v " shift)
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
635 (const control))
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 185
diff changeset
636 (integer :tag "Button"))
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
637 :set 'viper-reset-mouse-insert-key
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
638 :group 'viper-mouse)
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
639
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
642 ;;; Local Variables:
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 175
diff changeset
643 ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
644 ;;; End:
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
645
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;;; viper-mous.el ends here