aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-06-21 07:37:53 +0000
committerRichard M. Stallman1997-06-21 07:37:53 +0000
commitf23515e161b366ac32b8445f66c02022aa4c964d (patch)
tree3b4ea6bb5e91b31b2c3f8024f8a6c6508916cf3d
parentcbc7d8924158d489def0c744dc36cc0dc9742a14 (diff)
downloademacs-f23515e161b366ac32b8445f66c02022aa4c964d.tar.gz
emacs-f23515e161b366ac32b8445f66c02022aa4c964d.zip
Doc fixes.
(ogonek-jak, ogonek-how): Examples of customization fixed.
-rw-r--r--lisp/international/ogonek.el325
1 files changed, 159 insertions, 166 deletions
diff --git a/lisp/international/ogonek.el b/lisp/international/ogonek.el
index 044012d392a..932dc44ecf5 100644
--- a/lisp/international/ogonek.el
+++ b/lisp/international/ogonek.el
@@ -56,55 +56,55 @@
56 136 141 171 184 196 151 230 144 253)) 56 136 141 171 184 196 151 230 144 253))
57 ) 57 )
58 "The constant `ogonek-name-encoding-alist' is a list of (NAME.LIST) pairs. 58 "The constant `ogonek-name-encoding-alist' is a list of (NAME.LIST) pairs.
59Each LIST contains codes for 18 Polish diacritic characters. 59Each LIST contains codes for 18 Polish diacritic characters. The codes
60The codes are given in the following order: 60are given in the following order:
61 Aogonek Cacute Eogonek Lslash Nacute Oacute Sacute Zacute Zdotaccent 61 Aogonek Cacute Eogonek Lslash Nacute Oacute Sacute Zacute Zdotaccent
62 aogonek cacute eogonek lslash nacute oacute sacute zacute zdotaccent.") 62 aogonek cacute eogonek lslash nacute oacute sacute zacute zdotaccent.")
63 63
64; ------ A Little Info in Polish --------------- 64;; ------ A Little Info in Polish ---------------
65 65
66(defconst ogonek-informacja 66(defconst ogonek-informacja
67 " FUNKCJE INTERAKCYJNE UDOST/EPNIANE PRZEZ BIBLIOTEK/E `ogonek' 67 " FUNKCJE INTERAKCYJNE UDOST/EPNIANE PRZEZ BIBLIOTEK/E `ogonek'.
68 68
69Je/sli czytasz ten tekst, to albo przegl/adasz plik /zr/od/lowy 69Je/sli czytasz ten tekst, to albo przegl/adasz plik /xr/od/lowy
70biblioteki `ogonek.el', albo wywo/la/le/s polecenie `ogonek-jak'. 70biblioteki `ogonek.el', albo wywo/la/le/s polecenie `ogonek-jak'.
71W drugim przypadku mo/zesz usun/a/c tekst z ekranu, stosuj/ac 71W drugim przypadku mo/zesz usun/a/c tekst z ekranu, stosuj/ac
72polecenie `M-x kill-buffer'. 72polecenie `M-x kill-buffer'.
73 73
74Niniejsza bibliteka dostarcza funkcji do zmiany kodowania polskich 74Niniejsza biblioteka dostarcza funkcji do zmiany kodowania polskich
75znak/ow diakrytycznych. Funkcje te mo/zna pogrupowa/c nast/epuj/aco. 75znak/ow diakrytycznych. Funkcje te mo/zna pogrupowa/c nast/epuj/aco.
76 76
77 1. Funkcje `ogonek-recode-region' oraz `ogonek-recode-buffer' 77 1. `ogonek-recode-region' oraz `ogonek-recode-buffer'
78 przekodowu/j/a zaznaczony fragment wzgl/ednie ca/ly buffor. 78 przekodowuj/a zaznaczony fragment wzgl/ednie ca/ly buffor.
79 Po wywo/laniu interakcyjnym funkcji zadawane s/a 79 Po wywo/laniu interakcyjnym funkcji zadawane s/a
80 pytania o parametry przekodowania, czyli o nazw/e kodowania 80 pytania o parametry przekodowania: nazw/e kodowania
81 w tek/scie /zr/od/lowym i nazw/e kodowania docelowego. 81 w tek/scie /xr/od/lowym i nazw/e kodowania docelowego.
82 Poni/zsze przyk/lady pokazuj/a, jakich parametr/ow 82 Poni/zsze przyk/lady powinny wyja/sni/c, jakich parametr/ow
83 oczekuj/a wymienione funkcje: 83 oczekuj/a wymienione funkcje:
84 84
85 (ogonek-recode-region (poczatek) (koniec) 85 (ogonek-recode-region (poczatek-fragmentu) (koniec-fragmentu)
86 nazwa-kodowania-w-tekscie-zrodlowym nazwa-kodowania-docelowa) 86 nazwa-kodowania-w-tekscie-zrodlowym nazwa-kodowania-docelowa)
87 (ogonek-recode-buffer 87 (ogonek-recode-buffer
88 nazwa-kodowania-w-tekscie-zrodlowym nazwa-kodowania-docelowa) 88 nazwa-kodowania-w-tekscie-zrodlowym nazwa-kodowania-docelowa)
89 89
90 2. Funkcje `ogonek-prefixify-region' oraz `ogonek-prefixify-buffer' 90 2. `ogonek-prefixify-region' oraz `ogonek-prefixify-buffer'
91 do wprowadzania notacji prefiksowej. 91 s/lu/z/a do wprowadzania notacji prefiksowej.
92 92
93 (ogonek-prefixify-region (poczatek) (koniec) 93 (ogonek-prefixify-region (poczatek-fragmentu) (koniec-fragmentu)
94 nazwa-kodowania-w-tekscie-zrodlowym znak-prefiksu) 94 nazwa-kodowania-w-tekscie-zrodlowym znak-prefiksu)
95 (ogonek-prefixify-buffer 95 (ogonek-prefixify-buffer
96 nazwa-kodowania-w-tekscie-zrodlowym znak-prefiksu) 96 nazwa-kodowania-w-tekscie-zrodlowym znak-prefiksu)
97 97
98 3. Funkcje `ogonek-deprefixify-region' oraz `ogonek-deprefixify-buffer' 98 3. `ogonek-deprefixify-region' oraz `ogonek-deprefixify-buffer'
99 do usuwania notacji prefiksowej. 99 s/lu/z/a do usuwania notacji prefiksowej.
100 100
101 (ogonek-deprefixify-region (poczatek) (koniec) 101 (ogonek-deprefixify-region (poczatek-fragmentu) (koniec-fragmentu)
102 znak-prefiksu nazwa-kodowania-docelowa) 102 znak-prefiksu nazwa-kodowania-docelowa)
103 (ogonek-prefixify-buffer 103 (ogonek-prefixify-buffer
104 znak-prefiksu nazwa-kodowania-docelowa) 104 znak-prefiksu nazwa-kodowania-docelowa)
105 105
106 U/zycie klawisza TAB w trybie interakcyjnym powoduje wy/swietlenie 106 U/zycie klawisza TAB w trybie interakcyjnym powoduje wy/swietlenie
107 listy dopuszczalnych nazw kod/ow, odczytywanych ze sta/lej 107 listy dopuszczalnych nazw kod/ow, pami/etanych w sta/lej
108 `ogonek-name-encoding-alist'. 108 `ogonek-name-encoding-alist'.
109 109
110 Funkcje biblioteki odwo/luj/a si/e do pi/eciu zmiennych, kt/ore 110 Funkcje biblioteki odwo/luj/a si/e do pi/eciu zmiennych, kt/ore
@@ -112,7 +112,7 @@ znak/ow diakrytycznych. Funkcje te mo/zna pogrupowa/c nast/epuj/aco.
112 oraz ich warto/sci domy/slne s/a nast/epuj/ace: 112 oraz ich warto/sci domy/slne s/a nast/epuj/ace:
113 113
114 ogonek-from-encoding iso8859-2 114 ogonek-from-encoding iso8859-2
115 ogonek-to-encoding mazovia 115 ogonek-to-encoding ascii
116 ogonek-prefix-char / 116 ogonek-prefix-char /
117 ogonek-prefix-from-encoding iso8859-2 117 ogonek-prefix-from-encoding iso8859-2
118 ogonek-prefix-to-encoding iso8859-2 118 ogonek-prefix-to-encoding iso8859-2
@@ -120,159 +120,146 @@ znak/ow diakrytycznych. Funkcje te mo/zna pogrupowa/c nast/epuj/aco.
120 Powy/zsze warto/sci domy/slne mo/zna zmieni/c przez umieszczenie w pliku 120 Powy/zsze warto/sci domy/slne mo/zna zmieni/c przez umieszczenie w pliku
121 konfiguracyjnym `~/.emacs' odpowiednich przypisa/n, na przyk/lad: 121 konfiguracyjnym `~/.emacs' odpowiednich przypisa/n, na przyk/lad:
122 122
123 (setq ogonek-prefix-char ?/) 123 (setq ogonek-prefix-char ?/)
124 (setq ogonek-prefix-to-encoding \"iso8859-2\") 124 (setq ogonek-prefix-to-encoding \"iso8859-2\")
125 125
126 Zamiast wczytywania ca/lej biblioteki `ogonek.el' mo/zna w pliku 126 Zamiast wczytywania ca/lej biblioteki `ogonek.el' mo/zna w pliku
127 `~/.emacs' za/z/ada/c wczytania wybranych funkcji i to dopiero w 127 `~/.emacs' za/z/ada/c wczytania wybranych funkcji, na dodatek dopiero
128 chwili ich wywo/lania: 128 w chwili ich rzeczywistego u/zycia:
129 129
130 (autoload 'ogonek-jak \"ogonek\") 130 (autoload 'ogonek-jak \"ogonek\")
131 (autoload 'ogonek-recode-region \"ogonek\") 131 (autoload 'ogonek-recode-region \"ogonek\")
132 (autoload 'ogonek-prefixify-region \"ogonek\") 132 (autoload 'ogonek-prefixify-region \"ogonek\")
133 (autoload 'ogonek-deprefixify-region \"ogonek\") 133 (autoload 'ogonek-deprefixify-region \"ogonek\")
134 134
135 Cz/esto wyst/epuj/ace kombinacje wywo/la/n funkcji mo/zna dla wygody 135 Cz/esto wyst/epuj/ace kombinacje wywo/la/n funkcji mo/zna dla wygody
136 skr/oci/c i przypisa/c klawiszom. Oto praktyczne przyk/lady: 136 skr/oci/c i przypisa/c klawiszom. Oto praktyczne przyk/lady:
137 137
138 (defun deprefixify-iso8859-2-region () 138 (defun deprefixify-iso8859-2-region (start end)
139 (interactive \"*\") 139 (interactive \"*r\")
140 (ogonek-deprefixify-region 140 (ogonek-deprefixify-region start end ?/ \"iso8859-2\"))
141 (region-beginning) (region-end) ?/ \"iso8859-2\")) 141 (global-set-key \"\\C-cd\" 'deprefixify-iso8859-2-region) ; ctrl-c d
142 (global-set-key \"\\C-cd\" 'deprefixify-iso8859-2-region) ; ctrl-c d
143 142
144 (defun mazovia-to-iso8859-2 () 143 (defun mazovia-to-iso8859-2 (start end)
145 (interactive \"*\") 144 (interactive \"*r\")
146 (ogonek-recode-region \"mazovia\" \"iso8859-2\")) 145 (ogonek-recode-region start end \"mazovia\" \"iso8859-2\"))
147 (global-set-key \"\\C-cr\" 'mazovia-to-iso8859-2) ; ctrl-c r 146 (global-set-key \"\\C-cr\" 'mazovia-to-iso8859-2) ; ctrl-c r
148 147
149 (defun prefixify-iso8859-2-region () 148 (defun prefixify-iso8859-2-region (start end)
150 (interactive \"*\") 149 (interactive \"*r\")
151 (ogonek-prefixify-region 150 (ogonek-prefixify-region start end \"iso8859-2\" ?/))
152 (region-beginning) (region-end) \"iso8859-2\" ?/)) 151 (global-set-key \"\\C-cp\" 'prefixify-iso8859-2-region) ; ctrl-c p
153 (global-set-key \"\\C-cp\" 'prefixify-iso8859-2-region) ; ctrl-c p
154 152
155 Ka/zd/a operacj/e przekodowania mo/zna w ca/lo/sci odwo/la/c 153 Ka/zd/a operacj/e przekodowania mo/zna w ca/lo/sci odwo/la/c
156 przez wykonanie polecenia `undo'.") 154 przez wykonanie polecenia `undo'.")
157 155
158(defun ogonek-jak () 156(defun ogonek-jak ()
159 "Display the string constant `ogonek-informacja' 157 "Display `ogonek-informacja' in an auxiliary *ogonek-jak* buffer."
160by inserting it into an auxiliary *ogonek-jak* buffer."
161 (interactive) 158 (interactive)
162 (set-buffer (get-buffer-create " *ogonek-jak*")) 159 (set-buffer (get-buffer-create " *ogonek-jak*"))
163 (insert ogonek-informacja) 160 (insert ogonek-informacja)
164 (switch-to-buffer " *ogonek-jak*") 161 (switch-to-buffer " *ogonek-jak*")
165 (beginning-of-buffer)) 162 (beginning-of-buffer))
166 163
167; ------ A Little Info in English -------- 164;; ------ A Little Info in English --------
168 165
169(defconst ogonek-information 166(defconst ogonek-information
170 " INTERACTIVE FUNCTIONS PROVIDED BY THE LIBRARY `ogonek'. 167 " THE INTERACTIVE FUNCTIONS PROVIDED BY THE LIBRARY `ogonek'.
171 168
172If you read this text then you are either looking at the library's 169If you read this text then you are either looking at the library's
173source text or you have called the `ogonek-howto' command. In the 170source text or you have called the `ogonek-how' command. In the
174latter case you may remove this text using `M-x kill-buffer'. 171latter case you may remove this text using `M-x kill-buffer'.
175 172
176The library provides functions for changing the encoding of Polish 173The library provides functions for changing the encoding of Polish
177diacritic characters, the ones with an `ogonek' below or above them. 174diacritic characters, the ones with an `ogonek' below or above them.
178The functions come in the following gropus. 175The functions come in the following groups.
179 176
180 1. Functions `ogonek-recode-region' and `ogonek-recode-buffer' to 177 1. `ogonek-recode-region' and `ogonek-recode-buffer' to change
181 change between one-character encodings, such as `iso-8859-2', 178 between one-character encodings, such as `iso-8859-2', `mazovia',
182 `mazovia', plain `ascii' or `TeX'. As the names suggest you may 179 plain `ascii' or `TeX'. As the names suggest you may recode
183 recode either the entire current buffer or just a marked region 180 either the entire current buffer or just a marked region
184 of it. You may use these functions interactively as commands. Once 181 in it. You may use the functions interactively as commands.
185 you call a command you will be asked about the code used in 182 Once you call a command you will be asked about the code
186 the source text and the target encoding, the one you want to get. 183 currently used in your text and the target encoding, the one
187 The following examples show a non-interactive use of the functions 184 you want to get. The following example shows a non-interactive
188 in a program. They also illustrtate what parameters the functions 185 use of the functions in a program. This also illustrates what
189 expect: 186 type of parameters the functions expect to be called with:
190 187
191 (ogonek-recode-region (region-beginning) (region-end) 188 (ogonek-recode-region
192 from-code-name to-code-name) 189 (region-beginning) (region-end) from-code-name to-code-name)
193 (ogonek-recode-buffer from-code-name to-code-name) 190 (ogonek-recode-buffer from-code-name to-code-name)
194 191
195 2. Functions `ogonek-prefixify-region' and `ogonek-prefixify-buffer'. 192 2. `ogonek-prefixify-region' and `ogonek-prefixify-buffer' for
196 for introducing prefix notation: 193 introducing prefix notation:
197 194
198 (ogonek-prefixify-region (region-beginning) (region-end) 195 (ogonek-prefixify-region
199 from-code-name prefix-char) 196 (region-beginning) (region-end) from-code-name prefix-char)
200 (ogonek-prefixify-buffer from-code-name prefix-char) 197 (ogonek-prefixify-buffer from-code-name prefix-char)
201 198
202 3. Functions `ogonek-deprefixify-region' and `ogonek-deprefixify-buffer' 199 3. `ogonek-deprefixify-region' and `ogonek-deprefixify-buffer' for
203 for removing prefix notation: 200 removing prefix notation:
204 201
205 (ogonek-deprefixify-region (region-beginning) (region-end) 202 (ogonek-deprefixify-region
206 prefix-char to-code-name) 203 (region-beginning) (region-end) prefix-char to-code-name)
207 (ogonek-prefixify-buffer prefix-char to-code-name) 204 (ogonek-prefixify-buffer prefix-char to-code-name)
208 205
209 The use of the TAB character in interactive makes `emacs' display 206 The TAB character used in interactive mode makes `emacs'
210 the list of encodings recognized by the library - the code names 207 display the list of encodings recognized by the library. The list
211 are stored in the constant `ogonek-name-encoding-alist' 208 is stored in the constant `ogonek-name-encoding-alist'.
212 209
213 The functions of the library refer to five variables that keep 210 The `ogonek' functions refer to five variables in which the suggested
214 hints to the questions asked. The names of those variables as well 211 answers to dialogue questions are stored. The variables and their
215 as their default values are: 212 default values are:
216 213
217 ogonek-from-encoding iso8859-2 214 ogonek-from-encoding iso8859-2
218 ogonek-to-encoding mazovia 215 ogonek-to-encoding ascii
219 ogonek-prefix-char / 216 ogonek-prefix-char /
220 ogonek-prefix-from-encoding iso8859-2 217 ogonek-prefix-from-encoding iso8859-2
221 ogonek-prefix-to-encoding iso8859-2 218 ogonek-prefix-to-encoding iso8859-2
222 219
223 The above default values can be changed by placing appropriate settings 220 The above default values can be changed by placing appropriate settings
224 in the '~/.emacs' file: 221 in the '~/.emacs' file:
225 222
226 (setq ogonek-prefix-char ?/) 223 (setq ogonek-prefix-char ?/)
227 (setq ogonek-prefix-to-encoding \"iso8859-2\") 224 (setq ogonek-prefix-to-encoding \"iso8859-2\")
228 225
229 Instead of loading the whole library `ogonek.el' it may be better to 226 Instead of loading the whole library `ogonek' it may be better to
230 autoload chosen functions in `~/.emacs': 227 autoload the needed functions, for example by placing in `~/.emacs':
231 228
232 (autoload 'ogonek-jak \"ogonek\") 229 (autoload 'ogonek-how \"ogonek\")
233 (autoload 'ogonek-recode-region \"ogonek\") 230 (autoload 'ogonek-recode-region \"ogonek\")
234 (autoload 'ogonek-prefixify-region \"ogonek\") 231 (autoload 'ogonek-prefixify-region \"ogonek\")
235 (autoload 'ogonek-deprefixify-region \"ogonek\") 232 (autoload 'ogonek-deprefixify-region \"ogonek\")
236 233
237 The most frequent function calls can be abbreviated and assigned to 234 The most frequent function calls can be abbreviated and assigned to
238 keyboard keys. Here are a few practical examples: 235 keyboard keys. Here are a few practical examples:
239 236
240 (setq ogonek-from-code-name \"iso8859-2\") 237 (defun deprefixify-iso8859-2-region (start end)
241 (setq ogonek-to-code-name \"mazovia\") 238 (interactive \"*r\")
242 (setq ogonek-prefix-char ?/) 239 (ogonek-deprefixify-region start end ?/ \"iso8859-2\"))
243 (setq ogonek-prefix-from-code-name \"iso8859-2\") 240 (global-set-key \"\\C-cd\" 'deprefixify-iso8859-2-region) ; ctrl-c d
244 (setq ogonek-prefix-to-code-name \"iso8859-2\")
245
246 (defun deprefixify-iso8859-2-region ()
247 (interactive \"*\")
248 (ogonek-deprefixify-region
249 (region-beginning) (region-end) ?/ \"iso8859-2\"))
250 (global-set-key \"\\C-cd\" 'deprefixify-iso8859-2-region) ; ctrl-c d
251 241
252 (defun mazovia-to-iso8859-2 () 242 (defun mazovia-to-iso8859-2 (start end)
253 (interactive \"*\") 243 (interactive \"*r\")
254 (ogonek-recode-region \"mazovia\" \"iso8859-2\")) 244 (ogonek-recode-region start end \"mazovia\" \"iso8859-2\"))
255 (global-set-key \"\\C-cr\" 'mazovia-to-iso8859-2) ; ctrl-c r 245 (global-set-key \"\\C-cr\" 'mazovia-to-iso8859-2) ; ctrl-c r
256 246
257 (defun prefixify-iso8859-2-region () 247 (defun prefixify-iso8859-2-region (start end)
258 (interactive \"*\") 248 (interactive \"*r\")
259 (ogonek-prefixify-region 249 (ogonek-prefixify-region start end \"iso8859-2\" ?/))
260 (region-beginning) (region-end) \"iso8859-2\" ?/)) 250 (global-set-key \"\\C-cp\" 'prefixify-iso8859-2-region) ; ctrl-c p
261 (global-set-key \"\\C-cp\" 'prefixify-iso8859-2-region) ; ctrl-c p
262 251
263 Each recoding opertation can be called off by executing the `undo' 252 Each recoding operation can be called off using the `undo' command.")
264 command.")
265 253
266(defun ogonek-how () 254(defun ogonek-how ()
267 "Display the string constant `ogonek-information' 255 "Display `ogonek-information' in an auxiliary *recode-how* buffer."
268by inserting it into an auxiliary *recode-help* buffer."
269 (interactive "*") 256 (interactive "*")
270 (set-buffer (get-buffer-create " *ogonek-help*")) 257 (set-buffer (get-buffer-create " *ogonek-how*"))
271 (insert ogonek-information) 258 (insert ogonek-information)
272 (switch-to-buffer " *ogonek-help*") 259 (switch-to-buffer " *ogonek-how*")
273 (beginning-of-buffer)) 260 (beginning-of-buffer))
274 261
275;; ------ Variables for keeping hints to the questions --------- 262;; ---- Variables keeping the suggested answers to dialogue questions -----
276 263
277(defvar ogonek-from-encoding "iso8859-2" 264(defvar ogonek-from-encoding "iso8859-2"
278 "*Encoding in the source file of recoding.") 265 "*Encoding in the source file of recoding.")
@@ -285,65 +272,68 @@ by inserting it into an auxiliary *recode-help* buffer."
285(defvar ogonek-prefix-to-encoding "iso8859-2" 272(defvar ogonek-prefix-to-encoding "iso8859-2"
286 "*Encoding in the target file subject to deprefixifation.") 273 "*Encoding in the target file subject to deprefixifation.")
287 274
288;; ------- Utilities for reading function parameters ------------- 275;; ---- Auxiliary functions for reading parameters in interactive mode ----
289 276
290(defun ogonek-read-encoding (prompt default-name-var) 277(defun ogonek-read-encoding (prompt default-name-var)
291 "Change with completion based on alist `ogonek-name-encoding-alist'." 278 "Read encoding name with completion based on `ogonek-name-encoding-alist'.
279Store the name in the the parameter-variable DEFAULT-NAME-VAR.
280PROMPT is a string to be shown when the user is asked for a name."
292 (let ((encoding 281 (let ((encoding
293 (completing-read 282 (completing-read
294 (format "%s (default %s): " prompt (eval default-name-var)) 283 (format "%s (default %s): " prompt (eval default-name-var))
295 ogonek-name-encoding-alist nil t))) 284 ogonek-name-encoding-alist nil t)))
296 ; set the new default name to be the one just read 285 ;; change the default name to the one just read
297 (set default-name-var 286 (set default-name-var
298 (if (string= encoding "") (eval default-name-var) encoding)) 287 (if (string= encoding "") (eval default-name-var) encoding))
299 ; return the new default as the name you read 288 ;; return the new default as the name you read
300 (eval default-name-var))) 289 (eval default-name-var)))
301 290
302(defun ogonek-read-prefix (prompt default-prefix-var) 291(defun ogonek-read-prefix (prompt default-prefix-var)
303 "Change prefix." 292 "Read a prefix character for prefix notation.
293The result is stored in the variable DEFAULT-PREFIX-VAR.
294PROMPT is a string to be shown when the user is asked for a new prefix."
304 (let ((prefix-string 295 (let ((prefix-string
305 (read-string 296 (read-string
306 (format "%s (default %s): " prompt 297 (format "%s (default %s): " prompt
307 (char-to-string (eval default-prefix-var)))))) 298 (char-to-string (eval default-prefix-var))))))
308 (if (> (length prefix-string) 1) 299 (if (> (length prefix-string) 1)
309 (error "! Only one character expected.") 300 (error "! Only one character expected.")
310 ; set the default prefix character to the one just read 301 ;; set the default prefix character to the one just read
311 (set default-prefix-var 302 (set default-prefix-var
312 (if (string= prefix-string "") 303 (if (string= prefix-string "")
313 (eval default-prefix-var) 304 (eval default-prefix-var)
314 (string-to-char prefix-string))) 305 (string-to-char prefix-string)))
315 ; return the new default prefix as the code you read) 306 ;; the new default prefix is the function's result:
316 (eval default-prefix-var)))) 307 (eval default-prefix-var))))
317 308
318(defun ogonek-lookup-encoding (encoding) 309(defun ogonek-lookup-encoding (encoding)
319 "Pick up an association for `encoding' in `ogonek-name-encoding-alist'. 310 "Pick up an association for ENCODING in `ogonek-name-encoding-alist'.
320Before returning a result test whether it has been properly set 311Before returning a result test whether the string ENCODING is in
321which should be true if the encoding is one of those in 312the list `ogonek-name-encoding-alist'"
322`ogonek-name-encoding-alist'"
323 (let ((code-list (assoc encoding ogonek-name-encoding-alist))) 313 (let ((code-list (assoc encoding ogonek-name-encoding-alist)))
324 (if (null code-list) 314 (if (null code-list)
325 (error "! Name `%s' not known in `ogonek-name-encoding-alist'." 315 (error "! Name `%s' not known in `ogonek-name-encoding-alist'."
326 encoding) 316 encoding)
327 (cdr code-list)))) 317 (cdr code-list))))
328 318
329; ------- A utility for zipping two lists ----------- 319;; ---- An auxiliary function for zipping two lists of equal length ----
330 320
331(defun ogonek-zip-lists (xs ys) 321(defun ogonek-zip-lists (xs ys)
332 "Build a list of pairs with elements from lists `xs' and `ys'. 322 "Build a list of pairs from lists XS and YS of the same length."
333We assume that `xs' and `ys' are of the same length."
334 (let ((pairs nil)) 323 (let ((pairs nil))
335 (while xs 324 (while xs
336 (setq pairs (cons (cons (car xs) (car ys)) pairs)) 325 (setq pairs (cons (cons (car xs) (car ys)) pairs))
337 (setq xs (cdr xs)) 326 (setq xs (cdr xs))
338 (setq ys (cdr ys))) 327 (setq ys (cdr ys)))
339; `pairs' are the function's result 328 ;; `pairs' are the function's result
340 pairs)) 329 pairs))
341 330
342; -------- Dealing with one-character cencodings ------- 331;; ---- An auxiliary function building a one-to-one recoding table -----
343 332
344(defun ogonek-build-table (recoding-pairs) 333(defun ogonek-build-table (recoding-pairs)
345 "Build a table nedeed by emacs's `translate-region' function. 334 "Build a table required by Emacs's `translate-region' function.
346The `recoding-pairs' argument is a list of pairs of characters. 335RECODING-PAIRS is a list of character pairs for which recoding
336is not an identity.
347By using the built-in `translate-region' function 337By using the built-in `translate-region' function
348we gain better performance compared to converting characters 338we gain better performance compared to converting characters
349by a hand-written routine as it is done for prefix encodings." 339by a hand-written routine as it is done for prefix encodings."
@@ -352,17 +342,19 @@ by a hand-written routine as it is done for prefix encodings."
352 (while (< i 256) 342 (while (< i 256)
353 (aset table i i) 343 (aset table i i)
354 (setq i (1+ i))) 344 (setq i (1+ i)))
355 ; make changes in `table' according to `recoding-pairs' 345 ;; make changes in `table' according to `recoding-pairs'
356 (while recoding-pairs 346 (while recoding-pairs
357 (aset table (car (car recoding-pairs)) (cdr (car recoding-pairs))) 347 (aset table (car (car recoding-pairs)) (cdr (car recoding-pairs)))
358 (setq recoding-pairs (cdr recoding-pairs))) 348 (setq recoding-pairs (cdr recoding-pairs)))
359 ; return the table just built 349 ;; return the table just built
360 table)) 350 table))
361 351
352;; ---- Commands for one-to-one recoding -------------------------------
353
362(defun ogonek-recode-region (start end from-encoding to-encoding) 354(defun ogonek-recode-region (start end from-encoding to-encoding)
363 "This function recodes text in a region delineated by the current-mark 355 "Recode text in a marked region in one-to-one manner.
364and the current point according to the defaults set by the variables 356When called interactively ask the user for the names of the FROM-
365`ogonek-from-encoding' and `ogonek-to-encoding'." 357and TO- encodings."
366 (interactive (progn (barf-if-buffer-read-only) 358 (interactive (progn (barf-if-buffer-read-only)
367 (list 359 (list
368 (region-beginning) 360 (region-beginning)
@@ -378,7 +370,9 @@ and the current point according to the defaults set by the variables
378 (ogonek-lookup-encoding to-encoding)))))) 370 (ogonek-lookup-encoding to-encoding))))))
379 371
380(defun ogonek-recode-buffer (from-encoding to-encoding) 372(defun ogonek-recode-buffer (from-encoding to-encoding)
381 "Call `ogonek-region' on the entire buffer." 373 "Call `ogonek-recode-region' on the entire buffer.
374When called interactively ask the user for the names of the FROM-
375and TO- encodings."
382 (interactive (progn (barf-if-buffer-read-only) 376 (interactive (progn (barf-if-buffer-read-only)
383 (list 377 (list
384 (ogonek-read-encoding "From code" 'ogonek-from-encoding) 378 (ogonek-read-encoding "From code" 'ogonek-from-encoding)
@@ -386,19 +380,16 @@ and the current point according to the defaults set by the variables
386 (ogonek-recode-region 380 (ogonek-recode-region
387 (point-min) (point-max) from-encoding to-encoding)) 381 (point-min) (point-max) from-encoding to-encoding))
388 382
389; -------------------------------- 383;; ---- Recoding with prefix notation -------------------------------
390; Recoding with prefix notation
391; --------------------------------
392 384
393(defconst prefix-code '(?A ?C ?E ?L ?N ?O ?S ?X ?Z 385(defconst ogonek-prefix-code '(?A ?C ?E ?L ?N ?O ?S ?X ?Z
394 ?a ?c ?e ?l ?n ?o ?s ?x ?z)) 386 ?a ?c ?e ?l ?n ?o ?s ?x ?z))
395 387
396(defun ogonek-prefixify-region (start end from-encoding prefix-char) 388(defun ogonek-prefixify-region (start end from-encoding prefix-char)
397 "Replace -- in the region delineated by the current-mark 389 "In a region, replace FROM-encoded Polish characters with PREFIX pairs.
398and the point -- each character from `ogonek-from-encoding' 390A PREFIX pair generated consists of PREFIX-CHAR and the respective
399by two characters: `ogonek-prefix-char' and the corresponding 391character listed in the `ogonek-prefix-code' constant.
400character from the `prefix' list. Double the character 392PREFIX-CHAR itself gets doubled."
401`ogonek-prefix-char'"
402 (interactive (progn (barf-if-buffer-read-only) 393 (interactive (progn (barf-if-buffer-read-only)
403 (list 394 (list
404 (region-beginning) 395 (region-beginning)
@@ -407,8 +398,8 @@ character from the `prefix' list. Double the character
407 (ogonek-read-prefix "Prefix character" 'ogonek-prefix-char)))) 398 (ogonek-read-prefix "Prefix character" 'ogonek-prefix-char))))
408 (let* 399 (let*
409 ((from-code (ogonek-lookup-encoding from-encoding)) 400 ((from-code (ogonek-lookup-encoding from-encoding))
410 (to-code prefix-code) 401 (to-code ogonek-prefix-code)
411 (recoding-pairs ; we add `ogonek-prefix-char' for doubling 402 (recoding-pairs ; `ogonek-prefix-char' added for doubling
412 (ogonek-zip-lists 403 (ogonek-zip-lists
413 (cons prefix-char from-code) 404 (cons prefix-char from-code)
414 (cons prefix-char to-code)))) 405 (cons prefix-char to-code))))
@@ -417,13 +408,13 @@ character from the `prefix' list. Double the character
417 (while (< (point) end) 408 (while (< (point) end)
418 (let ((pair (assoc (following-char) recoding-pairs))) 409 (let ((pair (assoc (following-char) recoding-pairs)))
419 (if (null pair) 410 (if (null pair)
420 ; not a Polish character -- skip it 411 ;; not a Polish character -- skip it
421 (forward-char 1) 412 (forward-char 1)
422 ; Polish character -- replace it by a two characters 413 ;; Polish character -- insert a prefix pair instead
423 (delete-char 1) 414 (delete-char 1)
424 (insert ogonek-prefix-char) 415 (insert ogonek-prefix-char)
425 (insert (cdr pair)) 416 (insert (cdr pair))
426 ; the region is now one character longer 417 ;; the region is now one character longer
427 (setq end (1+ end)))))))) 418 (setq end (1+ end))))))))
428 419
429(defun ogonek-prefixify-buffer (from-encoding prefix-char) 420(defun ogonek-prefixify-buffer (from-encoding prefix-char)
@@ -436,10 +427,12 @@ character from the `prefix' list. Double the character
436 (point-min) (point-max) from-encoding prefix-char)) 427 (point-min) (point-max) from-encoding prefix-char))
437 428
438(defun ogonek-deprefixify-region (start end prefix-char to-encoding) 429(defun ogonek-deprefixify-region (start end prefix-char to-encoding)
439 "Replace `ogonek-prefix-char' followed by a character from 430 "In a region, replace PREFIX pairs with their corresponding TO-encodings.
440the `prefix' list or another `ogonek-prefix-char' by 431PREFIX-CHAR followed by a Polish character from the `ogonek-prefix-code'
441the corresponding character from `ogonek-from-encoding' 432list is replaced with the corresponding TO-encoded character. A doubled
442or by one `ogonek-prefix-char'." 433PREFIX-CHAR gets replaced with a single one. A combination of PREFIX-CHAR
434followed by a non-Polish character, that is one not listed in the
435`ogonek-prefix-code' constant, is left unchanged."
443 (interactive (progn (barf-if-buffer-read-only) 436 (interactive (progn (barf-if-buffer-read-only)
444 (list (region-beginning) 437 (list (region-beginning)
445 (region-end) 438 (region-end)
@@ -448,7 +441,7 @@ or by one `ogonek-prefix-char'."
448 (ogonek-read-encoding 441 (ogonek-read-encoding
449 "To code" 'ogonek-prefix-to-encoding)))) 442 "To code" 'ogonek-prefix-to-encoding))))
450 (let* 443 (let*
451 ((from-code prefix-code) 444 ((from-code ogonek-prefix-code)
452 (to-code (ogonek-lookup-encoding to-encoding)) 445 (to-code (ogonek-lookup-encoding to-encoding))
453 (recoding-pairs 446 (recoding-pairs
454 (ogonek-zip-lists 447 (ogonek-zip-lists
@@ -459,20 +452,20 @@ or by one `ogonek-prefix-char'."
459 (while (< (point) end) 452 (while (< (point) end)
460 (forward-char 1) 453 (forward-char 1)
461 (if (or (not (= (preceding-char) prefix-char)) (= (point) end)) 454 (if (or (not (= (preceding-char) prefix-char)) (= (point) end))
462 ; non-prefix character or the end-of-region -- do nothing 455 ;; non-prefix character or the end-of-region -- do nothing
463 () 456 ()
464 ; now, we can check the next character 457 ;; now, we can check the next character
465 (let ((pair (assoc (following-char) recoding-pairs))) 458 (let ((pair (assoc (following-char) recoding-pairs)))
466 (if (null pair) 459 (if (null pair)
467 ; `following-char' is not a Polish character nor it is 460 ;; `following-char' is not a Polish character nor it is
468 ; `prefix-char' since the one is among `recoding-pairs' 461 ;; `prefix-char' since the one is among `recoding-pairs'
469 (forward-char 1) 462 (forward-char 1)
470 ; else prefix followed by a Polish character has been found 463 ;; else prefix followed by a Polish character has been found
471 ; replace it by the corresponding Polish character 464 ;; replace it by the corresponding Polish character
472 (backward-char 1) 465 (backward-char 1)
473 (delete-char 2) 466 (delete-char 2)
474 (insert (cdr pair)) 467 (insert (cdr pair))
475 ; the region got shorter by one character 468 ;; the region got shorter by one character
476 (setq end (1- end))))))))) 469 (setq end (1- end)))))))))
477 470
478(defun ogonek-deprefixify-buffer (prefix-char to-encoding) 471(defun ogonek-deprefixify-buffer (prefix-char to-encoding)