annotate lisp/strokes.el @ 19345:eaec3bec7dea

Initial revision
author Richard M. Stallman <rms@gnu.org>
date Thu, 14 Aug 1997 04:51:22 +0000
parents
children bdac48dda163
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19345
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; strokes.el -- Control Emacs through mouse strokes --
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: David Bakhash <cadet@mit.edu>
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Maintainer: David Bakhash <cadet@mit.edu>
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Created: 12 April 1997
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords: lisp, mouse, extensions
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; This is the strokes package. It is intended to allow the user to
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; control Emacs by means of mouse strokes. Once strokes is loaded, you
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; can always get help be invoking `strokes-help':
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; > M-x strokes-help
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; and you can learn how to use the package. A mouse stroke, for now,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; can be defined as holding the middle button, for instance, and then
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; moving the mouse in whatever pattern you wish, which you have set
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; Emacs to understand as mapping to a given command. For example, you
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; may wish the have a mouse stroke that looks like a capital `C' which
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; means `copy-region-as-kill'. Treat strokes just like you do key
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; bindings. For example, Emacs sets key bindings globally with the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; `global-set-key' command. Likewise, you can do
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; > M-x global-set-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; to interactively program in a stroke. It would be wise to set the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; first one to this very command, so that from then on, you invoke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; `global-set-stroke' with a stroke. likewise, there may eventually
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; be a `local-set-stroke' command, also analogous to `local-set-key'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; You can always unset the last stroke definition with the command
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; > M-x strokes-unset-last-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; and the last stroke that was added to `strokes-global-map' will be
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; removed.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; Other analogies between strokes and key bindings are as follows:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; 1) To describe a stroke binding, you can type
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; > M-x describe-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; analogous to `describe-key'. It's also wise to have a stroke,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; like an `h', for help, or a `?', mapped to `describe-stroke'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; 2) stroke bindings are set internally through the Lisp function
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; `define-stroke', similar to the `define-key' function. some
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; examples for a 3x3 stroke grid would be
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; (define-stroke c-mode-stroke-map
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; '((0 . 0) (1 . 1) (2 . 2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; 'kill-region)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; (define-stroke strokes-global-map
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; '((0 . 0) (0 . 1) (0 . 2) (1 . 2) (2 . 2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; 'list-buffers)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; however, if you would probably just have the user enter in the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; stroke interactively and then set the stroke to whatever he/she
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; entered. The Lisp function to interactively read a stroke is
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; `strokes-read-stroke'. This is especially helpful when you're
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; on a fast computer that can handle a 9x9 stroke grid.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; NOTE: only global stroke bindings are currently implemented,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; however mode- and buffer-local stroke bindings may eventually
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; be implemented in a future version.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; The important variables to be aware of for this package are listed
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; below. They can all be altered through the customizing package via
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; > M-x customize
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; and customizing the group named `strokes'. You can also read
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; documentation on the variables there.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; `strokes-minimum-match-score' (determines the threshold of error that
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; makes a stroke acceptable or unacceptable. If your strokes arn't
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;; matching, then you should raise this variable.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; `strokes-grid-resolution' (determines the grid dimensions that you use
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; when defining/reading strokes. The finer the grid your computer can
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; handle, the more you can do, but even a 3x3 grid is pretty cool.)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; The default value (7) should be fine for most decent computers.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; NOTE: This variable should not be set to a number less than 3.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; `strokes-display-strokes-buffer' will allow you to hide the strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; buffer when doing simple strokes. This is a speedup for slow
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; computers as well as people who don't want to see their strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; If you find that your mouse is accelerating too fast, you can
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;; execute the UNIX X command to slow it down. A good possibility is
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; % xset m 5/4 8
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; which seems, heuristically, to work okay, without much disruption.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; Whenever you load in the strokes package, you will be able to save
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; what you've done upon exiting Emacs. You can also do
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; > M-x save-strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; and it will save your strokes in ~/.strokes, or you may wish to change
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; this by setting the variable `strokes-file'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; Note that internally, all of the routines that are part of this
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; package are able to deal with complex strokes, as they are a superset
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; of simple strokes. However, the default of this package will map
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; mouse button2 to the command `strokes-do-stroke', and NOT
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; `strokes-do-complex-stroke'. If you wish to use complex strokes, you
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; will have to override this key mapping. Complex strokes are terminated
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;; with mouse button3. The strokes package will not interfere with
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;; `mouse-yank', but you may want to examine how this is done (see the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; variable `strokes-click-command')
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;; To get strokes to work as part of your your setup, then you'll have
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; put the strokes package in your load-path (preferably byte-compiled)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; and then add the following to your .emacs file (or wherever
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; you put Emacs-specific startup preferences):
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;;(and (fboundp 'device-on-window-system-p)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; (device-on-window-system-p)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;; (require 'strokes))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;; Once loaded, you can start stroking. You can also toggle between
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; strokes mode by simple typing
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;; > M-x strokes-mode
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; I am now in the process of porting this package to Emacs. I also hope
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;; that, with the help of others, this package will be useful in entering
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;; in pictographic-like language text using the mouse (i.e. Korean).
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; Japanese and Chinese are a bit trickier, but I'm sure that with help
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; it can be done. The next version will allow the user to enter strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;; which "remove the pencil from the paper" so to speak, so one character
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;; can have multiple strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; You can read more about strokes at:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ;; http://www.mit.edu/people/cadet/strokes-help.html
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;; If you're interested in using strokes for writing English into Emacs
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; using strokes, then you'll want to read about it on the web page above
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;; or just download from http://www.mit.edu/people/cadet/strokes-abc.el,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;; which is nothing but a file with some helper commands for inserting
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ;; alphanumerics and punctuation.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 ;; Great thanks to Rob Ristroph for his generosity in letting me use his
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 ;; PC to develop this, Jason Johnson for his help in algorithms, Euna
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;; Kim for her help in Korean, and massive thanks to the helpful guys
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;; on the help instance on athena (zeno, jered, amu, gsstark, ghudson, etc)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;; Special thanks to Steve Baur and Hrvoje Niksic for all their help.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ;; And even more thanks to Dave Gillespie for all the elisp help--he
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;; is responsible for helping me use the cl macros at (near) max speed.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ;; Tasks: (what I'm getting ready for future version)...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ;; 2) use 'strokes-read-complex-stroke for korean, etc.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ;; 4) buffer-local 'strokes-local-map, and mode-stroke-maps would be nice
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 ;; 5) 'list-strokes (kinda important). What do people want?
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ;; How about an optional docstring for each stroke so that a person
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ;; can examine the strokes-file and actually make sense of it?
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ;; (e.g. "This stroke is a pentagram")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;; 6) add some hooks, like `strokes-read-stroke-hook'
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; 7) See what people think of the factory settings. Should I change
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;; them? They're all pretty arbitrary in a way. I guess they
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ;; should be minimal, but computers are getting lots faster, and
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ;; if I choose the defaults too conservatively, then strokes will
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;; surely dissapoint some people on decent machines (until they
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;; figure out M-x customize). I need feedback.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ;; Other: I always have the most beta version of strokes, so if you
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ;; want it just let me know.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;;; Code:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ;;; Requirements and provisions...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (autoload 'reporter-submit-bug-report "reporter")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (autoload 'mail-position-on-field "sendmail")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (eval-when-compile
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (mapcar 'require '(pp reporter advice)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (require 'levents)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 ;;; Constants...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defconst strokes-version "0.0-beta")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (defconst strokes-bug-address "cadet@mit.edu")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (defconst strokes-lift 'strokes-lift
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 "Symbol representing a stroke lift event for complex strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 Complex strokes are those which contain two or more simple strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 This will be useful for when Emacs understands Chinese.")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 ;;; user variables...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (defgroup strokes nil
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 "Control Emacs through mouse strokes"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 :group 'mouse)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (defcustom strokes-modeline-string " Strokes"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 "*Modeline identification when strokes are on \(default is \" Strokes\"\)."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 :type 'string
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (defcustom strokes-character ?@
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 "*Character used when drawing strokes in the strokes buffer.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 \(The default is lower-case `o', which works okay\)."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 :type 'character
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (defcustom strokes-minimum-match-score 1000
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 "*Minimum score for a stroke to be considered a possible match.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 Requiring a perfect match would set this variable to 0.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 The default value is 1000, but it's mostly dependent on how precisely
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 you manage to replicate your user-defined strokes. It also depends on
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 the value of `strokes-grid-resolution', since a higher grid resolution
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 will correspond to more sample points, and thus more distance
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 measurements. Usually, this is not a problem since you first set
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 `strokes-grid-resolution' based on what your computer seems to be able
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 to handle (though the defaults are usually more than sufficent), and
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 then you can set `strokes-minimum-match-score' to something that works
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 for you. The only purpose of this variable is to insure that if you
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 do a bogus stroke that really doesn't match any of the predefined
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ones, then strokes should NOT pick the one that came closest."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 :type 'integer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (defcustom strokes-grid-resolution 9
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 "*Integer defining dimensions of the stroke grid.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 The grid is a square grid, where STROKES-GRID-RESOLUTION defaults to
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 `9', making a 9x9 grid whose coordinates go from (0 . 0) on the top
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 left to ((STROKES-GRID-RESOLUTION - 1) . (STROKES-GRID-RESOLUTION - 1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 on the bottom right. The greater the resolution, the more intricate
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 your strokes can be.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 NOTE: This variable should be odd and MUST NOT be less than 3 and need
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 not be greater than 33, which is the resolution of the pixmaps.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 WARNING: Changing the value of this variable will gravely affect the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 strokes you have already programmed in. You should try to
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 figure out what it should be based on your needs and on how
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 quick the particular platform(s) you're operating on, and
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 only then start programming in your custom strokes."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 :type 'integer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (defcustom strokes-file "~/.strokes"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 "*File containing saved strokes for stroke-mode (default is ~/.strokes)."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 :type 'file
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (defcustom strokes-buffer-name " *strokes*"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 "The buffer that the strokes take place in (default is ` *strokes*')."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 :type 'string
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (defcustom strokes-use-strokes-buffer t
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 "*If non-nil, the strokes buffer is used and strokes are displayed.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 If nil, strokes will be read the same, however the user will not be
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 able to see the strokes. This be helpful for people who don't like
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 the delay in switching to the strokes buffer."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 :type 'boolean
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (defcustom strokes-click-command 'mouse-yank-at-click
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 "*Command to execute when stroke is actually a `click' event.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 This is set to `mouse-yank' by default."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 :type 'function
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 :group 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 ;;; internal variables...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (defvar strokes-mode nil
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 "Non-nil when `strokes' is globally enabled")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (defvar strokes-window-configuration nil
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 "The special window configuration used when entering strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 This is set properly in the function `strokes-update-window-configuration'.")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (defvar strokes-last-stroke nil
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 "Last stroke entered by the user.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 Its value gets set every time the function
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 `strokes-fill-stroke' gets called,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 since that is the best time to set the variable")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (defvar strokes-global-map '()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 "Association list of strokes and their definitions.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 Each entry is (STROKE . COMMAND) where STROKE is itself a list of
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 coordinates (X . Y) where X and Y are lists of positions on the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 normalized stroke grid, with the top left at (0 . 0). COMMAND is the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 corresponding interactive function")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (defvar strokes-load-hook nil
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 "Function or functions to be called when `strokes' is loaded.")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ;;; Macros...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (defsubst strokes-click-p (stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 "Non-nil if STROKE is really click."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (< (length stroke) 3))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 ;;; old, but worked pretty good (just in case)...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 ;;(defmacro strokes-define-stroke (stroke-map stroke def)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 ;; "Add STROKE to STROKE-MAP alist with given command DEF"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ;; (list 'if (list '< (list 'length stroke) 3)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ;; (list 'error
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 ;; "That's a click, not a stroke. See `strokes-click-command'")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 ;; (list 'setq stroke-map (list 'cons (list 'cons stroke def)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ;; (list 'remassoc stroke stroke-map)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (defsubst strokes-remassoc (key list)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (remove-if
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (lambda (element)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (equal key (car element)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 list))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (defmacro strokes-define-stroke (stroke-map stroke def)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 "Add STROKE to STROKE-MAP alist with given command DEF."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 `(if (strokes-click-p ,stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (error "That's a click, not a stroke; see `strokes-click-command'")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (setq ,stroke-map (cons (cons ,stroke ,def)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (strokes-remassoc ,stroke ,stroke-map)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (defalias 'define-stroke 'strokes-define-stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (defsubst strokes-square (x)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 "Returns the square of the number X"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (* x x))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (defsubst strokes-distance-squared (p1 p2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 "Gets the distance (squared) between to points P1 and P2.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 P1 and P2 are cons cells in the form (X . Y)."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (let ((x1 (car p1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (y1 (cdr p1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (x2 (car p2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (y2 (cdr p2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (+ (strokes-square (- x2 x1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (strokes-square (- y2 y1)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 ;;; Advice for various functions...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 ;; I'd originally wanted to write a macro that would just take in the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 ;; generic functions which use mouse button2 in various modes. Most of
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 ;; them are identical in form: they take an event as the single argument
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 ;; and then do their thing. I tried writing a macro that looked
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 ;; something like this, but failed. Advice just ain't that easy. The
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 ;; one that bugged me the most was `Manual-follow-xref', because that had
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 ;; &rest arguments, and I didn't know how to work around it in defadvice.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 ;; However, I was able to fix up most of the important modes (i.e. the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 ;; ones I use all the time). One `bug' in the program that I just can't
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 ;; seem to figure out is why I can only advise other button2 functions
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 ;; successfully when the variable `strokes-use-strokes-buffer' is nil. I
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 ;; did all the save-excursion/save-window-excursion stuff SPECIFICALLY so
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 ;; that using the strokes buffer or not would absolutely not affect any
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 ;; other part of the program. If someone can figure out how to make the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 ;; following advices work w/ regardless of that variable
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 ;; `strokes-use-strokes-buffer', then that would be a great victory. If
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ;; someone out there would be kind enough to make the commented code
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 ;; below work, I'd be grateful. By the way, I put the `protect' keywords
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 ;; there to insure that if a stroke went bad, then
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 ;; `strokes-click-command' would be set back. If this isn't necessary,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 ;; then feel free to let me know.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ;; For what follows, I really wanted something that would work like this:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 ;;(strokes-fix-button2 'vm-mouse-button-2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 ;; Or even better, I could have simply done something like:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 ;;(mapcar 'strokes-fix-button2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 ;; '(vm-mouse-button-2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 ;; rmail-summary-mouse-goto-msg
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 ;; <rest of them>))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 ;;; With help from Hans (author of advice.el)...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (defmacro strokes-fix-button2-command (command)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 "Fix COMMAND so that it can also work with strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 COMMAND must take one event argument.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 Example of how one might fix up a command that's bound to button2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 and which is an interactive funcion of one event argument:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 \(strokes-fix-button2-command 'rmail-summary-mouse-goto-msg)"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (let ((command (eval command)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 `(progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (defadvice ,command (around strokes-fix-button2 compile preactivate)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ,(format "Fix %s to work with strokes." command)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (if strokes-use-strokes-buffer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 ;; then strokes is no good and we'll have to use the original
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 ad-do-it
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 ;; otherwise, we can make strokes work too...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (let ((strokes-click-command
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ',(intern (format "ad-Orig-%s" command))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (strokes-do-stroke (ad-get-arg 0))))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (strokes-fix-button2-command 'vm-mouse-button-2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (strokes-fix-button2-command 'rmail-summary-mouse-goto-msg)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (strokes-fix-button2-command 'Buffer-menu-mouse-select)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (strokes-fix-button2-command 'w3-widget-button-click)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (strokes-fix-button2-command 'widget-image-button-press)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (strokes-fix-button2-command 'Info-follow-clicked-node)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (strokes-fix-button2-command 'compile-mouse-goto-error)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (strokes-fix-button2-command 'gdbsrc-select-or-yank)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (strokes-fix-button2-command 'hypropos-mouse-get-doc)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (strokes-fix-button2-command 'gnus-mouse-pick-group)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (strokes-fix-button2-command 'gnus-mouse-pick-article)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (strokes-fix-button2-command 'gnus-article-push-button)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (strokes-fix-button2-command 'dired-mouse-find-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (strokes-fix-button2-command 'url-dired-find-file-mouse)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (strokes-fix-button2-command 'dired-u-r-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (strokes-fix-button2-command 'dired-u-w-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (strokes-fix-button2-command 'dired-u-x-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (strokes-fix-button2-command 'dired-g-r-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (strokes-fix-button2-command 'dired-g-w-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (strokes-fix-button2-command 'dired-g-x-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (strokes-fix-button2-command 'dired-o-r-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (strokes-fix-button2-command 'dired-o-w-mouse-toggle)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (strokes-fix-button2-command 'isearch-yank-x-selection)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (strokes-fix-button2-command 'occur-mode-mouse-goto)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (strokes-fix-button2-command 'cvs-mouse-find-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 ;;; I can fix the customize widget button click, but then
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 ;;; people will get confused when they try to customize
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 ;;; strokes with the mouse and customize tells them that
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 ;;; `strokes-click-command' is mapped to `ad-Orig-widget-button-click'
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;;(strokes-fix-button2-command 'widget-button-click)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 ;;; without the advice, each advised function would look like...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 ;;(defadvice vm-mouse-button-2 (around vm-strokes activate protect)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 ;; "Allow strokes to work in VM."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 ;; (if strokes-use-strokes-buffer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 ;; ;; then strokes is no good and we'll have to use the original
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 ;; ad-do-it
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 ;; ;; otherwise, we can make strokes work too...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 ;; (let ((strokes-click-command 'ad-Orig-vm-mouse-button-2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 ;; (strokes-do-stroke (ad-get-arg 0)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ;;; Functions...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (defsubst strokes-mouse-event-p (event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (or (motion-event-p event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (button-press-event-p event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (button-release-event-p event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (defun strokes-event-closest-point-1 (window &optional line)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 "Return position of start of line LINE in WINDOW.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 If LINE is nil, return the last position visible in WINDOW."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (let* ((total (- (window-height window)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (if (window-minibuffer-p window)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 0 1)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (distance (or line total)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (goto-char (window-start window))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (if (= (vertical-motion distance) distance)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (if (not line)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (forward-char -1)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (point))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (defun strokes-event-closest-point (event &optional start-window)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 "Return the nearest position to where EVENT ended its motion.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 This is computed for the window where EVENT's motion started,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 or for window WINDOW if that is specified."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (or start-window (setq start-window (posn-window (event-start event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (if (eq start-window (posn-window (event-end event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (if (eq (event-point event) 'vertical-line)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (strokes-event-closest-point-1 start-window
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (cdr (posn-col-row (event-end event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (if (eq (event-point event) 'mode-line)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (strokes-event-closest-point-1 start-window)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (event-point event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 ;; EVENT ended in some other window.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (let* ((end-w (posn-window (event-end event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (end-w-top)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (w-top (nth 1 (window-edges start-window))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (setq end-w-top
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (if (windowp end-w)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (nth 1 (window-edges end-w))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (/ (cdr (posn-x-y (event-end event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 ((frame-char-height end-w)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (if (>= end-w-top w-top)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (strokes-event-closest-point-1 start-window)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (window-start start-window)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (defun strokes-lift-p (object)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 "Return non-nil if object is a stroke-lift."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (eq object strokes-lift))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (defun strokes-unset-last-stroke ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 "Undo the last stroke definition."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (interactive)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (let ((command (cdar strokes-global-map)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (if (y-or-n-p-maybe-dialog-box
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (format "really delete last stroke definition, defined to `%s'? "
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 command))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (setq strokes-global-map (cdr strokes-global-map))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (message "That stroke has been deleted"))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (message "Nothing done"))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (defun strokes-global-set-stroke (stroke command)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 "Interactively give STROKE the global binding as COMMAND.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 Operated just like `global-set-key', except for strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 COMMAND is a symbol naming an interactively-callable function. STROKE
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 is a list of sampled positions on the stroke grid as described in the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 documentation for the `strokes-define-stroke' function."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (interactive
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (list
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (and (or strokes-mode (strokes-mode t))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (strokes-read-complex-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 "Define a new stroke. Draw with button1 (or 2). End with button3..."))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (read-command "command to map stroke to: ")))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (strokes-define-stroke strokes-global-map stroke command))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (defalias 'global-set-stroke 'strokes-global-set-stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 ;;(defun global-unset-stroke (stroke); FINISH THIS DEFUN!
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 ;; "delete all strokes matching STROKE from `strokes-global-map',
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 ;; letting the user input
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 ;; the stroke with the mouse"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 ;; (interactive
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 ;; (list
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 ;; (strokes-read-stroke "Enter the stroke you want to delete...")))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 ;; (strokes-define-stroke 'strokes-global-map stroke command))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (defun strokes-get-grid-position (stroke-extent position &optional grid-resolution)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 "Map POSITION to a new grid position based on its STROKE-EXTENT and GRID-RESOLUTION.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 STROKE-EXTENT as a list \(\(XMIN . YMIN\) \(XMAX . YMAX\)\).
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 If POSITION is a `strokes-lift', then it is itself returned.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 Optional GRID-RESOLUTION may be used in place of STROKES-GRID-RESOLUTION.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 The grid is a square whose dimesion is [0,GRID-RESOLUTION)."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (cond ((consp position) ; actual pixel location
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (let ((grid-resolution (or grid-resolution strokes-grid-resolution))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (x (car position))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (y (cdr position))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (xmin (caar stroke-extent))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (ymin (cdar stroke-extent))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 ;; the `1+' is there to insure that the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 ;; formula evaluates correctly at the boundaries
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (xmax (1+ (caadr stroke-extent)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (ymax (1+ (cdadr stroke-extent))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (cons (floor (* grid-resolution
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (/ (float (- x xmin))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (- xmax xmin))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (floor (* grid-resolution
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (/ (float (- y ymin))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (- ymax ymin)))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 ((strokes-lift-p position) ; stroke lift
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 strokes-lift)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 ;;(defun strokes-get-grid-position (stroke-extent pix-pos)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 ;; "Return the stroke-grid position for PIX-POS given the total STROKE-EXTENT.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 ;;STROKE-EXTENT as a list \(\(xmin . ymin\) \(xmax . ymax\)\) and a particular
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 ;;pixel position or `strokes-lift', find the corresponding grid position
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 ;;\(based on `strokes-grid-resolution'\) for the PIX-POS."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 ;; (cond ((consp pix-pos) ; actual pixel location
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 ;; (let ((x (car pix-pos))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 ;; (y (cdr pix-pos))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 ;; (xmin (caar stroke-extent))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 ;; (ymin (cdar stroke-extent))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 ;; ;; the `1+' is there to insure that the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 ;; ;; formula evaluates correctly at the boundaries
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 ;; (xmax (1+ (caadr stroke-extent)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 ;; (ymax (1+ (cdadr stroke-extent))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 ;; (cons (floor (* strokes-grid-resolution
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 ;; (/ (float (- x xmin))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 ;; (- xmax xmin))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 ;; (floor (* strokes-grid-resolution
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 ;; (/ (float (- y ymin))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 ;; (- ymax ymin)))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 ;; ((strokes-lift-p pix-pos) ; stroke lift
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 ;; strokes-lift)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (defun strokes-get-stroke-extent (pixel-positions)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 "From a list of absolute PIXEL-POSITIONS, returns absolute spatial extent.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 The return value is a list ((XMIN . YMIN) (XMAX . YMAX))."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (if pixel-positions
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 (let ((xmin (caar pixel-positions))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (xmax (caar pixel-positions))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (ymin (cdar pixel-positions))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (ymax (cdar pixel-positions))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (rest (cdr pixel-positions)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (while rest
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (if (consp (car rest))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (let ((x (caar rest))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (y (cdar rest)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (if (< x xmin)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 (setq xmin x))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (if (> x xmax)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (setq xmax x))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (if (< y ymin)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (setq ymin y))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (if (> y ymax)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 (setq ymax y))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 (setq rest (cdr rest)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (let ((delta-x (- xmax xmin))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (delta-y (- ymax ymin)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (if (> delta-x delta-y)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 (setq ymin (- ymin
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (/ (- delta-x delta-y)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 ymax (+ ymax
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 (/ (- delta-x delta-y)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (setq xmin (- xmin
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (/ (- delta-y delta-x)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 xmax (+ xmax
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (/ (- delta-y delta-x)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 2))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (list (cons xmin ymin)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (cons xmax ymax))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 nil))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (defun strokes-eliminate-consecutive-redundancies (entries)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 "Returns a list with no consecutive redundant entries."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 ;; defun a grande vitesse grace a Dave G.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (loop for element on entries
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 if (not (equal (car element) (cadr element)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 collect (car element)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 ;; (loop for element on entries
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 ;; nconc (if (not (equal (car el) (cadr el)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 ;; (list (car el)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 ;; yet another (orig) way of doing it...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 ;; (if entries
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 ;; (let* ((current (car entries))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 ;; (rest (cdr entries))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 ;; (non-redundant-list (list current))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 ;; (next nil))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 ;; (while rest
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 ;; (setq next (car rest))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 ;; (if (equal current next)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 ;; (setq rest (cdr rest))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 ;; (setq non-redundant-list (cons next non-redundant-list)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 ;; current next
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 ;; rest (cdr rest))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 ;; (nreverse non-redundant-list))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 ;; nil))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (defun strokes-renormalize-to-grid (positions &optional grid-resolution)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 "Map POSITIONS to a new grid whose dimensions are based on GRID-RESOLUTION.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 POSITIONS is a list of positions and stroke-lifts.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 Optional GRID-RESOLUTION may be used in place of STROKES-GRID-RESOLUTION.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 The grid is a square whose dimesion is [0,GRID-RESOLUTION)."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (or grid-resolution (setq grid-resolution strokes-grid-resolution))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (let ((stroke-extent (strokes-get-stroke-extent positions)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (mapcar (function
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (lambda (pos)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (strokes-get-grid-position stroke-extent pos grid-resolution)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 positions)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 ;;(defun strokes-normalize-pixels-to-grid (pixel-positions)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 ;; "Map PIXEL-POSITIONS to the stroke grid.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 ;;PIXEL-POSITIONS is a list of pixel-positions and stroke-lifts. The
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 ;;normalized stroke grid is defined by the variable STROKES-GRID-RESOLUTION"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 ;; (let ((stroke-extent (strokes-get-stroke-extent pixel-positions)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 ;; (mapcar (function
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 ;; (lambda (pix-pos)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 ;; (strokes-get-grid-position stroke-extent pix-pos)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 ;; pixel-positions)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 (defun strokes-fill-stroke (unfilled-stroke &optional force)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 "Fill in missing grid locations in the list of UNFILLED-STROKE.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 If FORCE is non-nil, then fill the stroke even if it's `stroke-click'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 NOTE: This is where the global variable `strokes-last-stroke' is set."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 (setq strokes-last-stroke ; this is global
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (if (and (strokes-click-p unfilled-stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (not force))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 unfilled-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (loop for grid-locs on unfilled-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 nconc (let* ((current (car grid-locs))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (current-is-a-point-p (consp current))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (next (cadr grid-locs))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 (next-is-a-point-p (consp next))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (both-are-points-p (and current-is-a-point-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 next-is-a-point-p))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (x1 (and current-is-a-point-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (car current)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (y1 (and current-is-a-point-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (cdr current)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (x2 (and next-is-a-point-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (car next)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (y2 (and next-is-a-point-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (cdr next)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (delta-x (and both-are-points-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (- x2 x1)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 (delta-y (and both-are-points-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (- y2 y1)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (slope (and both-are-points-p
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 (if (zerop delta-x)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 nil ; undefined vertical slope
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (/ (float delta-y)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 delta-x)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (cond ((not both-are-points-p)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (list current))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 ((null slope) ; undefinded vertical slope
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (if (>= delta-y 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (loop for y from y1 below y2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 collect (cons x1 y))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (loop for y from y1 above y2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 collect (cons x1 y))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 ((zerop slope) ; (= y1 y2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (if (>= delta-x 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 (loop for x from x1 below x2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 collect (cons x y1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (loop for x from x1 above x2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 collect (cons x y1))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 ((>= (abs delta-x) (abs delta-y))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (if (> delta-x 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (loop for x from x1 below x2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 collect (cons x
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 (+ y1
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (round (* slope
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 (- x x1))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (loop for x from x1 above x2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 collect (cons x
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 (+ y1
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (round (* slope
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (- x x1))))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (t ; (< (abs delta-x) (abs delta-y))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (if (> delta-y 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (loop for y from y1 below y2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 collect (cons (+ x1
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (round (/ (- y y1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 slope)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 y))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 (loop for y from y1 above y2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 collect (cons (+ x1
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (round (/ (- y y1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 slope)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 y))))))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 (defun strokes-rate-stroke (stroke1 stroke2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 "Rates STROKE1 with STROKE2 and returns a score based on a distance metric.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 Note: the rating is an error rating, and therefore, a return of 0
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 represents a perfect match. Also note that the order of stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 arguments is order-independent for the algorithm used here."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (if (and stroke1 stroke2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (let ((rest1 (cdr stroke1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (rest2 (cdr stroke2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (err (strokes-distance-squared (car stroke1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (car stroke2))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (while (and rest1 rest2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (while (and (consp (car rest1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (consp (car rest2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (setq err (+ err
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (strokes-distance-squared (car rest1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (car rest2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 stroke1 rest1
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 stroke2 rest2
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 rest1 (cdr stroke1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 rest2 (cdr stroke2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (cond ((and (strokes-lift-p (car rest1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 (strokes-lift-p (car rest2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 (setq rest1 (cdr rest1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 rest2 (cdr rest2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 ((strokes-lift-p (car rest2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (while (consp (car rest1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 (setq err (+ err
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 (strokes-distance-squared (car rest1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 (car stroke2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 rest1 (cdr rest1))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 ((strokes-lift-p (car rest1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (while (consp (car rest2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 (setq err (+ err
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (strokes-distance-squared (car stroke1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 (car rest2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 rest2 (cdr rest2))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 (if (null rest2)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (while (consp (car rest1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 (setq err (+ err
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 (strokes-distance-squared (car rest1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 (car stroke2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 rest1 (cdr rest1))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 (if (null rest1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 (while (consp (car rest2))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 (setq err (+ err
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 (strokes-distance-squared (car stroke1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (car rest2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 rest2 (cdr rest2))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (if (or (strokes-lift-p (car rest1))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 (strokes-lift-p (car rest2)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 (setq err nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 err))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 nil))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (defun strokes-match-stroke (stroke stroke-map)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 "Finds the best matching command of STROKE in STROKE-MAP.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 Returns the corresponding match as (COMMAND . SCORE)."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (if (and stroke stroke-map)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (let ((score (strokes-rate-stroke stroke (caar stroke-map)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (command (cdar stroke-map))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 (map (cdr stroke-map)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 (while map
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (let ((newscore (strokes-rate-stroke stroke (caar map))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 (if (or (and newscore score (< newscore score))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 (and newscore (null score)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (setq score newscore
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 command (cdar map)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (setq map (cdr map))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (if score
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 (cons command score)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 nil))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 nil))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (defun strokes-read-stroke (&optional prompt event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 "Read a simple stroke (interactively) and return the stroke.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 Optional PROMPT in minibuffer displays before and during stroke reading.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 This function will display the stroke interactively as it is being
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 entered in the strokes buffer if the variable
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 `strokes-use-strokes-buffer' is non-nil.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 Optional EVENT is currently not used, but hopefully will be soon."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (track-mouse
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (let ((pix-locs nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (grid-locs nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 (event nil))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 (if strokes-use-strokes-buffer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 ;; switch to the strokes buffer and
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 ;; display the stroke as it's being read
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 (save-window-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 (set-window-configuration strokes-window-configuration)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 (if prompt
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (message prompt)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 (setq event (read-event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (while (not (button-press-event-p event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (setq event (read-event)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (unwind-protect
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 (setq event (read-event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 (while (not (button-release-event-p event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 (if (strokes-mouse-event-p event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 (let ((point (strokes-event-closest-point event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 (when point
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 (goto-char point)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 (subst-char-in-region point (1+ point) ?\ strokes-character))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 (push (cons (event-x-pixel event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (event-y-pixel event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 pix-locs)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (setq event (read-event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 ;; protected
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 ;; clean up strokes buffer and then bury it.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 (when (equal (buffer-name) strokes-buffer-name)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 (subst-char-in-region (point-min) (point-max) strokes-character ?\ )
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 (goto-char (point-min))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 (bury-buffer))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 ;; Otherwise, don't use strokes buffer and read stroke silently
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 (if prompt
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 (message prompt)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (setq event (read-event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 (while (not (button-press-event-p event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (setq event (read-event)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (setq event (read-event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (while (not (button-release-event-p event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (if (strokes-mouse-event-p event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (push (cons (event-x-pixel event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (event-y-pixel event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 pix-locs))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 (setq event (read-event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (setq grid-locs (strokes-renormalize-to-grid (nreverse pix-locs)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (strokes-fill-stroke (strokes-eliminate-consecutive-redundancies grid-locs))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 (defun strokes-read-complex-stroke (&optional prompt event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 "Read a complex stroke (interactively) and return the stroke.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 Optional PROMPT in minibuffer displays before and during stroke reading.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 Note that a complex stroke allows the user to pen-up and pen-down. This
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 is implemented by allowing the user to paint with button1 or button2 and
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 then complete the stroke with button3.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 Optional EVENT is currently not used, but hopefully will be soon."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (save-window-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 (track-mouse
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 (set-window-configuration strokes-window-configuration)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 (let ((pix-locs nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 (grid-locs nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 (event (or event (read-event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (if prompt
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 (while (not (button-press-event-p event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 (message prompt)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (setq event (read-event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 (unwind-protect
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 (setq event (read-event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 (while (not (and (button-press-event-p event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 (eq (event-button event) 3)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 (while (not (button-release-event-p event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (if (strokes-mouse-event-p event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 (let ((point (strokes-event-closest-point event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (when point
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 (goto-char point)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 (subst-char-in-region point (1+ point) ?\ strokes-character))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 (push (cons (event-x-pixel event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 (event-y-pixel event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 pix-locs)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 (setq event (read-event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (push strokes-lift pix-locs)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 (while (not (button-press-event-p event))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (setq event (read-event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 ;; ### KLUDGE! ### sit and wait
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 ;; for some useless event to
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 ;; happen to fix the minibuffer bug.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (while (not (button-release-event-p (read-event))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 (setq pix-locs (nreverse (cdr pix-locs))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 grid-locs (strokes-renormalize-to-grid pix-locs))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 (strokes-fill-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (strokes-eliminate-consecutive-redundancies grid-locs)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 ;; protected
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (when (equal (buffer-name) strokes-buffer-name)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (subst-char-in-region (point-min) (point-max) strokes-character ?\ )
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 (goto-char (point-min))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (bury-buffer))))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (defun strokes-execute-stroke (stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 "Given STROKE, execute the command which corresponds to it.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 The command will be executed provided one exists for that stroke,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 based on the variable `strokes-minimum-match-score'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 If no stroke matches, nothing is done and return value is nil."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (let* ((match (strokes-match-stroke stroke strokes-global-map))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 (command (car match))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (score (cdr match)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 (cond ((strokes-click-p stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 ;; This is the case of a `click' type event
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (command-execute strokes-click-command))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 ((and match (<= score strokes-minimum-match-score))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (message "%s" command)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (command-execute command))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 ((null strokes-global-map)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (if (file-exists-p strokes-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (and (y-or-n-p-maybe-dialog-box
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (format "No strokes loaded. Load `%s'? "
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 strokes-file))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (strokes-load-user-strokes))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (error "No strokes defined; use `global-set-stroke'")))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (t
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 (error
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 "No stroke matches; see variable `strokes-minimum-match-score'")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 nil))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 (defun strokes-do-stroke (event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 "Read a simple stroke from the user and then exectute its comand.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 This must be bound to a mouse event."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 (interactive "e")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 (or strokes-mode (strokes-mode t))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 (strokes-execute-stroke (strokes-read-stroke nil event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 (defun strokes-do-complex-stroke (event)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 "Read a complex stroke from the user and then exectute its command.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 This must be bound to a mouse event."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 (interactive "e")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 (or strokes-mode (strokes-mode t))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (strokes-execute-stroke (strokes-read-complex-stroke nil event)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 (defun strokes-describe-stroke (stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 "Displays the command which STROKE maps to, reading STROKE interactively."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (interactive
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 (list
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 (strokes-read-complex-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 "Enter stroke to describe; end with button3...")))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 (let* ((match (strokes-match-stroke stroke strokes-global-map))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 (command (or (and (strokes-click-p stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 strokes-click-command)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 (car match)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 (score (cdr match)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 (if (or (and match
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 (<= score strokes-minimum-match-score))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 (and (strokes-click-p stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 strokes-click-command))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 (message "That stroke maps to `%s'" command)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 (message "That stroke is undefined"))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 (sleep-for 1))) ; helpful for recursive edits
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (defalias 'describe-stroke 'strokes-describe-stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 ;;; ### FORGET IT! I COULN'T GET THE EMACS READER TO PARSE THIS FUNCTION ###
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 ;;(defun strokes-help ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 ;; "Get instructional help on using the the `strokes' package."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 ;; (interactive)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 ;; (with-output-to-temp-buffer "*Help with Strokes*"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 ;; (let ((helpdoc
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 ;; "This is help for the strokes package.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 ;;If you find something wrong with strokes, or feel that it can be
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 ;;improved in some way, then please feel free to email me:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 ;;David Bakhash <cadet@mit.edu>
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 ;;or just do
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 ;;M-x strokes-report-bug
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 ;;------------------------------------------------------------
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 ;;** Strokes...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 ;;The strokes package allows you to define strokes, made with
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 ;;the mouse or other pointer device, that Emacs can interpret as
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 ;;corresponding to commands, and then executes the commands. It does
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 ;;character recognition, so you don't have to worry about getting it
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 ;;right every time.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 ;;Strokes are easy to program and fun to use. To start strokes going,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 ;;you'll want to put the following line in your .emacs file as mentioned
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 ;;in the commentary to strokes.el.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 ;;This will load strokes when and only when you start Emacs on a window
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 ;;system, with a mouse or other pointer device defined.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 ;;To toggle strokes-mode, you just do
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 ;;> M-x strokes-mode
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 ;;** Strokes for controling the behavior of Emacs...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 ;;When you're ready to start defining strokes, just use the command
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 ;;> M-x global-set-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 ;;You will see a ` *strokes*' buffer which is waiting for you to enter in
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 ;;your stroke. When you enter in the stroke, you draw with button1 or
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 ;;button2, and then end with button3. Next, you enter in the command
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 ;;which will be executed when that stroke is invoked. Simple as that.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 ;;For now, try to define a stroke to copy a region. This is a popular
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 ;;edit command, so type
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 ;;> M-x global-set-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 ;;Then, in the ` *strokes*' buffer, draw the letter `C' (for `copy'\)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 ;;and then, when it asks you to enter the command to map that to, type
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 ;;> copy-region-as-kill
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 ;;That's about as hard as it gets.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 ;;Remember: paint with button1 or button2 and then end with button3.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 ;;If ever you want to know what a certain strokes maps to, then do
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 ;;> M-x describe-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 ;;and you can enter in any arbitrary stroke. Remember: The strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 ;;package lets you program in simple and complex, or multi-lift, strokes.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 ;;The only difference is how you *invoke* the two. You will most likely
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 ;;use simple strokes, as complex strokes were developed for
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 ;;Chinese/Japanese/Korean. So the middle mouse button, button2, will
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 ;;invoke the command `strokes-do-stroke' in buffers where button2 doesn't
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 ;;already have a meaning other than its original, which is `mouse-yank'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 ;;But don't worry: `mouse-yank' will still work with strokes. See the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 ;;variable `strokes-click-command'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 ;;If ever you define a stroke which you don't like, then you can unset
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 ;;it with the command
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 ;;> M-x strokes-unset-last-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 ;;Your strokes are stored as you enter them. They get saved in a file
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 ;;called ~/.strokes, along with other strokes configuration variables.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 ;;You can change this location by setting the variable `strokes-file'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 ;;You will be prompted to save them when you exit Emacs, or you can save
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 ;;them with
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 ;;> M-x save-strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 ;;Your strokes get loaded automatically when you enable `strokes-mode'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 ;;You can also load in your user-defined strokes with
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 ;;> M-x load-user-strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 ;;** A few more important things...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 ;;o The command `strokes-do-stroke' is also invoked with M-button2, so that you
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 ;; can still enter a stroke in modes which use button2 for other things,
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 ;; such as cross-referencing.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 ;;o Strokes are a bit computer-dependent in that they depend somewhat on
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 ;; the speed of the computer you're working on. This means that you
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 ;; may have to tweak some variables. You can read about them in the
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 ;; commentary of `strokes.el'. Better to just use apropos and read their
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 ;; docstrings. All variables/functions start with `strokes'. The one
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 ;; variable which many people wanted to see was
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 ;; `strokes-use-strokes-buffer' which allows the user to use strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 ;; silently--without displaying the strokes. All variables can be set
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 ;; by customizing the group named `strokes' via the customization package:
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 ;; > M-x customize"))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 ;; (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 ;; (princ helpdoc)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 ;; (set-buffer standard-output)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 ;; (help-mode))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 ;; (print-help-return-message)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 (defun strokes-report-bug ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 "Submit a bug report for strokes."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 (interactive)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 (let ((reporter-prompt-for-summary-p t))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 (or (boundp 'reporter-version)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 (setq reporter-version
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 "Your version of reporter is obsolete. Please upgrade."))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 (reporter-submit-bug-report
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 strokes-bug-address "Strokes"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 (cons
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 'strokes-version
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 (nconc
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 (mapcar
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 'intern
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 (sort
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 (let (completion-ignore-case)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 (all-completions "strokes-" obarray 'user-variable-p))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 'string-lessp))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 (list 'reporter-version)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 (function
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 (lambda ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 (mail-position-on-field "subject")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 (beginning-of-line)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 (skip-chars-forward "^:\n")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 (if (looking-at ": Strokes;")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 (goto-char (match-end 0))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 (delete-char -1)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 (insert " " strokes-version " bug:")))))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 (defsubst strokes-fill-current-buffer-with-whitespace ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 "Erase the contents of the current buffer and fill it with whitespace"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 (erase-buffer)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 (loop repeat (frame-height) do
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 (insert-char ?\ (1- (frame-width)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 (newline))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 (goto-char (point-min)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 (defun strokes-update-window-configuration ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 "Insure that `strokes-window-configuration' is up-to-date."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 (interactive)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 (let ((current-window (selected-window)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 (cond ((or (window-minibuffer-p current-window)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 (window-dedicated-p current-window))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 ;; don't try to update strokes window configuration
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 ;; if window is dedicated or a minibuffer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 ((or (interactive-p)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 (not (buffer-live-p (get-buffer strokes-buffer-name)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 (null strokes-window-configuration))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 ;; create `strokes-window-configuration' from scratch...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 (save-window-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 (get-buffer-create strokes-buffer-name)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 (set-window-buffer current-window strokes-buffer-name)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 (delete-other-windows)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 (fundamental-mode)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 (auto-save-mode 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 (if (featurep 'font-lock)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 (font-lock-mode 0))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 (abbrev-mode 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 (buffer-disable-undo (current-buffer))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 (setq truncate-lines nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 (strokes-fill-current-buffer-with-whitespace)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 (setq strokes-window-configuration (current-window-configuration))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 (bury-buffer))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (t ; `strokes buffer' still exists...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 ;; update the strokes-window-configuration for this specific frame...
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 (save-window-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 (set-window-buffer current-window strokes-buffer-name)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 (delete-other-windows)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 (strokes-fill-current-buffer-with-whitespace)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 (setq strokes-window-configuration (current-window-configuration))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (bury-buffer)))))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 (defun strokes-load-user-strokes ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 "Load user-defined strokes from file named by `strokes-file'."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 (interactive)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 (cond ((and (file-exists-p strokes-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 (file-readable-p strokes-file))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 (load-file strokes-file))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 ((interactive-p)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 (error "Trouble loading user-defined strokes; nothing done"))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 (t
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 (message "No user-defined strokes, sorry"))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 (defalias 'load-user-strokes 'strokes-load-user-strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 (defun strokes-prompt-user-save-strokes ()
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 "Save user-defined strokes to file named by `strokes-file'."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 (interactive)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 (save-excursion
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 (let ((current strokes-global-map))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 (unwind-protect
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 (setq strokes-global-map nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 (strokes-load-user-strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 (if (and (not (equal current strokes-global-map))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 (or (interactive-p)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 (yes-or-no-p-maybe-dialog-box "save your strokes? ")))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 (progn
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 (require 'pp) ; pretty-print variables
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 (message "Saving strokes in %s..." strokes-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 (get-buffer-create "*saved-strokes*")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 (set-buffer "*saved-strokes*")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 (erase-buffer)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 (emacs-lisp-mode)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 (goto-char (point-min))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 (insert-string
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 ";; -*- Syntax: Emacs-Lisp; Mode: emacs-lisp -*-\n")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 (insert-string (format ";;; saved strokes for %s, as of %s\n\n"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 (user-full-name)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 (format-time-string "%B %e, %Y" nil)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (message "Saving strokes in %s..." strokes-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 (insert-string (format "(setq strokes-global-map '%s)"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 (pp current)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 (message "Saving strokes in %s..." strokes-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 (indent-region (point-min) (point-max) nil)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 (write-region (point-min)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 (point-max)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 strokes-file))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (message "(no changes need to be saved)")))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 ;; protected
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 (if (get-buffer "*saved-strokes*")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 (kill-buffer (get-buffer "*saved-strokes*")))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (setq strokes-global-map current)))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 (defalias 'save-strokes 'strokes-prompt-user-save-strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 (defun strokes-toggle-strokes-buffer (&optional arg)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 "Toggle the use of the strokes buffer.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 In other words, toggle the variabe `strokes-use-strokes-buffer'.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 With ARG, use strokes buffer if and only if ARG is positive or true.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 Returns value of `strokes-use-strokes-buffer'."
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (interactive "P")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 (setq strokes-use-strokes-buffer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 (if arg (> (prefix-numeric-value arg) 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 (not strokes-use-strokes-buffer))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 ;;;###autoload
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 (defun strokes-mode (&optional arg)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 "Toggle strokes being enabled.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 With ARG, turn strokes on if and only if ARG is positive or true.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265 Note that `strokes-mode' is a global mode. Think of it as a minor
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 mode in all buffers when activated.
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 By default, strokes are invoked with mouse button-2. You can define
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 new strokes with
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 > M-x global-set-stroke
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 To use strokes for pictographic editing, such as Chinese/Japanese, use
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 Sh-button-2, which draws strokes and inserts them. Encode/decode your
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 strokes with
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 > M-x strokes-encode-buffer
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 > M-x strokes-decode-buffer"
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 (interactive "P")
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 (let ((on-p (if arg
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (> (prefix-numeric-value arg) 0)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 (not strokes-mode))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 (cond ((not window-system)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 (error "Can't use strokes without windows"))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 (on-p ; turn on strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 (and (file-exists-p strokes-file)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 (null strokes-global-map)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 (strokes-load-user-strokes))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 (add-hook 'kill-emacs-hook
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 'strokes-prompt-user-save-strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 (add-hook 'select-frame-hook
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 'strokes-update-window-configuration)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 (strokes-update-window-configuration)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 (define-key global-map [(button2)] 'strokes-do-stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 (define-key global-map [(meta button2)] 'strokes-do-stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 ;; (define-key global-map [(control button2)] 'strokes-do-complex-stroke)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (ad-activate-regexp "^strokes-") ; advise button2 commands
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (setq strokes-mode t))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 (t ; turn off strokes
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 (if (get-buffer strokes-buffer-name)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300 (kill-buffer (get-buffer strokes-buffer-name)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 (remove-hook 'select-frame-hook
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302 'strokes-update-window-configuration)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 (if (string-match "^strokes-" (symbol-name (key-binding [(button2)])))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 (define-key global-map [(button2)] strokes-click-command))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (if (string-match "^strokes-" (symbol-name (key-binding [(meta button2)])))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 (global-unset-key [(meta button2)]))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 ;; (if (string-match "^strokes-" (symbol-name (key-binding [(shift button2)])))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 ;; (global-unset-key [(shift button2)]))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (ad-deactivate-regexp "^strokes-") ; unadvise strokes-button2 commands
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 (setq strokes-mode nil))))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 (force-mode-line-update))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 (or (assq 'strokes-mode minor-mode-alist)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 (setq minor-mode-alist (cons (list 'strokes-mode strokes-modeline-string)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 minor-mode-alist)))
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 (provide 'strokes)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 (run-hooks 'strokes-load-hook)
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 ;;; strokes.el ends here
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321
eaec3bec7dea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322