Mercurial > emacs
annotate lisp/international/iso-acc.el @ 4743:f05c414fe229
Add #undef HAVE_RES_INIT.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 19 Sep 1993 19:28:39 +0000 |
parents | 488d0b668380 |
children | 4c51d8a8b09f |
rev | line source |
---|---|
4720 | 1 ;;; iso-acc.el -- minor mode providing electric accent keys |
2 ;;; Copyright (C) 1993 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Johan Vromans <jv@mh.nl> | |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
5 ;; Version: 1.7 |
4720 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
23 ;;; Commentary: | |
24 | |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
25 ;; Function `iso-accents-mode' activates a minor mode |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
26 ;; (`iso-accents-minor-mode') in which typewriter "dead keys" are |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
27 ;; emulated. The purpose of this emulation is to provide a simple |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
28 ;; means for inserting accented characters according to the ISO-8859-1 |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
29 ;; character set. |
4720 | 30 ;; |
31 ;; In `iso-accents-minor-mode', pseudo accent characters are used to | |
32 ;; introduce accented keys. The pseudo-accent characterss are: | |
33 ;; | |
34 ;; ' (minute) -> grave accent | |
35 ;; ` (backtick) -> acute accent | |
36 ;; " (second) -> diaeresis | |
37 ;; ^ (caret) -> circonflexe | |
38 ;; | |
39 ;; The action taken depends on the key that follows the pseudo accent. | |
40 ;; In general: | |
41 ;; | |
42 ;; pseudo-accent + appropriate letter -> accented letter | |
43 ;; pseudo-accent + space -> pseudo-accent | |
44 ;; pseudo-accent + pseudo-accent -> accent (if available) | |
45 ;; pseudo-accent + other -> pseudo-accent + other | |
46 ;; | |
47 ;; If the pseudo-accent is followed by anything else than a | |
48 ;; self-insert-command, the dead-key code is terminated, the | |
49 ;; pseudo-accent inserted 'as is' and the bell is rung to signal this. | |
50 ;; | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
51 ;; Function `iso-accents-mode' can be used to enable the iso accents |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
52 ;; minor mode, or disable it. |
4720 | 53 |
54 ;;; Code: | |
55 | |
56 (provide 'iso-acc) | |
57 | |
58 (defvar iso-accents-list | |
59 '(((?' ?A) ?\301) | |
60 ((?' ?E) ?\311) | |
61 ((?' ?I) ?\315) | |
62 ((?' ?O) ?\323) | |
63 ((?' ?U) ?\332) | |
64 ((?' ?a) ?\341) | |
65 ((?' ?e) ?\351) | |
66 ((?' ?i) ?\355) | |
67 ((?' ?o) ?\363) | |
68 ((?' ?u) ?\372) | |
69 ((?' ?') ?\264) | |
70 ((?' ? ) ?') | |
71 ((?` ?A) ?\300) | |
72 ((?` ?E) ?\310) | |
73 ((?` ?I) ?\314) | |
74 ((?` ?O) ?\322) | |
75 ((?` ?U) ?\331) | |
76 ((?` ?a) ?\340) | |
77 ((?` ?e) ?\350) | |
78 ((?` ?i) ?\354) | |
79 ((?` ?o) ?\362) | |
80 ((?` ?u) ?\371) | |
81 ((?` ? ) ?`) | |
82 ((?` ?`) ?`) ; no special code? | |
83 ((?` ?A) ?\302) | |
84 ((?^ ?E) ?\312) | |
85 ((?^ ?I) ?\316) | |
86 ((?^ ?O) ?\324) | |
87 ((?^ ?U) ?\333) | |
88 ((?^ ?a) ?\342) | |
89 ((?^ ?e) ?\352) | |
90 ((?^ ?i) ?\356) | |
91 ((?^ ?o) ?\364) | |
92 ((?^ ?u) ?\373) | |
93 ((?^ ? ) ?^) | |
94 ((?^ ?^) ?^) ; no special code? | |
95 ((?\" ?A) ?\304) | |
96 ((?\" ?E) ?\313) | |
97 ((?\" ?I) ?\317) | |
98 ((?\" ?O) ?\326) | |
99 ((?\" ?U) ?\334) | |
100 ((?\" ?a) ?\344) | |
101 ((?\" ?e) ?\353) | |
102 ((?\" ?i) ?\357) | |
103 ((?\" ?o) ?\366) | |
104 ((?\" ?u) ?\374) | |
105 ((?\" ? ) ?\") | |
106 ((?\" ?\") ?\250) | |
107 ) | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
108 "Association list for ISO accent combinations.") |
4720 | 109 |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
110 (defun iso-accents-accent-key () |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
111 "Modify the following character by adding an accent to it." |
4720 | 112 (interactive) |
113 | |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
114 ;; Pick up the accent character. |
4720 | 115 (let ((first-char last-command-char)) |
116 | |
117 ;; Display it and backup. | |
118 (insert first-char) | |
119 (backward-char 1) | |
120 | |
121 ;; Wait for the second key and look up the combination in the list. | |
122 (let* ((second-char (read-event)) | |
123 (entry (assoc (list first-char second-char) iso-accents-list))) | |
124 (if entry | |
125 ;; Found it: delete the first character and insert the combination. | |
126 (progn | |
127 (delete-char 1) | |
128 (insert (car (cdr entry)))) | |
129 | |
130 ;; Otherwise, advance and schedule the second key for execution. | |
131 (forward-char 1) | |
132 (setq unread-command-events (list second-char)) | |
133 | |
134 ;; If it is not a self-insert-command, ring the terminal bell. | |
135 (or (eq (key-binding (make-vector 1 second-char)) 'self-insert-command) | |
136 (beep 1)))))) | |
137 | |
138 (defvar iso-accents-minor-mode nil | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
139 "*Non-nil enables ISO-accents mode. |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
140 Setting this variable makes it local to the current buffer. |
4734
488d0b668380
Fix typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
4733
diff
changeset
|
141 See `iso-accents-mode'.") |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
142 (make-variable-buffer-local 'iso-accents-minor-mode) |
4720 | 143 |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
144 ;; A minor mode map `iso-accents-prefix-map' is used to activate the |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
145 ;; dead key handling depending on the value of iso-accents-minor-mode. |
4720 | 146 (defvar iso-accents-prefix-map nil |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
147 "Keymap for ISO-accents minor mode.") |
4720 | 148 |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
149 ;; Create the minor-mode keymap, if needed. |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
150 (or iso-accents-prefix-map |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
151 (progn |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
152 (setq iso-accents-prefix-map (make-sparse-keymap)) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
153 (define-key iso-accents-prefix-map "'" 'iso-accents-dead-key) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
154 (define-key iso-accents-prefix-map "`" 'iso-accents-dead-key) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
155 (define-key iso-accents-prefix-map "^" 'iso-accents-dead-key) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
156 (define-key iso-accents-prefix-map "\"" 'iso-accents-dead-key))) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
157 |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
158 ;; Add the dead key minor mode map to the minor mode maps. |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
159 (or (assq 'iso-accents-minor-mode minor-mode-map-alist) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
160 (setq minor-mode-map-alist |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
161 (cons (cons 'iso-accents-minor-mode iso-accents-prefix-map) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
162 minor-mode-map-alist))) |
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
163 |
4720 | 164 ;; It is a matter of taste if you want the minor mode indicated |
165 ;; in the mode line... | |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
166 ;; If so, uncomment the next four lines. |
4720 | 167 ;; (or (assq 'iso-accents-minor-mode minor-mode-map-alist) |
168 ;; (setq minor-mode-alist | |
169 ;; (append minor-mode-alist | |
170 ;; '((iso-accents-minor-mode " ISO-Acc"))))) | |
171 | |
172 ;;;###autoload | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
173 (defun iso-accents-mode (&optional arg) |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
174 "Toggle a minor mode in which accents modify the following letter. |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
175 This permits easy insertion of accented characters according to ISO-8859-1. |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
176 When Iso-accents mode is enabled, accent character keys |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
177 \(', \", ^ and ~) do not self-insert; instead, they modify the following |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
178 letter key so that it inserts an ISO accented letter. |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
179 |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
180 With an argument, a positive argument enables ISO-accents mode, |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
181 and a negative argument disables it." |
4720 | 182 |
183 (interactive "P") | |
184 | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
185 (if (if arg |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
186 ;; Negative arg means switch it off. |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
187 (<= (prefix-numeric-value arg) 0) |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
188 ;; No arg means toggle. |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
189 iso-accents-minor-mode) |
4720 | 190 (setq iso-accents-minor-mode nil) |
191 | |
192 ;; Enable electric accents. | |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
193 (setq iso-accents-minor-mode t))) |
4720 | 194 |
195 ;;; iso-acc.el ends here |