428
|
1 ;;; x-compose.el --- Compose-key processing in XEmacs
|
|
2
|
2828
|
3 ;; Copyright (C) 1992, 1993, 1997, 2005 Free Software Foundation, Inc.
|
428
|
4
|
|
5 ;; Author: Jamie Zawinski <jwz@jwz.org>
|
|
6 ;; Maintainer: XEmacs Development Team
|
|
7 ;; Rewritten by Martin Buchholz far too many times.
|
|
8 ;;
|
|
9 ;; Changed: 11 Jun 1997 by Heiko Muenkel <muenkel@tnt.uni-hannover.de>
|
|
10 ;; The degree sign couldn't be inserted with the old version.
|
|
11 ;; Keywords: i18n
|
|
12
|
|
13 ;; This file is part of XEmacs.
|
|
14
|
|
15 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
16 ;; under the terms of the GNU General Public License as published by
|
|
17 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
18 ;; any later version.
|
|
19
|
|
20 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
23 ;; General Public License for more details.
|
|
24
|
|
25 ;; You should have received a copy of the GNU General Public License
|
|
26 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
28 ;; Boston, MA 02111-1307, USA.
|
|
29
|
|
30 ;;; Synched up with: Not in FSF.
|
|
31
|
|
32 ;;; Commentary:
|
|
33
|
|
34 ;; created by jwz, 14-jun-92.
|
|
35 ;;; changed by Jan Vroonhof, July 1997: Use function-key-map instead
|
|
36 ;;; of global map.
|
|
37 ;;; Preliminary support for
|
|
38 ;;; XFree86 deadkeys
|
|
39
|
|
40 ;; This file implements DEC-, OpenWindows-, and HP-compatible "Compose"
|
|
41 ;; processing for XEmacs.
|
|
42
|
|
43 ;; If you are running a version of X which already does compose processing,
|
|
44 ;; then you don't need this file. But the MIT R4 and R5 distributions don't
|
|
45 ;; do compose processing, so you may want to fake it by using this code.
|
|
46
|
|
47 ;; The basic idea is that there are several ways to generate keysyms which
|
|
48 ;; do not have keys devoted to them on your keyboard.
|
|
49
|
|
50 ;; The first method is by using "dead" keys. A dead key is a key which,
|
|
51 ;; when typed, does not insert a character. Instead it modifies the
|
|
52 ;; following character typed. So if you typed "dead-tilde" followed by "A",
|
|
53 ;; then "A-tilde" would be inserted. Of course, this requires you to modify
|
|
54 ;; your keyboard to include a "dead-tilde" key on it somewhere.
|
|
55
|
|
56 ;; The second method is by using a "Compose" key. With a Compose key, you
|
|
57 ;; would type "Compose" then "tilde" then "A" to insert "A-tilde".
|
|
58
|
|
59 ;; There are a small number of dead keys: acute, grave, cedilla, diaeresis,
|
|
60 ;; circumflex, tilde, and ring. There are a larger number of accented and
|
|
61 ;; other characters accessible via the Compose key, so both are useful.
|
|
62
|
|
63 ;; To use this code, you will need to have a Compose key on your keyboard.
|
|
64 ;; The default configuration of most X keyboards doesn't contain one. You
|
|
65 ;; can, for example, turn the right "Meta" key into a "Compose" key with
|
|
66 ;; this command:
|
|
67
|
|
68 ;; xmodmap -e "remove mod1 = Meta_R" -e "keysym Meta_R = Multi_key"
|
|
69
|
|
70 ;; Multi-key is the name that X (and emacs) know the "Compose" key by.
|
|
71 ;; The "remove..." command is necessary because the "Compose" key must not
|
|
72 ;; have any modifier bits associated with it. This exact command may not
|
|
73 ;; work, depending on what system and keyboard you are using. If it
|
|
74 ;; doesn't, you'll have to read the man page for xmodmap. You might want
|
|
75 ;; to get the "xkeycaps" program from
|
|
76 ;; <URL:http://www.jwz.org/xkeycaps/>,
|
|
77 ;; which is a graphical front end to xmodmap
|
|
78 ;; that hides xmodmap's arcane syntax from you.
|
|
79
|
|
80 ;; If for some reason you don't want to have a dedicated compose key on your
|
|
81 ;; keyboard, you can use some other key as the prefix. For example, to make
|
|
82 ;; "Meta-Shift-C" act as a compose key (so that "M-C , c" would insert the
|
|
83 ;; character "ccedilla") you could do
|
|
84
|
|
85 ;; (global-set-key "\M-C" compose-map)
|
|
86
|
|
87 ;; I believe the bindings encoded in this file are the same as those used
|
|
88 ;; by OpenWindows versions 2 and 3, and DEC VT320 terminals. Please let me
|
|
89 ;; know if you think otherwise.
|
|
90
|
|
91 ;; Much thanks to Justin Bur <justin@crim.ca> for helping me understand how
|
|
92 ;; this stuff is supposed to work.
|
|
93
|
|
94 ;; You also might want to consider getting Justin's patch for the MIT Xlib
|
|
95 ;; that implements compose processing in the library. This will enable
|
|
96 ;; compose processing in applications other than emacs as well. You can
|
|
97 ;; get it from export.lcs.mit.edu in contrib/compose.tar.Z.
|
|
98
|
|
99 ;; This code has one feature that a more "builtin" Compose mechanism could
|
|
100 ;; not have: at any point you can type C-h to get a list of the possible
|
|
101 ;; completions of what you have typed so far.
|
|
102
|
2828
|
103 ;; Giacomo Boffi's problem of
|
|
104 ;; 20050324103919.8D22E4901@boffi95.stru.polimi.it is caused by Xlib doing
|
|
105 ;; the compose processing. To turn that off, I'm not certain what's
|
428
|
106
|
2828
|
107 ;;; Code:
|
428
|
108
|
|
109 (macrolet
|
|
110 ((define-compose-map (keymap-symbol)
|
|
111 `(progn
|
|
112 (defconst ,keymap-symbol (make-sparse-keymap ',keymap-symbol))
|
|
113 ;; Required to tell XEmacs the keymaps were actually autoloaded.
|
|
114 ;; #### Make this unnecessary!
|
|
115 (fset ',keymap-symbol ,keymap-symbol))))
|
|
116
|
|
117 (define-compose-map compose-map)
|
|
118 (define-compose-map compose-acute-map)
|
|
119 (define-compose-map compose-grave-map)
|
|
120 (define-compose-map compose-cedilla-map)
|
|
121 (define-compose-map compose-diaeresis-map)
|
|
122 (define-compose-map compose-circumflex-map)
|
|
123 (define-compose-map compose-tilde-map)
|
|
124 (define-compose-map compose-ring-map))
|
|
125
|
|
126 (define-key compose-map 'acute compose-acute-map)
|
|
127 (define-key compose-map 'grave compose-grave-map)
|
|
128 (define-key compose-map 'cedilla compose-cedilla-map)
|
|
129 (define-key compose-map 'diaeresis compose-diaeresis-map)
|
|
130 (define-key compose-map 'circumflex compose-circumflex-map)
|
|
131 (define-key compose-map 'tilde compose-tilde-map)
|
|
132 (define-key compose-map 'degree compose-ring-map)
|
|
133
|
|
134 ;;(define-key function-key-map [multi-key] compose-map)
|
|
135
|
|
136 ;; The following is necessary, because one can't rebind [degree]
|
|
137 ;; and use it to insert the degree sign!
|
|
138 ;;(defun compose-insert-degree ()
|
|
139 ;; "Inserts a degree sign."
|
|
140 ;; (interactive)
|
|
141 ;; (insert ?\260))
|
|
142
|
|
143 (define-key compose-map [acute] compose-acute-map)
|
|
144 (define-key compose-map [?'] compose-acute-map)
|
|
145 (define-key compose-map [grave] compose-grave-map)
|
|
146 (define-key compose-map [?`] compose-grave-map)
|
|
147 (define-key compose-map [cedilla] compose-cedilla-map)
|
|
148 (define-key compose-map [?,] compose-cedilla-map)
|
|
149 (define-key compose-map [diaeresis] compose-diaeresis-map)
|
|
150 (define-key compose-map [?\"] compose-diaeresis-map)
|
|
151 (define-key compose-map [circumflex] compose-circumflex-map)
|
|
152 (define-key compose-map [?^] compose-circumflex-map)
|
|
153 (define-key compose-map [tilde] compose-tilde-map)
|
|
154 (define-key compose-map [~] compose-tilde-map)
|
|
155 (define-key compose-map [degree] compose-ring-map)
|
|
156 (define-key compose-map [?*] compose-ring-map)
|
|
157
|
|
158
|
|
159 ;;; The contents of the "dead key" maps. These are shared by the
|
|
160 ;;; compose-map.
|
|
161
|
2828
|
162 ;;; These used to all have nice readable X11-oriented keysym names as the
|
|
163 ;;; macro definition in the third argument, but I moved the interpretation
|
|
164 ;;; of those mappings (that is, Aacute to \301, &c.) to runtime in the X11
|
|
165 ;;; code on first sight of the symbols--which is the more general solution,
|
|
166 ;;; what with Unicode keysyms, publishing, technical and so on, there's no
|
|
167 ;;; need to have them hanging around as symbols all the time--so they're no
|
|
168 ;;; longer available to Lisp before X11 sees them, something this relied on.
|
|
169
|
|
170 ;;; The transformation was done like so;
|
|
171
|
|
172 ;;; (while (re-search-forward "\\[\\([a-zA-Z]+\\)\\])$" nil t)
|
|
173 ;;; (replace-match (format "(?\\%o)"
|
|
174 ;;; (get (intern (match-string 1)) 'character-of-keysym))
|
|
175 ;;; t t nil 1))
|
|
176
|
|
177 ;;; with a lot of repeated calling of setxkbmap to esoteric keymaps--so
|
|
178 ;;; x_reset_key_mapping gets called for all the keys on the keyboard--yacute
|
|
179 ;;; getting picked up from the Czech keymap, idiaeresis from the Dutch one,
|
|
180 ;;; and many more (al, ca, cz, de, dvorak, ee, es, fi, fr, hu,
|
|
181 ;;; ie(UnicodeExpert), it, nl, pt, ro, tr, us, vn, if it interests you.)
|
|
182
|
|
183 ;;; The parentheses inside the vector are because otherwise the macro gets
|
|
184 ;;; interpreted as a meta character, the Latin-1 codes being in exactly that
|
|
185 ;;; range. Perhaps that bears documenting somewhere. Also, why is help
|
|
186 ;;; turned off for these (x-compose) sequences by default?
|
|
187
|
|
188 ;;; (Aidan Kehoe, 2005-05-18)
|
|
189
|
428
|
190 (define-key compose-acute-map [space] "'")
|
2828
|
191 (define-key compose-acute-map [?'] [(?\264)])
|
|
192 (define-key compose-acute-map [?A] [(?\301)])
|
|
193 (define-key compose-acute-map [E] [(?\311)])
|
|
194 (define-key compose-acute-map [I] [(?\315)])
|
|
195 (define-key compose-acute-map [O] [(?\323)])
|
|
196 (define-key compose-acute-map [U] [(?\332)])
|
|
197 (define-key compose-acute-map [Y] [(?\335)])
|
|
198 (define-key compose-acute-map [a] [(?\341)])
|
|
199 (define-key compose-acute-map [e] [(?\351)])
|
|
200 (define-key compose-acute-map [i] [(?\355)])
|
|
201 (define-key compose-acute-map [o] [(?\363)])
|
|
202 (define-key compose-acute-map [u] [(?\372)])
|
|
203 (define-key compose-acute-map [y] [(?\375)])
|
428
|
204
|
|
205 (define-key compose-grave-map [space] "`")
|
2828
|
206 (define-key compose-grave-map [?`] [(?\140)])
|
|
207 (define-key compose-grave-map [A] [(?\300)])
|
|
208 (define-key compose-grave-map [E] [(?\310)])
|
|
209 (define-key compose-grave-map [I] [(?\314)])
|
|
210 (define-key compose-grave-map [O] [(?\322)])
|
|
211 (define-key compose-grave-map [U] [(?\331)])
|
|
212 (define-key compose-grave-map [a] [(?\340)])
|
|
213 (define-key compose-grave-map [e] [(?\350)])
|
|
214 (define-key compose-grave-map [i] [(?\354)])
|
|
215 (define-key compose-grave-map [o] [(?\362)])
|
|
216 (define-key compose-grave-map [u] [(?\371)])
|
428
|
217
|
|
218 (define-key compose-cedilla-map [space] ",")
|
2828
|
219 (define-key compose-cedilla-map [?,] [(?\270)])
|
|
220 (define-key compose-cedilla-map [C] [(?\307)])
|
|
221 (define-key compose-cedilla-map [c] [(?\347)])
|
428
|
222
|
2828
|
223 (define-key compose-diaeresis-map [space] [(?\250)])
|
|
224 (define-key compose-diaeresis-map [?\"] [(?\250)])
|
|
225 (define-key compose-diaeresis-map [A] [(?\304)])
|
|
226 (define-key compose-diaeresis-map [E] [(?\313)])
|
|
227 (define-key compose-diaeresis-map [I] [(?\317)])
|
|
228 (define-key compose-diaeresis-map [O] [(?\326)])
|
|
229 (define-key compose-diaeresis-map [U] [(?\334)])
|
|
230 (define-key compose-diaeresis-map [a] [(?\344)])
|
|
231 (define-key compose-diaeresis-map [e] [(?\353)])
|
|
232 (define-key compose-diaeresis-map [i] [(?\357)])
|
|
233 (define-key compose-diaeresis-map [o] [(?\366)])
|
|
234 (define-key compose-diaeresis-map [u] [(?\374)])
|
|
235 (define-key compose-diaeresis-map [y] [(?\377)])
|
428
|
236
|
|
237 (define-key compose-circumflex-map [space] "^")
|
|
238 (define-key compose-circumflex-map [?/] "|")
|
2828
|
239 (define-key compose-circumflex-map [?!] [(?\246)])
|
|
240 (define-key compose-circumflex-map [?-] [(?\257)])
|
|
241 (define-key compose-circumflex-map [?_] [(?\257)])
|
|
242 (define-key compose-circumflex-map [?0] [(?\260)])
|
|
243 (define-key compose-circumflex-map [?1] [(?\271)])
|
|
244 (define-key compose-circumflex-map [?2] [(?\262)])
|
|
245 (define-key compose-circumflex-map [?3] [(?\263)])
|
|
246 (define-key compose-circumflex-map [?.] [(?\267)])
|
|
247 (define-key compose-circumflex-map [A] [(?\302)])
|
|
248 (define-key compose-circumflex-map [E] [(?\312)])
|
|
249 (define-key compose-circumflex-map [I] [(?\316)])
|
|
250 (define-key compose-circumflex-map [O] [(?\324)])
|
|
251 (define-key compose-circumflex-map [U] [(?\333)])
|
|
252 (define-key compose-circumflex-map [a] [(?\342)])
|
|
253 (define-key compose-circumflex-map [e] [(?\352)])
|
|
254 (define-key compose-circumflex-map [i] [(?\356)])
|
|
255 (define-key compose-circumflex-map [o] [(?\364)])
|
|
256 (define-key compose-circumflex-map [u] [(?\373)])
|
428
|
257
|
|
258 (define-key compose-tilde-map [space] "~")
|
2828
|
259 (define-key compose-tilde-map [A] [(?\303)])
|
|
260 (define-key compose-tilde-map [N] [(?\321)])
|
|
261 (define-key compose-tilde-map [O] [(?\325)])
|
|
262 (define-key compose-tilde-map [a] [(?\343)])
|
|
263 (define-key compose-tilde-map [n] [(?\361)])
|
|
264 (define-key compose-tilde-map [o] [(?\365)])
|
428
|
265
|
2828
|
266 (define-key compose-ring-map [space] [(?\260)])
|
|
267 (define-key compose-ring-map [A] [(?\305)])
|
|
268 (define-key compose-ring-map [a] [(?\345)])
|
428
|
269
|
|
270
|
|
271 ;;; The rest of the compose-map. These are the composed characters
|
|
272 ;;; that are not accessible via "dead" keys.
|
|
273
|
|
274 (define-key compose-map " '" "'")
|
|
275 (define-key compose-map " ^" "^")
|
|
276 (define-key compose-map " `" "`")
|
|
277 (define-key compose-map " ~" "~")
|
2828
|
278 (define-key compose-map " " [(?\240)])
|
|
279 (define-key compose-map " \"" [(?\250)])
|
|
280 (define-key compose-map " :" [(?\250)])
|
|
281 (define-key compose-map " *" [(?\260)])
|
428
|
282
|
2828
|
283 (define-key compose-map "!!" [(?\241)])
|
|
284 (define-key compose-map "!^" [(?\246)])
|
|
285 (define-key compose-map "!S" [(?\247)])
|
|
286 (define-key compose-map "!s" [(?\247)])
|
|
287 (define-key compose-map "!P" [(?\266)])
|
|
288 (define-key compose-map "!p" [(?\266)])
|
428
|
289
|
|
290 (define-key compose-map "((" "[")
|
|
291 (define-key compose-map "(-" "{")
|
|
292
|
|
293 (define-key compose-map "))" "]")
|
|
294 (define-key compose-map ")-" "}")
|
|
295
|
|
296 (define-key compose-map "++" "#")
|
2828
|
297 (define-key compose-map "+-" [(?\261)])
|
428
|
298
|
|
299 (define-key compose-map "-(" "{")
|
|
300 (define-key compose-map "-)" "}")
|
|
301 (define-key compose-map "--" "-")
|
2828
|
302 (define-key compose-map "-L" [(?\243)])
|
|
303 (define-key compose-map "-l" [(?\243)])
|
|
304 (define-key compose-map "-Y" [(?\245)])
|
|
305 (define-key compose-map "-y" [(?\245)])
|
|
306 (define-key compose-map "-," [(?\254)])
|
|
307 (define-key compose-map "-|" [(?\254)])
|
|
308 (define-key compose-map "-^" [(?\257)])
|
|
309 (define-key compose-map "-+" [(?\261)])
|
|
310 (define-key compose-map "-:" [(?\367)])
|
|
311 (define-key compose-map "-D" [(?\320)])
|
|
312 (define-key compose-map "-d" [(?\360)])
|
|
313 (define-key compose-map "-a" [(?\252)])
|
428
|
314
|
2828
|
315 (define-key compose-map ".^" [(?\267)])
|
428
|
316
|
|
317 (define-key compose-map "//" "\\")
|
|
318 (define-key compose-map "/<" "\\")
|
|
319 (define-key compose-map "/^" "|")
|
2828
|
320 (define-key compose-map "/C" [(?\242)])
|
|
321 (define-key compose-map "/c" [(?\242)])
|
|
322 (define-key compose-map "/U" [(?\265)])
|
|
323 (define-key compose-map "/u" [(?\265)])
|
|
324 (define-key compose-map "/O" [(?\330)])
|
|
325 (define-key compose-map "/o" [(?\370)])
|
428
|
326
|
2828
|
327 (define-key compose-map "0X" [(?\244)])
|
|
328 (define-key compose-map "0x" [(?\244)])
|
|
329 (define-key compose-map "0S" [(?\247)])
|
|
330 (define-key compose-map "0s" [(?\247)])
|
|
331 (define-key compose-map "0C" [(?\251)])
|
|
332 (define-key compose-map "0c" [(?\251)])
|
|
333 (define-key compose-map "0R" [(?\256)])
|
|
334 (define-key compose-map "0r" [(?\256)])
|
|
335 (define-key compose-map "0^" [(?\260)])
|
428
|
336
|
2828
|
337 (define-key compose-map "1^" [(?\271)])
|
|
338 (define-key compose-map "14" [(?\274)])
|
|
339 (define-key compose-map "12" [(?\275)])
|
428
|
340
|
2828
|
341 (define-key compose-map "2^" [(?\262)])
|
428
|
342
|
2828
|
343 (define-key compose-map "3^" [(?\263)])
|
|
344 (define-key compose-map "34" [(?\276)])
|
428
|
345
|
2828
|
346 (define-key compose-map ":-" [(?\367)])
|
428
|
347
|
|
348 (define-key compose-map "</" "\\")
|
2828
|
349 (define-key compose-map "<<" [(?\253)])
|
428
|
350
|
2828
|
351 (define-key compose-map "=L" [(?\243)])
|
|
352 (define-key compose-map "=l" [(?\243)])
|
|
353 (define-key compose-map "=Y" [(?\245)])
|
|
354 (define-key compose-map "=y" [(?\245)])
|
428
|
355
|
2828
|
356 (define-key compose-map ">>" [(?\273)])
|
428
|
357
|
2828
|
358 (define-key compose-map "??" [(?\277)])
|
428
|
359
|
|
360 (define-key compose-map "AA" "@")
|
|
361 (define-key compose-map "Aa" "@")
|
2828
|
362 (define-key compose-map "A_" [(?\252)])
|
|
363 (define-key compose-map "A`" [(?\300)])
|
|
364 (define-key compose-map "A'" [(?\301)])
|
|
365 (define-key compose-map "A^" [(?\302)])
|
|
366 (define-key compose-map "A~" [(?\303)])
|
|
367 (define-key compose-map "A\"" [(?\304)])
|
|
368 (define-key compose-map "A*" [(?\305)])
|
|
369 (define-key compose-map "AE" [(?\306)])
|
428
|
370
|
2828
|
371 (define-key compose-map "C/" [(?\242)])
|
|
372 (define-key compose-map "C|" [(?\242)])
|
|
373 (define-key compose-map "C0" [(?\251)])
|
|
374 (define-key compose-map "CO" [(?\251)])
|
|
375 (define-key compose-map "Co" [(?\251)])
|
|
376 (define-key compose-map "C," [(?\307)])
|
428
|
377
|
2828
|
378 (define-key compose-map "D-" [(?\320)])
|
428
|
379
|
2828
|
380 (define-key compose-map "E`" [(?\310)])
|
|
381 (define-key compose-map "E'" [(?\311)])
|
|
382 (define-key compose-map "E^" [(?\312)])
|
|
383 (define-key compose-map "E\"" [(?\313)])
|
428
|
384
|
2828
|
385 (define-key compose-map "I`" [(?\314)])
|
|
386 (define-key compose-map "I'" [(?\315)])
|
|
387 (define-key compose-map "I^" [(?\316)])
|
|
388 (define-key compose-map "I\"" [(?\317)])
|
428
|
389
|
2828
|
390 (define-key compose-map "L-" [(?\243)])
|
|
391 (define-key compose-map "L=" [(?\243)])
|
428
|
392
|
2828
|
393 (define-key compose-map "N~" [(?\321)])
|
428
|
394
|
2828
|
395 (define-key compose-map "OX" [(?\244)])
|
|
396 (define-key compose-map "Ox" [(?\244)])
|
|
397 (define-key compose-map "OS" [(?\247)])
|
|
398 (define-key compose-map "Os" [(?\247)])
|
|
399 (define-key compose-map "OC" [(?\251)])
|
|
400 (define-key compose-map "Oc" [(?\251)])
|
|
401 (define-key compose-map "OR" [(?\256)])
|
|
402 (define-key compose-map "Or" [(?\256)])
|
|
403 (define-key compose-map "O_" [(?\272)])
|
|
404 (define-key compose-map "O`" [(?\322)])
|
|
405 (define-key compose-map "O'" [(?\323)])
|
|
406 (define-key compose-map "O^" [(?\324)])
|
|
407 (define-key compose-map "O~" [(?\325)])
|
|
408 (define-key compose-map "O\"" [(?\326)])
|
|
409 (define-key compose-map "O/" [(?\330)])
|
428
|
410
|
2828
|
411 (define-key compose-map "P!" [(?\266)])
|
428
|
412
|
2828
|
413 (define-key compose-map "R0" [(?\256)])
|
|
414 (define-key compose-map "RO" [(?\256)])
|
|
415 (define-key compose-map "Ro" [(?\256)])
|
428
|
416
|
2828
|
417 (define-key compose-map "S!" [(?\247)])
|
|
418 (define-key compose-map "S0" [(?\247)])
|
|
419 (define-key compose-map "SO" [(?\247)])
|
|
420 (define-key compose-map "So" [(?\247)])
|
|
421 (define-key compose-map "SS" [(?\337)])
|
428
|
422
|
2828
|
423 (define-key compose-map "TH" [(?\336)])
|
428
|
424
|
2828
|
425 (define-key compose-map "U`" [(?\331)])
|
|
426 (define-key compose-map "U'" [(?\332)])
|
|
427 (define-key compose-map "U^" [(?\333)])
|
|
428 (define-key compose-map "U\"" [(?\334)])
|
428
|
429
|
2828
|
430 (define-key compose-map "X0" [(?\244)])
|
|
431 (define-key compose-map "XO" [(?\244)])
|
|
432 (define-key compose-map "Xo" [(?\244)])
|
428
|
433
|
2828
|
434 (define-key compose-map "Y-" [(?\245)])
|
|
435 (define-key compose-map "Y=" [(?\245)])
|
|
436 (define-key compose-map "Y'" [(?\335)])
|
428
|
437
|
2828
|
438 (define-key compose-map "_A" [(?\252)])
|
|
439 (define-key compose-map "_a" [(?\252)])
|
|
440 (define-key compose-map "_^" [(?\257)])
|
|
441 (define-key compose-map "_O" [(?\272)])
|
|
442 (define-key compose-map "_o" [(?\272)])
|
428
|
443
|
|
444 (define-key compose-map "aA" "@")
|
|
445 (define-key compose-map "aa" "@")
|
2828
|
446 (define-key compose-map "a_" [(?\252)])
|
|
447 (define-key compose-map "a-" [(?\252)])
|
|
448 (define-key compose-map "a`" [(?\340)])
|
|
449 (define-key compose-map "a'" [(?\341)])
|
|
450 (define-key compose-map "a^" [(?\342)])
|
|
451 (define-key compose-map "a~" [(?\343)])
|
|
452 (define-key compose-map "a\"" [(?\344)])
|
|
453 (define-key compose-map "a*" [(?\345)])
|
|
454 (define-key compose-map "ae" [(?\346)])
|
428
|
455
|
2828
|
456 (define-key compose-map "c/" [(?\242)])
|
|
457 (define-key compose-map "c|" [(?\242)])
|
|
458 (define-key compose-map "c0" [(?\251)])
|
|
459 (define-key compose-map "cO" [(?\251)])
|
|
460 (define-key compose-map "co" [(?\251)])
|
|
461 (define-key compose-map "c," [(?\347)])
|
428
|
462
|
2828
|
463 (define-key compose-map "d-" [(?\360)])
|
428
|
464
|
2828
|
465 (define-key compose-map "e`" [(?\350)])
|
|
466 (define-key compose-map "e'" [(?\351)])
|
|
467 (define-key compose-map "e^" [(?\352)])
|
|
468 (define-key compose-map "e\"" [(?\353)])
|
428
|
469
|
2828
|
470 (define-key compose-map "i`" [(?\354)])
|
|
471 (define-key compose-map "i'" [(?\355)])
|
|
472 (define-key compose-map "i^" [(?\356)])
|
|
473 (define-key compose-map "i\"" [(?\357)])
|
|
474 (define-key compose-map "i:" [(?\357)])
|
428
|
475
|
2828
|
476 (define-key compose-map "l-" [(?\243)])
|
|
477 (define-key compose-map "l=" [(?\243)])
|
428
|
478
|
2828
|
479 (define-key compose-map "n~" [(?\361)])
|
428
|
480
|
2828
|
481 (define-key compose-map "oX" [(?\244)])
|
|
482 (define-key compose-map "ox" [(?\244)])
|
|
483 (define-key compose-map "oC" [(?\251)])
|
|
484 (define-key compose-map "oc" [(?\251)])
|
|
485 (define-key compose-map "oR" [(?\256)])
|
|
486 (define-key compose-map "or" [(?\256)])
|
|
487 (define-key compose-map "oS" [(?\247)])
|
|
488 (define-key compose-map "os" [(?\247)])
|
|
489 (define-key compose-map "o_" [(?\272)])
|
|
490 (define-key compose-map "o`" [(?\362)])
|
|
491 (define-key compose-map "o'" [(?\363)])
|
|
492 (define-key compose-map "o^" [(?\364)])
|
|
493 (define-key compose-map "o~" [(?\365)])
|
|
494 (define-key compose-map "o\"" [(?\366)])
|
|
495 (define-key compose-map "o/" [(?\370)])
|
428
|
496
|
2828
|
497 (define-key compose-map "p!" [(?\266)])
|
428
|
498
|
2828
|
499 (define-key compose-map "r0" [(?\256)])
|
|
500 (define-key compose-map "rO" [(?\256)])
|
|
501 (define-key compose-map "ro" [(?\256)])
|
428
|
502
|
2828
|
503 (define-key compose-map "s!" [(?\247)])
|
|
504 (define-key compose-map "s0" [(?\247)])
|
|
505 (define-key compose-map "sO" [(?\247)])
|
|
506 (define-key compose-map "so" [(?\247)])
|
|
507 (define-key compose-map "ss" [(?\337)])
|
428
|
508
|
2828
|
509 (define-key compose-map "th" [(?\376)])
|
428
|
510
|
2828
|
511 (define-key compose-map "u`" [(?\371)])
|
|
512 (define-key compose-map "u'" [(?\372)])
|
|
513 (define-key compose-map "u^" [(?\373)])
|
|
514 (define-key compose-map "u\"" [(?\374)])
|
|
515 (define-key compose-map "u/" [(?\265)])
|
428
|
516
|
2828
|
517 (define-key compose-map "x0" [(?\244)])
|
|
518 (define-key compose-map "xO" [(?\244)])
|
|
519 (define-key compose-map "xo" [(?\244)])
|
|
520 (define-key compose-map "xx" [(?\327)])
|
428
|
521
|
2828
|
522 (define-key compose-map "y-" [(?\245)])
|
|
523 (define-key compose-map "y=" [(?\245)])
|
|
524 (define-key compose-map "y'" [(?\375)])
|
|
525 (define-key compose-map "y\"" [(?\377)])
|
428
|
526
|
2828
|
527 (define-key compose-map "|C" [(?\242)])
|
|
528 (define-key compose-map "|c" [(?\242)])
|
|
529 (define-key compose-map "||" [(?\246)])
|
428
|
530
|
|
531
|
2828
|
532 ;; [[ Suppose we type these three physical keys: [Multi_key " a]
|
428
|
533 ;; Xlib can deliver these keys as the following sequences of keysyms:
|
|
534 ;;
|
|
535 ;; - [Multi_key " a] (no surprise here)
|
|
536 ;; - [adiaeresis] (OK, Xlib is doing compose processing for us)
|
|
537 ;; - [Multi_key " adiaeresis] (Huh?)
|
|
538 ;;
|
|
539 ;; It is the last possibility that is arguably a bug. Xlib can't
|
|
540 ;; decide whether it's really doing compose processing or not (or
|
|
541 ;; actually, different parts of Xlib disagree).
|
|
542 ;;
|
2828
|
543 ;; So we'll just convert [Multi_key " adiaeresis] to [adiaeresis] ]]
|
|
544
|
|
545 (eval-when-compile
|
|
546 (when nil ;; Commenting out.
|
|
547
|
|
548 ;; This _used_ to work with our X11-oriented keysyms above. With them
|
|
549 ;; gone, it won't. The X11 bug it works around should be long dead. (Ha!
|
|
550 ;; Wasn't it cockroaches that would have ruled the planet after World
|
|
551 ;; War III?)
|
|
552
|
|
553 (defun xlib-input-method-bug-workaround (keymap)
|
|
554 (map-keymap
|
|
555 (lambda (key value)
|
|
556 (cond
|
|
557 ((keymapp value)
|
|
558 (xlib-input-method-bug-workaround value))
|
|
559 ((and (sequencep value)
|
|
560 (eq 1 (length value))
|
|
561 (null (lookup-key keymap value)))
|
|
562 (define-key keymap value value))))
|
|
563 keymap))
|
|
564 (xlib-input-method-bug-workaround compose-map)
|
|
565 (unintern 'xlib-input-method-bug-workaround)))
|
428
|
566
|
|
567 ;; While we're at it, a similar mechanism will make colon equivalent
|
|
568 ;; to doublequote for diaeresis processing. Some Xlibs do this.
|
|
569 (defun alias-colon-to-doublequote (keymap)
|
|
570 (map-keymap
|
|
571 (lambda (key value)
|
|
572 (when (keymapp value)
|
|
573 (alias-colon-to-doublequote value))
|
|
574 (when (eq key '\")
|
|
575 (define-key keymap ":" value)))
|
|
576 keymap))
|
|
577 (alias-colon-to-doublequote compose-map)
|
|
578 (unintern 'alias-colon-to-doublequote)
|
|
579
|
|
580 ;;; Electric dead keys: making a' mean a-acute.
|
|
581
|
|
582
|
|
583 (defun electric-diacritic (&optional count)
|
|
584 "Modify the previous character with an accent.
|
|
585 For example, if `:' is bound to this command, then typing `a:'
|
|
586 will first insert `a' and then turn it into `\344' (adiaeresis).
|
|
587 The keys to which this command may be bound (and the accents
|
|
588 which it understands) are:
|
|
589
|
|
590 ' (acute) \301\311\315\323\332\335 \341\351\355\363\372\375
|
|
591 ` (grave) \300\310\314\322\331 \340\350\354\362\371
|
|
592 : (diaeresis) \304\313\317\326\334 \344\353\357\366\374\377
|
|
593 ^ (circumflex) \302\312\316\324\333 \342\352\356\364\373
|
|
594 , (cedilla) \307\347
|
|
595 . (ring) \305\345"
|
|
596 (interactive "p")
|
|
597 (or count (setq count 1))
|
|
598
|
|
599 (if (not (eq last-command 'self-insert-command))
|
|
600 ;; Only do the magic if the two chars were typed in succession.
|
|
601 (self-insert-command count)
|
|
602
|
|
603 ;; This is so that ``a : C-x u'' will transform `adiaeresis' back into `a:'
|
|
604 (self-insert-command count)
|
|
605 (undo-boundary)
|
|
606 (delete-char (- count))
|
|
607
|
|
608 (let* ((c last-command-char)
|
|
609 (map (cond ((eq c ?') compose-acute-map)
|
|
610 ((eq c ?`) compose-grave-map)
|
|
611 ((eq c ?,) compose-cedilla-map)
|
|
612 ((eq c ?:) compose-diaeresis-map)
|
|
613 ((eq c ?^) compose-circumflex-map)
|
|
614 ((eq c ?~) compose-tilde-map)
|
|
615 ((eq c ?.) compose-ring-map)
|
|
616 (t (error "unknown diacritic: %s (%c)" c c))))
|
|
617 (base-char (preceding-char))
|
|
618 (mod-char (and (>= (downcase base-char) ?a) ; only do alphabetics?
|
|
619 (<= (downcase base-char) ?z)
|
|
620 (lookup-key map (make-string 1 base-char)))))
|
|
621 (if (and (vectorp mod-char) (= (length mod-char) 1))
|
|
622 (setq mod-char (aref mod-char 0)))
|
|
623 (if (and mod-char (symbolp mod-char))
|
2828
|
624 (setq mod-char (or (get mod-char 'character-of-keysym) mod-char)))
|
428
|
625 (if (and mod-char (> count 0))
|
|
626 (delete-char -1)
|
|
627 (setq mod-char c))
|
|
628 (while (> count 0)
|
|
629 (insert mod-char)
|
|
630 (setq count (1- count))))))
|
|
631
|
|
632 ;; should "::" mean "¨" and ": " mean ":"?
|
|
633 ;; should we also do
|
|
634 ;; (?~
|
|
635 ;; (?A "\303")
|
|
636 ;; (?C "\307")
|
|
637 ;; (?D "\320")
|
|
638 ;; (?N "\321")
|
|
639 ;; (?O "\325")
|
|
640 ;; (?a "\343")
|
|
641 ;; (?c "\347")
|
|
642 ;; (?d "\360")
|
|
643 ;; (?n "\361")
|
|
644 ;; (?o "\365")
|
|
645 ;; (?> "\273")
|
|
646 ;; (?< "\253")
|
|
647 ;; (? "~")) ; no special code
|
|
648 ;; (?\/
|
|
649 ;; (?A "\305") ;; A-with-ring (Norwegian and Danish)
|
|
650 ;; (?E "\306") ;; AE-ligature (Norwegian and Danish)
|
|
651 ;; (?O "\330")
|
|
652 ;; (?a "\345") ;; a-with-ring (Norwegian and Danish)
|
|
653 ;; (?e "\346") ;; ae-ligature (Norwegian and Danish)
|
|
654 ;; (?o "\370")
|
|
655 ;; (? "/")) ; no special code
|
|
656
|
|
657
|
|
658 ;;; Providing help in the middle of a compose sequence. (Way cool.)
|
|
659
|
|
660 (eval-when-compile
|
|
661 (defsubst next-composable-event ()
|
|
662 (let (event)
|
|
663 (while (progn
|
|
664 (setq event (next-command-event))
|
|
665 (not (or (key-press-event-p event)
|
|
666 (button-press-event-p event))))
|
|
667 (dispatch-event event))
|
|
668 event)))
|
|
669
|
|
670 (defun compose-help (ignore-prompt)
|
|
671 (let* ((keys (apply 'vector (nbutlast (append (this-command-keys) nil))))
|
|
672 (map (or (lookup-key function-key-map keys)
|
|
673 (error "can't find map? %s %s" keys (this-command-keys))))
|
|
674 binding)
|
|
675 (save-excursion
|
|
676 (with-output-to-temp-buffer "*Help*"
|
|
677 (set-buffer "*Help*")
|
|
678 (erase-buffer)
|
|
679 (message "Working...")
|
|
680 (setq ctl-arrow 'compose) ; non-t-non-nil
|
|
681 (insert "You are typing a compose sequence. So far you have typed: ")
|
|
682 (insert (key-description keys))
|
|
683 (insert "\nCompletions from here are:\n\n")
|
|
684 (map-keymap 'compose-help-mapper map t)
|
|
685 (message "? ")))
|
|
686 (while (keymapp map)
|
|
687 (setq binding (lookup-key map (vector (next-composable-event))))
|
|
688 (if (null binding)
|
|
689 (message "No such key in keymap. Try again.")
|
|
690 (setq map binding)))
|
|
691 binding))
|
|
692
|
|
693 (put 'compose-help 'isearch-command t) ; so that it doesn't terminate isearch
|
|
694
|
|
695 (defun compose-help-mapper (key binding)
|
|
696 (if (and (symbolp key)
|
2828
|
697 (get key 'character-of-keysym))
|
|
698 (setq key (get key 'character-of-keysym)))
|
428
|
699 (if (eq binding 'compose-help) ; suppress that...
|
|
700 nil
|
|
701 (if (keymapp binding)
|
|
702 (let ((p (point)))
|
|
703 (map-keymap 'compose-help-mapper binding t)
|
|
704 (goto-char p)
|
|
705 (while (not (eobp))
|
|
706 (if (characterp key)
|
|
707 (insert (make-string 1 key))
|
|
708 (insert (single-key-description key)))
|
|
709 (insert " ")
|
|
710 (forward-line 1)))
|
|
711 (if (characterp key)
|
|
712 (insert (make-string 1 key))
|
|
713 (insert (single-key-description key)))
|
|
714 (indent-to 16)
|
|
715 (let ((code (and (vectorp binding)
|
|
716 (= 1 (length binding))
|
2828
|
717 (get (aref binding 0) 'character-of-keysym))))
|
428
|
718 (if code
|
|
719 (insert (make-string 1 code))
|
|
720 (if (stringp binding)
|
|
721 (insert binding)
|
|
722 (insert (prin1-to-string binding)))))
|
|
723 (when (and (vectorp binding) (= 1 (length binding)))
|
|
724 (indent-to 32)
|
|
725 (insert (symbol-name (aref binding 0)))))
|
|
726 (insert "\n")))
|
|
727
|
|
728 ;; define it at top-level in the compose map...
|
|
729 ;;(define-key compose-map [(control h)] 'compose-help)
|
|
730 ;;(define-key compose-map [help] 'compose-help)
|
|
731 ;; and then define it in each sub-map of the compose map.
|
|
732 (map-keymap
|
|
733 (lambda (key binding)
|
|
734 (when (keymapp binding)
|
|
735 ;; (define-key binding [(control h)] 'compose-help)
|
|
736 ;; (define-key binding [help] 'compose-help)
|
|
737 ))
|
|
738 compose-map nil)
|
|
739
|
|
740 ;; Make redisplay display the accented letters
|
|
741 (if (memq (default-value 'ctl-arrow) '(t nil))
|
|
742 (setq-default ctl-arrow 'iso-8859/1))
|
|
743
|
|
744
|
|
745 (provide 'x-compose)
|
|
746
|
|
747 ;;; x-compose.el ends here
|