annotate lisp/iso/iso-acc.el @ 88:821dec489c24 r20-0

Import from CVS: tag r20-0
author cvs
date Mon, 13 Aug 2007 09:09:59 +0200
parents 131b0175ea99
children 1040fe1366ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; iso-acc.el --- minor mode providing electric accent keys
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Author: Johan Vromans <jv@mh.nl>
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
6 ;; Version: 1.8
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
7 ;; Maintainer: FSF
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;; Keywords: i18n
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
9 ;; Adapted to XEmacs 19.14 by Alexandre Oliva <oliva@dcc.unicamp.br>
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
10 ;; Last update: Jan 25, 1997
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; GNU General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 ;; Function `iso-accents-mode' activates a minor mode in which
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32 ;; typewriter "dead keys" are emulated. The purpose of this emulation
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33 ;; is to provide a simple means for inserting accented characters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 ;; according to the ISO-8859-1 character set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36 ;; In `iso-accents-mode', pseudo accent characters are used to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37 ;; introduce accented keys. The pseudo-accent characters are:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 ;; ' (minute) -> grave accent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 ;; ` (backtick) -> acute accent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41 ;; " (second) -> diaeresis
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 ;; ^ (caret) -> circumflex
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 ;; ~ (tilde) -> tilde over the character
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
44 ;; / (slash) -> slash through the character.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
45 ;; , (cedilla) -> cedilla under the character (except on default mode).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
46 ;; Also: /A is A-with-ring and /E is AE ligature.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48 ;; The action taken depends on the key that follows the pseudo accent.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 ;; In general:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 ;; pseudo-accent + appropriate letter -> accented letter
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
52 ;; pseudo-accent + space -> pseudo-accent (except for comma)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 ;; pseudo-accent + pseudo-accent -> accent (if available)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 ;; pseudo-accent + other -> pseudo-accent + other
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 ;; If the pseudo-accent is followed by anything else than a
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 ;; self-insert-command, the dead-key code is terminated, the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 ;; pseudo-accent inserted 'as is' and the bell is rung to signal this.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 ;; Function `iso-accents-mode' can be used to enable the iso accents
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 ;; minor mode, or disable it.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 ;; If you want only some of these characters to serve as accents,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 ;; add a language to `iso-languages' which specifies the accent characters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 ;; that you want, then select the language with `iso-accents-customize'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 (provide 'iso-acc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 ;; needed for compatibility with XEmacs 19.14
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (if (fboundp 'read-event) ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 (defun read-event () (event-key (next-command-event))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
75 ;; needed to work on GNU Emacs (had to use this function on XEmacs)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
76 (if (fboundp 'character-to-event) ()
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
77 (defun character-to-event (ch &optional event console meta)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
78 (if (listp ch) (car ch) ch)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 ;; needed for compatibility with XEmacs 19.14 and GNU Emacs 19.30
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 (if (fboundp 'this-single-command-keys) ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (if (string-match "Lucid" (version))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 (defun this-single-command-keys ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 (setq this-command (not (this-command-keys)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (this-command-keys))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 (defun this-single-command-keys () (this-command-keys))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 (defvar iso-languages
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 '(("portuguese"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (?C . ?\307) (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (?u . ?\372) (?c . ?\347) (?\ . ?') (space . ?'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 (?` (?A . ?\300) (?a . ?\340) (?\ . ?`) (space . ?`))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94 (?^ (?A . ?\302) (?E . ?\312) (?O . ?\324) (?a . ?\342) (?e . ?\352)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 (?o . ?\364) (?\ . ?^) (space . ?^))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 (?\" (?U . ?\334) (?u . ?\374) (?\ . ?\") (space . ?\"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
97 (?\~ (?A . ?\303) (?O . ?\325) (?a . ?\343) (?o . ?\365) (?\ . ?\~) (space . ?\~))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 (?, (?c . ?\347) (?C . ?\307)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 ("irish"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101 (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363) (?u . ?\372)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 (?\ . ?') (space . ?')))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 ("french"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
106 (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
107 (?C . ?\307) (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
108 (?u . ?\372) (?c . ?\347) (?\ . ?') (space . ?'))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
109 (?` (?A . ?\300) (?E . ?\310) (?a . ?\340) (?e . ?\350) (?\ . ?`) (space . ?`))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 (?^ (?A . ?\302) (?E . ?\312) (?I . ?\316) (?O . ?\324) (?U . ?\333)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 (?a . ?\342) (?e . ?\352) (?i . ?\356) (?o . ?\364) (?u . ?\373)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 (?\ . ?^) (space . ?^))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
113 (?\" (?U . ?\334) (?u . ?\374) (?\ . ?\") (space . ?\"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
114 (?\~ (?A . ?\303) (?O . ?\325) (?a . ?\343) (?o . ?\365) (?\ . ?\~) (space . ?\~))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (?, (?c . ?\347) (?C . ?\307)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 ("latin-2"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 (?' (?A . ?\301) (?C . ?\306) (?D . ?\320) (?E . ?\311) (?I . ?\315)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 (?L . ?\305) (?N . ?\321) (?O . ?\323) (?R . ?\300) (?S . ?\246)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120 (?U . ?\332) (?Y . ?\335) (?Z . ?\254) (?a . ?\341) (?c . ?\346)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121 (?d . ?\360) (?e . ?\351) (?i . ?\355) (?l . ?\345) (?n . ?\361)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 (?o . ?\363) (?r . ?\340) (?s . ?\266) (?u . ?\372) (?y . ?\375)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 (?z . ?\274) (?' . ?\264) (?\ . ?') (space . ?'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 (?` (?A . ?\241) (?C . ?\307) (?E . ?\312) (?L . ?\243) (?S . ?\252)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (?T . ?\336) (?Z . ?\257) (?a . ?\261) (?l . ?\263) (?c . ?\347)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 (?e . ?\352) (?s . ?\272) (?t . ?\376) (?z . ?\277) (?` . ?\252)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 (?. . ?\377) (?\ . ?`) (space . ?`))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 (?^ (?A . ?\302) (?O . ?\324) (?a . ?\342) (?o . ?\364)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 (?^ . ?^) ; no special code?
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130 (?\ . ?^) (space . ?^))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 (?\" (?A . ?\304) (?E . ?\313) (?O . ?\326) (?U . ?\334) (?a . ?\344)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 (?e . ?\353) (?o . ?\366) (?s . ?\337) (?u . ?\374) (?\" . ?\250)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133 (?\ . ?\") (space . ?\"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (?\~ (?A . ?\303) (?C . ?\310) (?D . ?\317) (?L . ?\245) (?N . ?\322)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (?O . ?\325) (?R . ?\330) (?S . ?\251) (?T . ?\253) (?U . ?\333)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (?Z . ?\256) (?a . ?\323) (?c . ?\350) (?d . ?\357) (?l . ?\265)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 (?n . ?\362) (?o . ?\365) (?r . ?\370) (?s . ?\271) (?t . ?\273)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 (?u . ?\373) (?z . ?\276)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 (?v . ?\242) ; v accent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (?\~ . ?\242) ; v accent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 (?\. . ?\270) ; cedilla accent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142 (?\ . ?\~) (space . ?\~)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 ("latin-1"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146 (?Y . ?\335) (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 (?u . ?\372) (?y . ?\375) (?' . ?\264) (?\ . ?') (space . ?'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 (?` (?A . ?\300) (?E . ?\310) (?I . ?\314) (?O . ?\322) (?U . ?\331)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 (?a . ?\340) (?e . ?\350) (?i . ?\354) (?o . ?\362) (?u . ?\371)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 (?` . ?`) (?\ . ?`) (space . ?`))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 (?^ (?A . ?\302) (?E . ?\312) (?I . ?\316) (?O . ?\324) (?U . ?\333)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 (?a . ?\342) (?e . ?\352) (?i . ?\356) (?o . ?\364) (?u . ?\373)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153 (?^ . ?^) (?\ . ?^) (space . ?^))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154 (?\" (?A . ?\304) (?E . ?\313) (?I . ?\317) (?O . ?\326) (?U . ?\334)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 (?a . ?\344) (?e . ?\353) (?i . ?\357) (?o . ?\366) (?s . ?\337)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156 (?u . ?\374) (?y . ?\377) (?\" . ?\250) (?\ . ?\") (space . ?\"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (?\~ (?A . ?\303) (?C . ?\307) (?D . ?\320) (?N . ?\321) (?O . ?\325)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 (?T . ?\336) (?a . ?\343) (?c . ?\347) (?d . ?\360) (?n . ?\361)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 (?o . ?\365) (?t . ?\376) (?> . ?\273) (?< . ?\253) (?\~ . ?\270)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 (?! . ?\241) (?? . ?\277)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161 (?\ . ?\~) (space . ?\~))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (?\/ (?A . ?\305) (?E . ?\306) (?O . ?\330) (?a . ?\345) (?e . ?\346)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 (?o . ?\370) (?\/ . ?\260) (?\ . ?\/) (space . ?\/))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164 "List of language-specific customizations for the ISO Accents mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 Each element of the list is of the form
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 (LANGUAGE
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 (PSEUDO-ACCENT MAPPINGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 (PSEUDO-ACCENT MAPPINGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 ...)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 LANGUAGE is a string naming the language.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 PSEUDO-ACCENT is a char specifying an accent key.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175 MAPPINGS are cons cells of the form (CHAR . ISO-CHAR).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177 The net effect is that the key sequence PSEUDO-ACCENT CHAR is mapped
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 to ISO-CHAR on input.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180 (defvar iso-language nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181 "Language for which ISO Accents mode is currently customized.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182 Change it with the `iso-accents-customize' function.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184 (defvar iso-accents-list nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 "Association list for ISO accent combinations, for the chosen language.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 (defvar iso-accents-mode nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 "*Non-nil enables ISO Accents mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
189 Setting this variable makes it local to the current buffer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190 See the function `iso-accents-mode'.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191 (make-variable-buffer-local 'iso-accents-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
193 (defvar iso-accents-enable '(?' ?` ?^ ?\" ?~ ?/ ?,)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 "*List of accent keys that become prefixes in ISO Accents mode.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
195 The default is (?' ?` ?^ ?\" ?~ ?/ ?,), which contains all the supported
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 accent keys. If you set this variable to a list in which some of those
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 characters are missing, the missing ones do not act as accents.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 Note that if you specify a language with `iso-accents-customize',
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 that can also turn off certain prefixes (whichever ones are not needed in
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 the language you choose).")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 (defun iso-accents-accent-key (prompt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 "Modify the following character by adding an accent to it."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205 ;; Pick up the accent character.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (if (and iso-accents-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 (memq last-input-char iso-accents-enable))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 (iso-accents-compose prompt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 (char-to-string last-input-char)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 (defun iso-accents-compose (prompt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 (let* ((first-char last-input-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213 (list (assq first-char iso-accents-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 ;; Wait for the second key and look up the combination.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215 (second-char (if (or prompt
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216 (not (eq (key-binding "a")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 'self-insert-command))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 ;; Not at start of a key sequence.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 (> (length (this-single-command-keys)) 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 ;; Called from anything but the command loop.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 this-command)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 (message "%s%c"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 (or prompt "Compose with ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 first-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 (read-event))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (insert first-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (prog1 (read-event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (delete-region (1- (point)) (point)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 (entry (cdr (assq second-char list))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (if entry
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
232 ;; Found it: insert the accented character and
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
233 ;; return a do-nothing key
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
234 (vector (character-to-event (list entry)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 ;; Otherwise, advance and schedule the second key for execution.
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
236 (setq unread-command-events (append
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
237 (list
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
238 (character-to-event (list second-char)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
239 unread-command-events))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
240 (vector (character-to-event (list first-char))))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 ;; It is a matter of taste if you want the minor mode indicated
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 ;; in the mode line...
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 ;; If so, uncomment the next four lines.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 ;; (or (assq 'iso-accents-mode minor-mode-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 ;; (setq minor-mode-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 ;; (append minor-mode-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 ;; '((iso-accents-mode " ISO-Acc")))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 ;;;###autoload
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (defun iso-accents-mode (&optional arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 "Toggle ISO Accents mode, in which accents modify the following letter.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 This permits easy insertion of accented characters according to ISO-8859-1.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 When Iso-accents mode is enabled, accent character keys
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 \(`, ', \", ^, / and ~) do not self-insert; instead, they modify the following
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 letter key so that it inserts an ISO accented letter.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 You can customize ISO Accents mode to a particular language
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 with the command `iso-accents-customize'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 Special combinations: ~c gives a c with cedilla,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 ~d gives an Icelandic eth (d with dash).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263 ~t gives an Icelandic thorn.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 \"s gives German sharp s.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 /a gives a with ring.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 /e gives an a-e ligature.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 ~< and ~> give guillemots.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 ~! gives an inverted exclamation mark.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 ~? gives an inverted question mark.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 With an argument, a positive argument enables ISO Accents mode,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 and a negative argument disables it."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 (if (if arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 ;; Negative arg means switch it off.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 (<= (prefix-numeric-value arg) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 ;; No arg means toggle.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 iso-accents-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 (setq iso-accents-mode nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 ;; Enable electric accents.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 (setq iso-accents-mode t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
286 (defvar iso-accents-mode-map nil)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
287
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 (defun iso-accents-customize (language)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289 "Customize the ISO accents machinery for a particular language.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290 It selects the customization based on the specifications in the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 `iso-languages' variable."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 (interactive (list (completing-read "Language: " iso-languages nil t)))
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
293 (let ((table (assoc language iso-languages)) tail acc)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 (if (not table)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
295 (error "Unknown language '%s'" language)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296 (setq iso-language language
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 iso-accents-list (cdr table))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 (if key-translation-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 (substitute-key-definition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300 'iso-accents-accent-key nil key-translation-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 (setq key-translation-map (make-sparse-keymap)))
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
302 (setq iso-accents-mode-map (make-sparse-keymap))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
303 (let ((pair (assoc 'iso-accents-mode minor-mode-map-alist)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
304 (if pair
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
305 (setcdr pair iso-accents-mode-map)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
306 (let ((l minor-mode-map-alist))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
307 (while (cdr l)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
308 (setq l (cdr l)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
309 (setcdr l (list (cons 'iso-accents-mode iso-accents-mode-map))))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310 ;; Set up translations for all the characters that are used as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 ;; accent prefixes in this language.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 (setq tail iso-accents-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 (while tail
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
314 (define-key key-translation-map
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
315 (vector (character-to-event (list (car (car tail)))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316 'iso-accents-accent-key)
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
317 (setq acc (cdr (car tail)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
318 (while acc
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
319 (define-key iso-accents-mode-map
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
320 (vector (character-to-event (list (cdr (car acc)))))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
321 'iso-accents-self-insert-unless-redefined)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
322 (setq acc (cdr acc)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 (setq tail (cdr tail))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324
88
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
325 (defun iso-accents-self-insert-unless-redefined (prompt)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
326 "Temporarily disables iso-accents-mode, and checks for additional bindings of the keys that produced its invocation. If no such binding is found, 'self-insert-command is returned"
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
327 (interactive "p")
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
328 (let* ((iso-accents-mode nil)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
329 (bind (key-binding (this-command-keys)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
330 (repeat t) result)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
331 (while repeat
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
332 (setq result
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
333 (cond ((or (null bind)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
334 (eq bind 'self-insert-command))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
335 (setq repeat nil)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
336 (self-insert-command prompt))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
337 ((commandp bind)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
338 (setq repeat nil)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
339 (call-interactively bind))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
340 ((or (stringp bind)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
341 (keymapp bind))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
342 (setq repeat nil)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
343 bind)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
344 ((and (consp bind)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
345 (stringp (car bind)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
346 (setq bind (cdr bind)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
347 ((and (consp bind)
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
348 (keymapp (car bind)))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
349 (setq bind (lookup-key (car bind) (cdr bind))))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
350 (t (error "Invalid key binding")))))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
351 result))
821dec489c24 Import from CVS: tag r20-0
cvs
parents: 70
diff changeset
352
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
353 (defun iso-accentuate (start end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
354 "Convert two-character sequences in region into accented characters.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
355 Noninteractively, this operates on text from START to END.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
356 This uses the same conversion that ISO Accents mode uses for type-in."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
357 (interactive "r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
358 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
359 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
360 (narrow-to-region start end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
361 (goto-char start)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
362 (forward-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
363 (let (entry)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
364 (while (< (point) end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
365 (if (and (memq (preceding-char) iso-accents-enable)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
366 (setq entry (cdr (assq (following-char) (assq (preceding-char) iso-accents-list)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
367 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
368 (forward-char -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
369 (delete-char 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
370 (insert entry)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
371 (setq end (1- end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
372 (forward-char 1)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
373
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
374 (defun iso-accent-rassoc-unit (value alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
375 (let (elt acc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
376 (while (and alist (not elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
377 (setq acc (car (car alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
378 elt (car (rassq value (cdr (car alist))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
379 alist (cdr alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
380 (if elt
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
381 (cons acc elt))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
382
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
383 (defun iso-unaccentuate (start end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
384 "Convert accented characters in the region into two-character sequences.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
385 Noninteractively, this operates on text from START to END.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
386 This uses the opposite of the conversion done by ISO Accents mode for type-in."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
387 (interactive "r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
388 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
389 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
390 (narrow-to-region start end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
391 (goto-char start)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
392 (let (entry)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
393 (while (< (point) end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
394 (if (and (> (following-char) 127)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
395 (setq entry (iso-accent-rassoc-unit (following-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
396 iso-accents-list)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
397 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
398 (delete-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
399 (insert (car entry) (cdr entry))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
400 (setq end (1+ end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
401 (forward-char 1)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
402
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
403 (defun iso-deaccentuate (start end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
404 "Convert accented characters in the region into unaccented characters.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
405 Noninteractively, this operates on text from START to END."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
406 (interactive "r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
407 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
408 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
409 (narrow-to-region start end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
410 (goto-char start)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
411 (let (entry)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
412 (while (< (point) end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
413 (if (and (> (following-char) 127)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
414 (setq entry (iso-accent-rassoc-unit (following-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
415 iso-accents-list)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
416 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
417 (delete-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
418 (insert (cdr entry)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
419 (forward-char 1)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
420
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
421 ;; Set up the default settings.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
422 (iso-accents-customize "latin-1")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
423
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
424 ;; Use Iso-Accents mode in the minibuffer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
425 ;; if it was in use in the previous buffer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
426 (defun iso-acc-minibuf-setup ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
427 (setq iso-accents-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
428 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
429 (set-buffer (window-buffer minibuffer-scroll-window))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
430 iso-accents-mode)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
431
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
432 (add-hook 'minibuf-setup-hook 'iso-acc-minibuf-setup)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
433
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
434 ;;; iso-acc.el ends here