Mercurial > emacs
annotate lisp/international/iso-acc.el @ 4889:8b896067d6fb
(ispell): If the buffer to spell has no associated file, or, the
associated file has a special handler, use a temporary file with the
buffer contents to pass to the local ispell process.
author | Brian Fox <bfox@gnu.org> |
---|---|
date | Mon, 25 Oct 1993 06:18:23 +0000 |
parents | 4c51d8a8b09f |
children | e96cc77d9a7c |
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 |
110 (defvar iso-accents-minor-mode nil | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
111 "*Non-nil enables ISO-accents mode. |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
112 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
|
113 See `iso-accents-mode'.") |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
114 (make-variable-buffer-local 'iso-accents-minor-mode) |
4720 | 115 |
4877
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
116 (defun iso-accents-accent-key (prompt) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
117 "Modify the following character by adding an accent to it." |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
118 ;; Pick up the accent character. |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
119 (if iso-accents-minor-mode |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
120 (iso-accents-compose prompt) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
121 (char-to-string last-input-char))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
122 |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
123 (defun iso-accents-compose-key (prompt) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
124 "Modify the following character by adding an accent to it." |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
125 ;; Pick up the accent character. |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
126 (let ((combined (iso-accents-compose prompt))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
127 (if unread-command-events |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
128 (let ((unread unread-command-events)) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
129 (setq unread-command-events nil) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
130 (error "Characters %s and %s cannot be composed" |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
131 (single-key-description (aref combined 0)) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
132 (single-key-description (car unread))))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
133 combined)) |
4720 | 134 |
4877
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
135 (defun iso-accents-compose (prompt) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
136 (let* ((first-char last-input-char) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
137 ;; Wait for the second key and look up the combination. |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
138 (second-char (if (or prompt |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
139 (not (eq (key-binding "a") |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
140 'self-insert-command))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
141 (progn |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
142 (message "%s%c" |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
143 (or prompt "Compose with ") |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
144 first-char) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
145 (read-event)) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
146 (insert first-char) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
147 (prog1 (read-event) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
148 (delete-region (1- (point)) (point))))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
149 (entry (assoc (list first-char second-char) iso-accents-list))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
150 (if entry |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
151 ;; Found it: delete the first character and insert the combination. |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
152 (concat (list (nth 1 entry))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
153 ;; Otherwise, advance and schedule the second key for execution. |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
154 (setq unread-command-events (list second-char)) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
155 (vector first-char)))) |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
156 |
4877
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
157 (or key-translation-map (setq key-translation-map (make-sparse-keymap))) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
158 ;; For sequences starting with an accent character, |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
159 ;; use a function that tests iso-accents-minor-mode. |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
160 (define-key key-translation-map "'" 'iso-accents-accent-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
161 (define-key key-translation-map "`" 'iso-accents-accent-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
162 (define-key key-translation-map "^" 'iso-accents-accent-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
163 (define-key key-translation-map "\"" 'iso-accents-accent-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
164 ;; For sequences starting with a compose key, |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
165 ;; always do the compose processing. |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
166 (define-key key-translation-map [compose ?\'] 'iso-accents-compose-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
167 (define-key key-translation-map [compose ?\`] 'iso-accents-compose-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
168 (define-key key-translation-map [compose ?^] 'iso-accents-compose-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
169 (define-key key-translation-map [compose ?\"] 'iso-accents-compose-key) |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
170 ;; The way to make compose work is to translate some other key sequence |
4c51d8a8b09f
Define "dead keys" in key-translation-map, not in global-map.
Richard M. Stallman <rms@gnu.org>
parents:
4734
diff
changeset
|
171 ;; into it, using key-translation-map. |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
172 |
4720 | 173 ;; It is a matter of taste if you want the minor mode indicated |
174 ;; in the mode line... | |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
175 ;; If so, uncomment the next four lines. |
4720 | 176 ;; (or (assq 'iso-accents-minor-mode minor-mode-map-alist) |
177 ;; (setq minor-mode-alist | |
178 ;; (append minor-mode-alist | |
179 ;; '((iso-accents-minor-mode " ISO-Acc"))))) | |
180 | |
181 ;;;###autoload | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
182 (defun iso-accents-mode (&optional arg) |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
183 "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
|
184 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
|
185 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
|
186 \(', \", ^ 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
|
187 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
|
188 |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
189 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
|
190 and a negative argument disables it." |
4720 | 191 |
192 (interactive "P") | |
193 | |
4721
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
194 (if (if arg |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
195 ;; Negative arg means switch it off. |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
196 (<= (prefix-numeric-value arg) 0) |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
197 ;; No arg means toggle. |
d34c02ddea9f
Fix lots of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
4720
diff
changeset
|
198 iso-accents-minor-mode) |
4720 | 199 (setq iso-accents-minor-mode nil) |
200 | |
201 ;; Enable electric accents. | |
4733
4d378f483cf4
Set up keymap at load time.
Richard M. Stallman <rms@gnu.org>
parents:
4721
diff
changeset
|
202 (setq iso-accents-minor-mode t))) |
4720 | 203 |
204 ;;; iso-acc.el ends here |