annotate lisp/emulation/viper-mous.el @ 92409:8171649adf8a

(Quniscribe, QCformat): New symbols. (syms_of_w32font): Define them. (w32font_has_char): Indicate uncertainty. (w32font_encode_char): Encode as glyph point. Make static. (recompute_cached_metrics): New function. (w32font_open_internal): Use it. Set font to use glyph points initially. Set format based on type of font. (w32font_text_extents, w32font_draw): Optionally use glyph points. (w32_enumfont_pattern_entity): Accept backend arg. Set type based on it. Set format based on information available here. (add_font_entity_to_list): Identify backend based on opentype_only.
author Jason Rumney <jasonr@gnu.org>
date Mon, 03 Mar 2008 00:31:18 +0000
parents 7a6035a7126b
children 34417c118a39
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13212
diff changeset
1 ;;; viper-mous.el --- mouse support for Viper
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13212
diff changeset
2
64701
34bd8e434dd7 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64215
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 2001, 2002, 2003, 2004,
79705
d6d821e3ae21 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78218
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
11288
d1f620273acb Add copyright.
Karl Heuer <kwzh@gnu.org>
parents: 10789
diff changeset
5
42602
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 39215
diff changeset
6 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
39215
8dccf2552307 2001-09-09 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 38414
diff changeset
7
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
78218
ac0efac52065 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 64034
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 64034
diff changeset
23 ;; Boston, MA 02110-1301, USA.
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 26263
diff changeset
25 ;;; Commentary:
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 26263
diff changeset
26
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 26263
diff changeset
27 ;;; Code:
14909
7ff1df13b124 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14586
diff changeset
28
18047
1b06411ccc04 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16766
diff changeset
29 (provide 'viper-mous)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30
14909
7ff1df13b124 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14586
diff changeset
31 ;; compiler pacifier
7ff1df13b124 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14586
diff changeset
32 (defvar double-click-time)
7ff1df13b124 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14586
diff changeset
33 (defvar mouse-track-multi-click-time)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
34 (defvar viper-search-start-marker)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
35 (defvar viper-local-search-start-marker)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
36 (defvar viper-search-history)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
37 (defvar viper-s-string)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
38 (defvar viper-re-search)
18047
1b06411ccc04 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16766
diff changeset
39
18172
e145ccc61a22 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18129
diff changeset
40 ;; loading happens only in non-interactive compilation
e145ccc61a22 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18129
diff changeset
41 ;; in order to spare non-viperized emacs from being viperized
e145ccc61a22 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18129
diff changeset
42 (if noninteractive
e145ccc61a22 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18129
diff changeset
43 (eval-when-compile
e145ccc61a22 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18129
diff changeset
44 (let ((load-path (cons (expand-file-name ".") load-path)))
e145ccc61a22 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18129
diff changeset
45 (or (featurep 'viper-cmd)
86523
a5a206b3f518 Load viper*.el files silently.
Glenn Morris <rgm@gnu.org>
parents: 85972
diff changeset
46 (load "viper-cmd.el" nil t 'nosuffix))
18172
e145ccc61a22 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18129
diff changeset
47 )))
18047
1b06411ccc04 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16766
diff changeset
48 ;; end pacifier
1b06411ccc04 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16766
diff changeset
49
1b06411ccc04 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16766
diff changeset
50 (require 'viper-util)
1b06411ccc04 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16766
diff changeset
51
14909
7ff1df13b124 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14586
diff changeset
52
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
53 (defgroup viper-mouse nil
64034
f1afe84c7bbc (viper-mouse): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
54 "Support for Viper special mouse-bound commands."
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
55 :prefix "viper-"
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
56 :group 'viper)
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
57
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 ;;; Variables
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
60
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 ;; Variable used for catching the switch-frame event.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 ;; If non-nil, indicates that previous-frame should be the selected
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
63 ;; one. Used by viper-mouse-click-get-word. Not a user option.
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
64 (defvar viper-frame-of-focus nil)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
65
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 ;; Frame that was selected before the switch-frame event.
64215
a4c59075cac8 * viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 64085
diff changeset
67 (defvar viper-current-frame-saved (selected-frame))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
68
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
69 (defcustom viper-surrounding-word-function 'viper-surrounding-word
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 "*Function that determines what constitutes a word for clicking events.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
71 Takes two parameters: a COUNT, indicating how many words to return,
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 and CLICK-COUNT, telling whether this is the first click, a double-click,
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
73 or a tripple-click."
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
74 :type 'symbol
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
75 :group 'viper-mouse)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
76
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 ;; time interval in millisecond within which successive clicks are
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 ;; considered related
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
79 (defcustom viper-multiclick-timeout (if (viper-window-display-p)
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
80 (if (featurep 'xemacs)
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
81 mouse-track-multi-click-time
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
82 double-click-time)
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
83 500)
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
84 "*Time interval in millisecond within which successive mouse clicks are
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
85 considered related."
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
86 :type 'integer
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
87 :group 'viper-mouse)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 ;; current event click count; XEmacs only
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
90 (defvar viper-current-click-count 0)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 ;; time stamp of the last click event; XEmacs only
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
92 (defvar viper-last-click-event-timestamp 0)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 ;; Local variable used to toggle wraparound search on click.
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
95 (viper-deflocalvar viper-mouse-click-search-noerror t)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
96
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 ;; Local variable used to delimit search after wraparound.
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
98 (viper-deflocalvar viper-mouse-click-search-limit nil)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
99
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 ;; remembers prefix argument to pass along to commands invoked by second
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 ;; click.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 ;; This is needed because in Emacs (not XEmacs), assigning to preix-arg
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 ;; causes Emacs to count the second click as if it was a single click
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
104 (defvar viper-global-prefix-argument nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
105
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
106
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
107 ;; same keys, but parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
108 (defvar viper-mouse-up-search-key-parsed nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
109 (defvar viper-mouse-down-search-key-parsed nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
110 (defvar viper-mouse-up-insert-key-parsed nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
111 (defvar viper-mouse-down-insert-key-parsed nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
112
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 ;;; Code
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
118 (defsubst viper-multiclick-p ()
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
119 (not (viper-sit-for-short viper-multiclick-timeout t)))
14384
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
120
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
121 ;; Returns window where click occurs
20206
f44ff2c52fac new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19942
diff changeset
122 (defun viper-mouse-click-window (click)
92375
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
123 (let ((win (if (featurep 'xemacs) (event-window click)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
124 (posn-window (event-start click)))))
20206
f44ff2c52fac new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19942
diff changeset
125 (if (window-live-p win)
f44ff2c52fac new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19942
diff changeset
126 win
f44ff2c52fac new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19942
diff changeset
127 (error "Click was not over a live window"))))
14384
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
128
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
129 ;; Returns window where click occurs
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
130 (defsubst viper-mouse-click-frame (click)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
131 (window-frame (viper-mouse-click-window click)))
14384
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
132
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
133 ;; Returns the buffer of the window where click occurs
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
134 (defsubst viper-mouse-click-window-buffer (click)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
135 (window-buffer (viper-mouse-click-window click)))
14384
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
136
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
137 ;; Returns the name of the buffer in the window where click occurs
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
138 (defsubst viper-mouse-click-window-buffer-name (click)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
139 (buffer-name (viper-mouse-click-window-buffer click)))
14384
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
140
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
141 ;; Returns position of a click
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
142 (defsubst viper-mouse-click-posn (click)
92375
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
143 (if (featurep 'xemacs) (event-point click)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
144 (posn-point (event-start click))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
145
14384
854325337547 Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14233
diff changeset
146
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
147 (defun viper-surrounding-word (count click-count)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 "Returns word surrounding point according to a heuristic.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 COUNT indicates how many regions to return.
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
150 If CLICK-COUNT is 1, `word' is a word in Vi sense.
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
151 If CLICK-COUNT is 2,then `word' is a Word in Vi sense.
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 If the character clicked on is a non-separator and is non-alphanumeric but
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 is adjacent to an alphanumeric symbol, then it is considered alphanumeric
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
154 for the purpose of this command. If this character has a matching
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 character, such as `\(' is a match for `\)', then the matching character is
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 also considered alphanumeric.
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
157 For convenience, in Lisp modes, `-' is considered alphanumeric.
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
158
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
159 If CLICK-COUNT is 3 or more, returns the line clicked on with leading and
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
160 trailing space and tabs removed. In that case, the first argument, COUNT,
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
161 is ignored."
22285
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
162 (let ((modifiers "_")
12898
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
163 beg skip-flag result
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
164 word-beg)
12898
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
165 (if (> click-count 2)
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
166 (save-excursion
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
167 (beginning-of-line)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
168 (viper-skip-all-separators-forward 'within-line)
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
169 (setq beg (point))
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
170 (end-of-line)
12898
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
171 (setq result (buffer-substring beg (point))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
172
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
173 (if (and (not (viper-looking-at-alphasep))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
174 (or (save-excursion (viper-backward-char-carefully)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
175 (viper-looking-at-alpha))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
176 (save-excursion (viper-forward-char-carefully)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
177 (viper-looking-at-alpha))))
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
178 (setq modifiers
22285
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
179 (concat modifiers
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
180 (cond ((looking-at "\\\\") "\\\\")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
181 ((looking-at "-") "C-C-")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
182 ((looking-at "[][]") "][")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
183 ((looking-at "[()]") ")(")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
184 ((looking-at "[{}]") "{}")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
185 ((looking-at "[<>]") "<>")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
186 ((looking-at "[`']") "`'")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
187 ((looking-at "\\^") "\\^")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
188 ((viper-looking-at-separator) "")
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
189 (t (char-to-string (following-char))))
2e952bf93040 (viper-surrounding-word): Added '_' to alpha modifiers.
Karl Heuer <kwzh@gnu.org>
parents: 20206
diff changeset
190 )
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
191 ))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
192
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
193 ;; Add `-' to alphanum, if it wasn't added and if we are in Lisp
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
194 (or (looking-at "-")
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
195 (not (string-match "lisp" (symbol-name major-mode)))
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
196 (setq modifiers (concat modifiers "C-C-")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
197
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
198
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
199 (save-excursion
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
200 (cond ((> click-count 1) (viper-skip-nonseparators 'backward))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
201 ((viper-looking-at-alpha modifiers)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
202 (viper-skip-alpha-backward modifiers))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
203 ((not (viper-looking-at-alphasep modifiers))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
204 (viper-skip-nonalphasep-backward))
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
205 (t (if (> click-count 1)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
206 (viper-skip-nonseparators 'backward)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
207 (viper-skip-alpha-backward modifiers))))
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
208
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
209 (setq word-beg (point))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
210
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
211 (setq skip-flag nil) ; don't move 1 char forw the first time
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
212 (while (> count 0)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
213 (if skip-flag (viper-forward-char-carefully 1))
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
214 (setq skip-flag t) ; now always move 1 char forward
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
215 (if (> click-count 1)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
216 (viper-skip-nonseparators 'forward)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
217 (viper-skip-alpha-forward modifiers))
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
218 (setq count (1- count)))
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
219
12898
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
220 (setq result (buffer-substring word-beg (point))))
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
221 ) ; if
13212
73b3decace33 * viper-mous.el (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12898
diff changeset
222 ;; XEmacs doesn't have set-text-properties, but there buffer-substring
12898
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
223 ;; doesn't return properties together with the string, so it's not needed.
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
224 (if (featurep 'emacs)
12898
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
225 (set-text-properties 0 (length result) nil result))
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
226 result
e5d4ba91148f (vip-surrounding-word): modified to understand tripple clicks.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12694
diff changeset
227 ))
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
230 (defun viper-mouse-click-get-word (click count click-count)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231 "Returns word surrounding the position of a mouse click.
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
232 Click may be in another window. Current window and buffer isn't changed.
12694
9dedaee6ee1c (vip-multiclick-timeout): new default.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 12140
diff changeset
233 On single or double click, returns the word as determined by
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
234 `viper-surrounding-word-function'."
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
235
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236 (let ((click-word "")
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
237 (click-pos (viper-mouse-click-posn click))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
238 (click-buf (viper-mouse-click-window-buffer click)))
15480
43a3308fcf61 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14909
diff changeset
239 (or (natnump count) (setq count 1))
43a3308fcf61 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14909
diff changeset
240 (or (natnump click-count) (setq click-count 1))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
241
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242 (save-excursion
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 (save-window-excursion
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 (if click-pos
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245 (progn
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 (set-buffer click-buf)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
247
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 (goto-char click-pos)
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 (setq click-word
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
250 (funcall viper-surrounding-word-function count click-count)))
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 26263
diff changeset
251 (error "Click must be over a window"))
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252 click-word))))
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
255 (defun viper-mouse-click-insert-word (click arg)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256 "Insert word clicked or double-clicked on.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 With prefix argument, N, insert that many words.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258 This command must be bound to a mouse click.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259 The double-click action of the same mouse button must not be bound
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
260 \(or it must be bound to the same function\).
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
261 See `viper-surrounding-word' for the definition of a word in this case."
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262 (interactive "e\nP")
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
263 (if viper-frame-of-focus ;; to handle clicks in another frame
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
264 (select-frame viper-frame-of-focus))
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
265 (if (save-excursion
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
266 (or (not (eq (key-binding viper-mouse-down-insert-key-parsed)
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
267 'viper-mouse-catch-frame-switch))
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
268 (not (eq (key-binding viper-mouse-up-insert-key-parsed)
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
269 'viper-mouse-click-insert-word))
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
270 (and (featurep 'xemacs) (not (event-over-text-area-p click)))))
19756
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
271 () ; do nothing, if binding isn't right or not over text
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
272 ;; turn arg into a number
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
273 (cond ((integerp arg) nil)
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
274 ;; prefix arg is a list when one hits C-u then command
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
275 ((and (listp arg) (integerp (car arg)))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
276 (setq arg (car arg)))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
277 (t (setq arg 1)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
278
19756
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
279 (if (not (eq (key-binding viper-mouse-down-insert-key-parsed)
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
280 'viper-mouse-catch-frame-switch))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
281 () ; do nothing
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
282 (let (click-count interrupting-event)
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
283 (if (and
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
284 (viper-multiclick-p)
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
285 ;; This trick checks if there is a pending mouse event if so, we
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
286 ;; use this latter event and discard the current mouse click If
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
287 ;; the next pending event is not a mouse event, we execute the
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
288 ;; current mouse event
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
289 (progn
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
290 (setq interrupting-event (viper-read-event))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
291 (viper-mouse-event-p last-input-event)))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
292 (progn ; interrupted wait
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
293 (setq viper-global-prefix-argument arg)
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
294 ;; count this click for XEmacs
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
295 (viper-event-click-count click))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
296 ;; uninterrupted wait or the interrupting event wasn't a mouse event
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
297 (setq click-count (viper-event-click-count click))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
298 (if (> click-count 1)
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
299 (setq arg viper-global-prefix-argument
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
300 viper-global-prefix-argument nil))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
301 (insert (viper-mouse-click-get-word click arg click-count))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
302 (if (and interrupting-event
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
303 (eventp interrupting-event)
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
304 (not (viper-mouse-event-p interrupting-event)))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
305 (viper-set-unread-command-events interrupting-event))
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
306 )))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
307
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
308 ;; Arg is an event. Accepts symbols and numbers, too
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
309 (defun viper-mouse-event-p (event)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 (if (eventp event)
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 (string-match "\\(mouse-\\|frame\\|screen\\|track\\)"
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
312 (prin1-to-string (viper-event-key event)))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
313
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
314 ;; XEmacs has no double-click events. So, we must simulate.
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 ;; So, we have to simulate event-click-count.
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
316 (defun viper-event-click-count (click)
92375
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
317 (if (featurep 'xemacs) (viper-event-click-count-xemacs click)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
318 (event-click-count click)))
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
319
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
320 (when (featurep 'xemacs)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
321
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
322 ;; kind of semaphore for updating viper-current-click-count
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
323 (defvar viper-counting-clicks-p nil)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
324
92375
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
325 (defun viper-event-click-count-xemacs (click)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
326 (let ((time-delta (- (event-timestamp click)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
327 viper-last-click-event-timestamp))
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
328 inhibit-quit)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
329 (while viper-counting-clicks-p
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
330 (ignore))
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
331 (setq viper-counting-clicks-p t)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
332 (if (> time-delta viper-multiclick-timeout)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
333 (setq viper-current-click-count 0))
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
334 (discard-input)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
335 (setq viper-current-click-count (1+ viper-current-click-count)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
336 viper-last-click-event-timestamp (event-timestamp click))
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
337 (setq viper-counting-clicks-p nil)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
338 (if (viper-sit-for-short viper-multiclick-timeout t)
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
339 viper-current-click-count
7a6035a7126b Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
340 0))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
341
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
343 (defun viper-mouse-click-search-word (click arg)
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
344 "Find the word clicked or double-clicked on. Word may be in another window.
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 With prefix argument, N, search for N-th occurrence.
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
346 This command must be bound to a mouse click. The double-click action of the
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 same button must not be bound \(or it must be bound to the same function\).
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
348 See `viper-surrounding-word' for the details on what constitutes a word for
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 this command."
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 (interactive "e\nP")
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
351 (if viper-frame-of-focus ;; to handle clicks in another frame
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
352 (select-frame viper-frame-of-focus))
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
353 (if (save-excursion
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
354 (or (not (eq (key-binding viper-mouse-down-search-key-parsed)
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
355 'viper-mouse-catch-frame-switch))
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
356 (not (eq (key-binding viper-mouse-up-search-key-parsed)
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
357 'viper-mouse-click-search-word))
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
358 (and (featurep 'xemacs) (not (event-over-text-area-p click)))))
19756
22c1e47f66e1 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19203
diff changeset
359 () ; do nothing, if binding isn't right or not over text
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
360 (let ((previous-search-string viper-s-string)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
361 click-word click-count)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
362
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
363 (if (and
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
364 (viper-multiclick-p)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
365 ;; This trick checks if there is a pending mouse event if so, we use
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
366 ;; this latter event and discard the current mouse click If the next
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
367 ;; pending event is not a mouse event, we execute the current mouse
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
368 ;; event
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
369 (progn
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
370 (viper-read-event)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
371 (viper-mouse-event-p last-input-event)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
372 (progn ; interrupted wait
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
373 (setq viper-global-prefix-argument (or viper-global-prefix-argument
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
374 arg)
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
375 ;; remember command that was before the multiclick
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
376 this-command last-command)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
377 ;; make sure we counted this event---needed for XEmacs only
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
378 (viper-event-click-count click))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
379 ;; uninterrupted wait
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
380 (setq click-count (viper-event-click-count click))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
381 (setq click-word (viper-mouse-click-get-word click nil click-count))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
382
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
383 (if (> click-count 1)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
384 (setq arg viper-global-prefix-argument
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
385 viper-global-prefix-argument nil))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
386 (setq arg (or arg 1))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
387
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
388 (viper-deactivate-mark)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
389 (if (or (not (string= click-word viper-s-string))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
390 (not (markerp viper-search-start-marker))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
391 (not (equal (marker-buffer viper-search-start-marker)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
392 (current-buffer)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
393 (not (eq last-command 'viper-mouse-click-search-word)))
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 (progn
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
395 (setq viper-search-start-marker (point-marker)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
396 viper-local-search-start-marker viper-search-start-marker
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
397 viper-mouse-click-search-noerror t
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
398 viper-mouse-click-search-limit nil)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
399
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
400 ;; make search string known to Viper
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
401 (setq viper-s-string (if viper-re-search
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
402 (regexp-quote click-word)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
403 click-word))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
404 (if (not (string= viper-s-string (car viper-search-history)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
405 (setq viper-search-history
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
406 (cons viper-s-string viper-search-history)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
407 ))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
408
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
409 (push-mark nil t)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
410 (while (> arg 0)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
411 (viper-forward-word 1)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
412 (condition-case nil
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
413 (progn
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
414 (if (not (search-forward
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
415 click-word viper-mouse-click-search-limit
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
416 viper-mouse-click-search-noerror))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
417 (progn
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
418 (setq viper-mouse-click-search-noerror nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
419 (setq viper-mouse-click-search-limit
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
420 (save-excursion
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
421 (if (and
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
422 (markerp viper-local-search-start-marker)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
423 (marker-buffer viper-local-search-start-marker))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
424 (goto-char viper-local-search-start-marker))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
425 (viper-line-pos 'end)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
426
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
427 (goto-char (point-min))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
428 (search-forward click-word
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
429 viper-mouse-click-search-limit nil)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
430 (goto-char (match-beginning 0))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
431 (message "Searching for: %s" viper-s-string)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
432 (if (<= arg 1) ; found the right occurrence of the pattern
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
433 (progn
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
434 (viper-adjust-window)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
435 (viper-flash-search-pattern)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
436 )
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
437 (error (beep 1)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
438 (if (or (not (string= click-word previous-search-string))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
439 (not (eq last-command 'viper-mouse-click-search-word)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
440 (message "`%s': String not found in %s"
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
441 viper-s-string (buffer-name (current-buffer)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
442 (message
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
443 "`%s': Last occurrence in %s. Back to beginning of search"
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
444 click-word (buffer-name (current-buffer)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
445 (setq arg 1) ;; to terminate the loop
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
446 (sit-for 2))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
447 (setq viper-mouse-click-search-noerror t)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
448 (setq viper-mouse-click-search-limit nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
449 (if (and (markerp viper-local-search-start-marker)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
450 (marker-buffer viper-local-search-start-marker))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
451 (goto-char viper-local-search-start-marker))))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
452 (setq arg (1- arg)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
453 ))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
454
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
455 (defun viper-mouse-catch-frame-switch (event arg)
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 "Catch the event of switching frame.
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
457 Usually is bound to a `down-mouse' event to work properly. See sample
18129
e92598964ee6 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18047
diff changeset
458 bindings in the Viper manual."
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 (interactive "e\nP")
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
460 (setq viper-frame-of-focus nil)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
461 ;; pass prefix arg along to viper-mouse-click-search/insert-word
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 (setq prefix-arg arg)
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 (if (eq last-command 'handle-switch-frame)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
464 (setq viper-frame-of-focus viper-current-frame-saved))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
465 ;; make Emacs forget that it executed viper-mouse-catch-frame-switch
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 (setq this-command last-command))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
467
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
468 ;; Called just before switching frames. Saves the old selected frame.
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 ;; Sets last-command to handle-switch-frame (this is done automatically in
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
470 ;; Emacs.
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 ;; The semantics of switching frames is different in Emacs and XEmacs.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472 ;; In Emacs, if you select-frame A while mouse is over frame B and then
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 ;; start typing, input goes to frame B, which becomes selected.
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
474 ;; In XEmacs, input will go to frame A. This may be a bug in one of the
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 ;; Emacsen, but also may be a design decision.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 ;; Also, in Emacs sending input to frame B generates handle-switch-frame
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 ;; event, while in XEmacs it doesn't.
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 ;; All this accounts for the difference in the behavior of
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
479 ;; viper-mouse-click-* commands when you click in a frame other than the one
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
480 ;; that was the last to receive input. In Emacs, focus will be in frame A
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
481 ;; until you do something other than viper-mouse-click-* command.
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 ;; In XEmacs, you have to manually select frame B (with the mouse click) in
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 ;; order to shift focus to frame B.
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
484 (defsubst viper-remember-current-frame (frame)
12140
75379a19c5d5 Changed vip-*-frame-* to *-frame-*, incorporated overlay strings,
Karl Heuer <kwzh@gnu.org>
parents: 11288
diff changeset
485 (setq last-command 'handle-switch-frame
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
486 viper-current-frame-saved (selected-frame)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
487
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
488
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
489 ;; The key is of the form (MODIFIER ... BUTTON-NUMBER)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
490 ;; Converts into a valid mouse button spec for the appropriate version of
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
491 ;; Emacs. EVENT-TYPE is either `up' or `down'. Up returns button-up key; down
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
492 ;; returns button-down key.
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
493 (defun viper-parse-mouse-key (key-var event-type)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
494 (let ((key (eval key-var))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
495 button-spec meta-spec shift-spec control-spec key-spec)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
496 (if (null key)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
497 ;; just return nil
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
498 ()
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
499 (setq button-spec
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
500 (cond ((memq 1 key)
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
501 (if (featurep 'emacs)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
502 (if (eq 'up event-type)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
503 "mouse-1" "down-mouse-1")
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
504 (if (eq 'up event-type)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
505 'button1up 'button1)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
506 ((memq 2 key)
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
507 (if (featurep 'emacs)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
508 (if (eq 'up event-type)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
509 "mouse-2" "down-mouse-2")
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
510 (if (eq 'up event-type)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
511 'button2up 'button2)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
512 ((memq 3 key)
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
513 (if (featurep 'emacs)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
514 (if (eq 'up event-type)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
515 "mouse-3" "down-mouse-3")
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
516 (if (eq 'up event-type)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
517 'button3up 'button3)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
518 (t (error
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
519 "%S: invalid button number, %S" key-var key)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
520 meta-spec
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
521 (if (memq 'meta key)
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
522 (if (featurep 'emacs) "M-" 'meta)
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
523 (if (featurep 'emacs) "" nil))
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
524 shift-spec
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
525 (if (memq 'shift key)
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
526 (if (featurep 'emacs) "S-" 'shift)
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
527 (if (featurep 'emacs) "" nil))
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
528 control-spec
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
529 (if (memq 'control key)
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
530 (if (featurep 'emacs) "C-" 'control)
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
531 (if (featurep 'emacs) "" nil)))
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
532
85972
51aa47312c4b * ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78218
diff changeset
533 (setq key-spec (if (featurep 'emacs)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
534 (vector
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
535 (intern
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
536 (concat
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
537 control-spec meta-spec shift-spec button-spec)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
538 (vector
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
539 (delq
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
540 nil
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
541 (list
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
542 control-spec meta-spec shift-spec button-spec)))))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
543 )))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
544
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
545 (defun viper-unbind-mouse-search-key ()
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
546 (if viper-mouse-up-search-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
547 (global-unset-key viper-mouse-up-search-key-parsed))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
548 (if viper-mouse-down-search-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
549 (global-unset-key viper-mouse-down-search-key-parsed))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
550 (setq viper-mouse-up-search-key-parsed nil
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
551 viper-mouse-down-search-key-parsed nil))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
552
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
553 (defun viper-unbind-mouse-insert-key ()
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
554 (if viper-mouse-up-insert-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
555 (global-unset-key viper-mouse-up-insert-key-parsed))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
556 (if viper-mouse-down-insert-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
557 (global-unset-key viper-mouse-down-insert-key-parsed))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
558 (setq viper-mouse-up-insert-key-parsed nil
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
559 viper-mouse-down-insert-key-parsed nil))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
560
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
561 ;; If FORCE, bind even if this mouse action is already bound to something else
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
562 (defun viper-bind-mouse-search-key (&optional force)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
563 (setq viper-mouse-up-search-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
564 (viper-parse-mouse-key 'viper-mouse-search-key 'up)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
565 viper-mouse-down-search-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
566 (viper-parse-mouse-key 'viper-mouse-search-key 'down))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
567 (cond ((or (null viper-mouse-up-search-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
568 (null viper-mouse-down-search-key-parsed))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
569 nil) ; just quit
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
570 ((and (null force)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
571 (key-binding viper-mouse-up-search-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
572 (not (eq (key-binding viper-mouse-up-search-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
573 'viper-mouse-click-search-word)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
574 (message
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
575 "%S already bound to a mouse event. Viper mouse-search feature disabled"
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
576 viper-mouse-up-search-key-parsed))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
577 ((and (null force)
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
578 (key-binding viper-mouse-down-search-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
579 (not (eq (key-binding viper-mouse-down-search-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
580 'viper-mouse-catch-frame-switch)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
581 (message
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
582 "%S already bound to a mouse event. Viper mouse-search feature disabled"
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
583 viper-mouse-down-search-key-parsed))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
584 (t
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
585 (global-set-key viper-mouse-up-search-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
586 'viper-mouse-click-search-word)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
587 (global-set-key viper-mouse-down-search-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
588 'viper-mouse-catch-frame-switch))))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
589
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
590 ;; If FORCE, bind even if this mouse action is already bound to something else
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
591 (defun viper-bind-mouse-insert-key (&optional force)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
592 (setq viper-mouse-up-insert-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
593 (viper-parse-mouse-key 'viper-mouse-insert-key 'up)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
594 viper-mouse-down-insert-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
595 (viper-parse-mouse-key 'viper-mouse-insert-key 'down))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
596 (cond ((or (null viper-mouse-up-insert-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
597 (null viper-mouse-down-insert-key-parsed))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
598 nil) ; just quit
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
599 ((and (null force)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
600 (key-binding viper-mouse-up-insert-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
601 (not (eq (key-binding viper-mouse-up-insert-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
602 'viper-mouse-click-insert-word)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
603 (message
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
604 "%S already bound to a mouse event. Viper mouse-insert feature disabled"
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
605 viper-mouse-up-insert-key-parsed))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
606 ((and (null force)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
607 (key-binding viper-mouse-down-insert-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
608 (not (eq (key-binding viper-mouse-down-insert-key-parsed)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
609 'viper-mouse-catch-frame-switch)))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
610 (message
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 22285
diff changeset
611 "%S already bound to a mouse event. Viper mouse-insert feature disabled"
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
612 viper-mouse-down-insert-key-parsed))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
613 (t
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
614 (global-set-key viper-mouse-up-insert-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
615 'viper-mouse-click-insert-word)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
616 (global-set-key viper-mouse-down-insert-key-parsed
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
617 'viper-mouse-catch-frame-switch))))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
618
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
619 (defun viper-reset-mouse-search-key (symb val)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
620 (viper-unbind-mouse-search-key)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
621 (set symb val)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
622 (viper-bind-mouse-search-key 'force))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
623
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
624 (defun viper-reset-mouse-insert-key (symb val)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
625 (viper-unbind-mouse-insert-key)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
626 (set symb val)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
627 (viper-bind-mouse-insert-key 'force))
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
628
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
629
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
630 (defcustom viper-mouse-search-key '(meta shift 1)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
631 "*Key used to click-search in Viper.
19908
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
632 This must be a list that specifies the mouse button and modifiers.
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
633 The supported modifiers are `meta', `shift', and `control'.
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
634 For instance, `(meta shift 1)' means that holding the meta and shift
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
635 keys down and clicking on a word with mouse button 1
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
636 will search for that word in the buffer that was current before the click.
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
637 This buffer may be different from the one where the click occurred."
19942
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
638 :type '(list (set :inline t :tag "Modifiers" :format "%t: %v"
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
639 (const :format "%v " meta)
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
640 (const :format "%v " shift)
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
641 (const control))
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
642 (integer :tag "Button"))
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
643 :set 'viper-reset-mouse-search-key
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
644 :group 'viper-mouse)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
645
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
646 (defcustom viper-mouse-insert-key '(meta shift 2)
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
647 "*Key used to click-insert in Viper.
19908
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
648 Must be a list that specifies the mouse button and modifiers.
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
649 The supported modifiers are `meta', `shift', and `control'.
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
650 For instance, `(meta shift 2)' means that holding the meta and shift keys
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
651 down, and clicking on a word with mouse button 2, will insert that word
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
652 at the cursor in the buffer that was current just before the click.
3a37d4348914 (viper-mouse-search-key, viper-mouse-insert-key): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19756
diff changeset
653 This buffer may be different from the one where the click occurred."
19942
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
654 :type '(list (set :inline t :tag "Modifiers" :format "%t: %v"
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
655 (const :format "%v " meta)
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
656 (const :format "%v " shift)
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
657 (const control))
b960ef5a1ecc (viper-mouse-search-key): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 19908
diff changeset
658 (integer :tag "Button"))
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
659 :set 'viper-reset-mouse-insert-key
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
660 :group 'viper-mouse)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
661
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
662
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
663
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
664 ;;; Local Variables:
19079
dfbef8117c6a new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
665 ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
666 ;;; End:
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18343
diff changeset
667
10789
af7c0bb1059f Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
669 ;;; arch-tag: e56b2390-06c4-4dd1-96f5-c7876e2d8c2f
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 26263
diff changeset
670 ;;; viper-mous.el ends here