annotate lisp/strokes.el @ 21934:809dbde64976

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