Mercurial > emacs
annotate lisp/international/ogonek.el @ 99266:8d57082234b9
(indent-for-tab-command): Use use-region-p.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 30 Oct 2008 23:52:39 +0000 |
parents | 889bc336b89b |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
21701 | 1 ;;; ogonek.el --- change the encoding of Polish diacritics |
18264 | 2 |
79709 | 3 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
74544 | 4 ;; Free Software Foundation, Inc. |
18264 | 5 |
6 ;; Author: W{\l}odek Bzyl, Ryszard Kubiak | |
7 ;; Maintainer: rysiek@ipipan.gda.pl (Ryszard Kubiak) | |
8 ;; Keywords: i18n | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
94664
889bc336b89b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
18264 | 13 ;; it under the terms of the GNU General Public License as published by |
94664
889bc336b89b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
889bc336b89b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
18264 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94664
889bc336b89b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
18264 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; To use this library load it using | |
28 ;; M-x load-library [enter] ogonek | |
29 ;; Then, you may get a short info by calling one of | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
30 ;; M-x ogonek-jak -- in Polish |
18264 | 31 ;; M-x ogonek-how -- in English " |
32 | |
21646
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
33 ;;; Code: |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
34 |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
35 (defgroup ogonek nil |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
36 "Change the encoding of Polish diacritic characters." |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
37 :prefix "ogonek-" |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
38 :group 'i18n) |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
39 |
18264 | 40 (defconst ogonek-name-encoding-alist |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
41 '(("ascii" . (?A ?C ?E ?L ?N ?O ?S ?Z ?Z |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
42 ?a ?c ?e ?l ?n ?o ?s ?z ?z)) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
43 ("iso8859-2" . (161 198 202 163 209 211 166 172 175 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
44 177 230 234 179 241 243 182 188 191)) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
45 ("mazovia" . (143 149 144 156 165 163 152 160 161 |
18264 | 46 134 141 145 146 164 162 158 166 167)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
47 ("windows-EE" . (165 198 202 163 209 211 140 143 175 |
18264 | 48 185 230 234 179 241 243 156 159 191)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
49 ("windows-PL" . (165 198 202 163 209 211 140 143 175 |
18264 | 50 185 230 234 179 241 243 156 159 191)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
51 ("latin-2" . (164 143 168 157 227 224 151 141 189 |
18264 | 52 165 134 169 136 228 162 152 171 190)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
53 ("CP852" . (164 143 168 157 227 224 151 141 189 |
18264 | 54 165 134 169 136 228 162 152 171 190)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
55 ("MeX" . (129 130 134 138 139 211 145 153 155 |
18264 | 56 161 162 166 170 171 243 177 185 187)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
57 ("CorelDraw" . (197 242 201 163 209 211 255 225 237 |
18264 | 58 229 236 230 198 241 243 165 170 186)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
59 ("Amiga" . (194 202 203 206 207 211 212 218 219 |
18264 | 60 226 234 235 238 239 243 244 250 251)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
61 ("Mac" . (132 140 162 252 193 238 229 143 251 |
18264 | 62 136 141 171 184 196 151 230 144 253)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
63 ) |
18264 | 64 "The constant `ogonek-name-encoding-alist' is a list of (NAME.LIST) pairs. |
18363 | 65 Each LIST contains codes for 18 Polish diacritic characters. The codes |
66 are given in the following order: | |
18264 | 67 Aogonek Cacute Eogonek Lslash Nacute Oacute Sacute Zacute Zdotaccent |
68 aogonek cacute eogonek lslash nacute oacute sacute zacute zdotaccent.") | |
69 | |
18363 | 70 ;; ------ A Little Info in Polish --------------- |
18264 | 71 |
72 (defconst ogonek-informacja | |
18363 | 73 " FUNKCJE INTERAKCYJNE UDOST/EPNIANE PRZEZ BIBLIOTEK/E `ogonek'. |
18264 | 74 |
18363 | 75 Je/sli czytasz ten tekst, to albo przegl/adasz plik /xr/od/lowy |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
76 biblioteki `ogonek.el', albo wywo/la/le/s polecenie `ogonek-jak'. |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
77 W drugim przypadku mo/zesz usun/a/c tekst z ekranu, stosuj/ac |
18264 | 78 polecenie `M-x kill-buffer'. |
79 | |
18363 | 80 Niniejsza biblioteka dostarcza funkcji do zmiany kodowania polskich |
18264 | 81 znak/ow diakrytycznych. Funkcje te mo/zna pogrupowa/c nast/epuj/aco. |
82 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
83 1. `ogonek-recode-region' oraz `ogonek-recode-buffer' |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
84 przekodowuj/a zaznaczony fragment wzgl/ednie ca/ly buffor. |
18264 | 85 Po wywo/laniu interakcyjnym funkcji zadawane s/a |
18363 | 86 pytania o parametry przekodowania: nazw/e kodowania |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
87 w tek/scie /xr/od/lowym i nazw/e kodowania docelowego. |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
88 Poni/zsze przyk/lady powinny wyja/sni/c, jakich parametr/ow |
18264 | 89 oczekuj/a wymienione funkcje: |
90 | |
18363 | 91 (ogonek-recode-region (poczatek-fragmentu) (koniec-fragmentu) |
18264 | 92 nazwa-kodowania-w-tekscie-zrodlowym nazwa-kodowania-docelowa) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
93 (ogonek-recode-buffer |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
94 nazwa-kodowania-w-tekscie-zrodlowym nazwa-kodowania-docelowa) |
18264 | 95 |
18363 | 96 2. `ogonek-prefixify-region' oraz `ogonek-prefixify-buffer' |
97 s/lu/z/a do wprowadzania notacji prefiksowej. | |
18264 | 98 |
18363 | 99 (ogonek-prefixify-region (poczatek-fragmentu) (koniec-fragmentu) |
18264 | 100 nazwa-kodowania-w-tekscie-zrodlowym znak-prefiksu) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
101 (ogonek-prefixify-buffer |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
102 nazwa-kodowania-w-tekscie-zrodlowym znak-prefiksu) |
18264 | 103 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
104 3. `ogonek-deprefixify-region' oraz `ogonek-deprefixify-buffer' |
18363 | 105 s/lu/z/a do usuwania notacji prefiksowej. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
106 |
18363 | 107 (ogonek-deprefixify-region (poczatek-fragmentu) (koniec-fragmentu) |
18264 | 108 znak-prefiksu nazwa-kodowania-docelowa) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
109 (ogonek-prefixify-buffer |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
110 znak-prefiksu nazwa-kodowania-docelowa) |
18264 | 111 |
112 U/zycie klawisza TAB w trybie interakcyjnym powoduje wy/swietlenie | |
18363 | 113 listy dopuszczalnych nazw kod/ow, pami/etanych w sta/lej |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
114 `ogonek-name-encoding-alist'. |
18264 | 115 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
116 Funkcje biblioteki odwo/luj/a si/e do pi/eciu zmiennych, kt/ore |
18264 | 117 przechowuj/a podpowiedzi do zadawanych pyta/n. Nazwy tych zmiennych |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
118 oraz ich warto/sci domy/slne s/a nast/epuj/ace: |
18264 | 119 |
120 ogonek-from-encoding iso8859-2 | |
18363 | 121 ogonek-to-encoding ascii |
18264 | 122 ogonek-prefix-char / |
123 ogonek-prefix-from-encoding iso8859-2 | |
124 ogonek-prefix-to-encoding iso8859-2 | |
125 | |
126 Powy/zsze warto/sci domy/slne mo/zna zmieni/c przez umieszczenie w pliku | |
127 konfiguracyjnym `~/.emacs' odpowiednich przypisa/n, na przyk/lad: | |
128 | |
18363 | 129 (setq ogonek-prefix-char ?/) |
130 (setq ogonek-prefix-to-encoding \"iso8859-2\") | |
18264 | 131 |
132 Zamiast wczytywania ca/lej biblioteki `ogonek.el' mo/zna w pliku | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
133 `~/.emacs' za/z/ada/c wczytania wybranych funkcji, na dodatek dopiero |
18363 | 134 w chwili ich rzeczywistego u/zycia: |
18264 | 135 |
18363 | 136 (autoload 'ogonek-jak \"ogonek\") |
137 (autoload 'ogonek-recode-region \"ogonek\") | |
138 (autoload 'ogonek-prefixify-region \"ogonek\") | |
139 (autoload 'ogonek-deprefixify-region \"ogonek\") | |
18264 | 140 |
141 Cz/esto wyst/epuj/ace kombinacje wywo/la/n funkcji mo/zna dla wygody | |
142 skr/oci/c i przypisa/c klawiszom. Oto praktyczne przyk/lady: | |
143 | |
18363 | 144 (defun deprefixify-iso8859-2-region (start end) |
145 (interactive \"*r\") | |
146 (ogonek-deprefixify-region start end ?/ \"iso8859-2\")) | |
147 (global-set-key \"\\C-cd\" 'deprefixify-iso8859-2-region) ; ctrl-c d | |
18264 | 148 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
149 (defun mazovia-to-iso8859-2 (start end) |
18363 | 150 (interactive \"*r\") |
151 (ogonek-recode-region start end \"mazovia\" \"iso8859-2\")) | |
152 (global-set-key \"\\C-cr\" 'mazovia-to-iso8859-2) ; ctrl-c r | |
18264 | 153 |
18363 | 154 (defun prefixify-iso8859-2-region (start end) |
155 (interactive \"*r\") | |
156 (ogonek-prefixify-region start end \"iso8859-2\" ?/)) | |
157 (global-set-key \"\\C-cp\" 'prefixify-iso8859-2-region) ; ctrl-c p | |
18264 | 158 |
159 Ka/zd/a operacj/e przekodowania mo/zna w ca/lo/sci odwo/la/c | |
160 przez wykonanie polecenia `undo'.") | |
161 | |
162 (defun ogonek-jak () | |
18363 | 163 "Display `ogonek-informacja' in an auxiliary *ogonek-jak* buffer." |
18264 | 164 (interactive) |
165 (set-buffer (get-buffer-create " *ogonek-jak*")) | |
166 (insert ogonek-informacja) | |
167 (switch-to-buffer " *ogonek-jak*") | |
62314
8ef4dac936f9
(ogonek-jak, ogonek-how): Don't use beginning-of-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
62274
diff
changeset
|
168 (goto-char (point-min))) |
18264 | 169 |
18363 | 170 ;; ------ A Little Info in English -------- |
18264 | 171 |
172 (defconst ogonek-information | |
18363 | 173 " THE INTERACTIVE FUNCTIONS PROVIDED BY THE LIBRARY `ogonek'. |
18264 | 174 |
175 If you read this text then you are either looking at the library's | |
18363 | 176 source text or you have called the `ogonek-how' command. In the |
18264 | 177 latter case you may remove this text using `M-x kill-buffer'. |
178 | |
179 The library provides functions for changing the encoding of Polish | |
180 diacritic characters, the ones with an `ogonek' below or above them. | |
18363 | 181 The functions come in the following groups. |
18264 | 182 |
18363 | 183 1. `ogonek-recode-region' and `ogonek-recode-buffer' to change |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
184 between one-character encodings, such as `iso-8859-2', `mazovia', |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
185 plain `ascii' or `TeX'. As the names suggest you may recode |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
186 either the entire current buffer or just a marked region |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
187 in it. You may use the functions interactively as commands. |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
188 Once you call a command you will be asked about the code |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
189 currently used in your text and the target encoding, the one |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
190 you want to get. The following example shows a non-interactive |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
191 use of the functions in a program. This also illustrates what |
18363 | 192 type of parameters the functions expect to be called with: |
18264 | 193 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
194 (ogonek-recode-region |
18363 | 195 (region-beginning) (region-end) from-code-name to-code-name) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
196 (ogonek-recode-buffer from-code-name to-code-name) |
18264 | 197 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
198 2. `ogonek-prefixify-region' and `ogonek-prefixify-buffer' for |
18363 | 199 introducing prefix notation: |
18264 | 200 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
201 (ogonek-prefixify-region |
18363 | 202 (region-beginning) (region-end) from-code-name prefix-char) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
203 (ogonek-prefixify-buffer from-code-name prefix-char) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
204 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
205 3. `ogonek-deprefixify-region' and `ogonek-deprefixify-buffer' for |
18363 | 206 removing prefix notation: |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
207 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
208 (ogonek-deprefixify-region |
18363 | 209 (region-beginning) (region-end) prefix-char to-code-name) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
210 (ogonek-prefixify-buffer prefix-char to-code-name) |
18264 | 211 |
18363 | 212 The TAB character used in interactive mode makes `emacs' |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
213 display the list of encodings recognized by the library. The list |
18363 | 214 is stored in the constant `ogonek-name-encoding-alist'. |
18264 | 215 |
18363 | 216 The `ogonek' functions refer to five variables in which the suggested |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
217 answers to dialogue questions are stored. The variables and their |
18363 | 218 default values are: |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
219 |
18264 | 220 ogonek-from-encoding iso8859-2 |
18363 | 221 ogonek-to-encoding ascii |
222 ogonek-prefix-char / | |
18264 | 223 ogonek-prefix-from-encoding iso8859-2 |
224 ogonek-prefix-to-encoding iso8859-2 | |
225 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
226 The above default values can be changed by placing appropriate settings |
18264 | 227 in the '~/.emacs' file: |
228 | |
18363 | 229 (setq ogonek-prefix-char ?/) |
230 (setq ogonek-prefix-to-encoding \"iso8859-2\") | |
18264 | 231 |
18363 | 232 Instead of loading the whole library `ogonek' it may be better to |
233 autoload the needed functions, for example by placing in `~/.emacs': | |
18264 | 234 |
18363 | 235 (autoload 'ogonek-how \"ogonek\") |
236 (autoload 'ogonek-recode-region \"ogonek\") | |
237 (autoload 'ogonek-prefixify-region \"ogonek\") | |
238 (autoload 'ogonek-deprefixify-region \"ogonek\") | |
18264 | 239 |
240 The most frequent function calls can be abbreviated and assigned to | |
241 keyboard keys. Here are a few practical examples: | |
242 | |
18363 | 243 (defun deprefixify-iso8859-2-region (start end) |
244 (interactive \"*r\") | |
245 (ogonek-deprefixify-region start end ?/ \"iso8859-2\")) | |
246 (global-set-key \"\\C-cd\" 'deprefixify-iso8859-2-region) ; ctrl-c d | |
18264 | 247 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
248 (defun mazovia-to-iso8859-2 (start end) |
18363 | 249 (interactive \"*r\") |
250 (ogonek-recode-region start end \"mazovia\" \"iso8859-2\")) | |
251 (global-set-key \"\\C-cr\" 'mazovia-to-iso8859-2) ; ctrl-c r | |
18264 | 252 |
18363 | 253 (defun prefixify-iso8859-2-region (start end) |
254 (interactive \"*r\") | |
255 (ogonek-prefixify-region start end \"iso8859-2\" ?/)) | |
256 (global-set-key \"\\C-cp\" 'prefixify-iso8859-2-region) ; ctrl-c p | |
18264 | 257 |
18363 | 258 Each recoding operation can be called off using the `undo' command.") |
18264 | 259 |
260 (defun ogonek-how () | |
18363 | 261 "Display `ogonek-information' in an auxiliary *recode-how* buffer." |
18264 | 262 (interactive "*") |
18363 | 263 (set-buffer (get-buffer-create " *ogonek-how*")) |
18264 | 264 (insert ogonek-information) |
18363 | 265 (switch-to-buffer " *ogonek-how*") |
62314
8ef4dac936f9
(ogonek-jak, ogonek-how): Don't use beginning-of-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
62274
diff
changeset
|
266 (goto-char (point-min))) |
18264 | 267 |
18363 | 268 ;; ---- Variables keeping the suggested answers to dialogue questions ----- |
21646
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
269 (defvar ogonek-encoding-choices |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
270 (cons 'choice |
21646
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
271 (mapcar (lambda (x) (list 'const (car x))) |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
272 ogonek-name-encoding-alist)) |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
273 "List of ogonek encodings. Used only for customization.") |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
274 (defcustom ogonek-from-encoding "iso8859-2" |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
275 "*Encoding in the source file of recoding." |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
276 :type ogonek-encoding-choices |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
277 :group 'ogonek) |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
278 (defcustom ogonek-to-encoding "ascii" |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
279 "*Encoding in the target file of recoding." |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
280 :type ogonek-encoding-choices |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
281 :group 'ogonek) |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
282 (defcustom ogonek-prefix-char ?/ |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
283 "*Prefix character for prefix encodings." |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
284 :type 'character |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
285 :group 'ogonek) |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
286 (defcustom ogonek-prefix-from-encoding "iso8859-2" |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
287 "*Encoding in the source file subject to prefixifation." |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
288 :type ogonek-encoding-choices |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
289 :group 'ogonek) |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
290 (defcustom ogonek-prefix-to-encoding "iso8859-2" |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
291 "*Encoding in the target file subject to deprefixifation." |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
292 :type ogonek-encoding-choices |
ec243644b3fb
Customize. Add `;;; Code' line.
Stephen Eglen <stephen@gnu.org>
parents:
18363
diff
changeset
|
293 :group 'ogonek) |
18264 | 294 |
18363 | 295 ;; ---- Auxiliary functions for reading parameters in interactive mode ---- |
18264 | 296 |
297 (defun ogonek-read-encoding (prompt default-name-var) | |
18363 | 298 "Read encoding name with completion based on `ogonek-name-encoding-alist'. |
42686 | 299 Store the name in the parameter-variable DEFAULT-NAME-VAR. |
18363 | 300 PROMPT is a string to be shown when the user is asked for a name." |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
301 (let ((encoding |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
302 (completing-read |
18264 | 303 (format "%s (default %s): " prompt (eval default-name-var)) |
304 ogonek-name-encoding-alist nil t))) | |
18363 | 305 ;; change the default name to the one just read |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
306 (set default-name-var |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
307 (if (string= encoding "") (eval default-name-var) encoding)) |
18363 | 308 ;; return the new default as the name you read |
18264 | 309 (eval default-name-var))) |
310 | |
311 (defun ogonek-read-prefix (prompt default-prefix-var) | |
18363 | 312 "Read a prefix character for prefix notation. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
313 The result is stored in the variable DEFAULT-PREFIX-VAR. |
18363 | 314 PROMPT is a string to be shown when the user is asked for a new prefix." |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
315 (let ((prefix-string |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
316 (read-string |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
317 (format "%s (default %s): " prompt |
18264 | 318 (char-to-string (eval default-prefix-var)))))) |
319 (if (> (length prefix-string) 1) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
320 (error "! Only one character expected") |
18363 | 321 ;; set the default prefix character to the one just read |
18264 | 322 (set default-prefix-var |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
323 (if (string= prefix-string "") |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
324 (eval default-prefix-var) |
18264 | 325 (string-to-char prefix-string))) |
18363 | 326 ;; the new default prefix is the function's result: |
18264 | 327 (eval default-prefix-var)))) |
328 | |
329 (defun ogonek-lookup-encoding (encoding) | |
18363 | 330 "Pick up an association for ENCODING in `ogonek-name-encoding-alist'. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
331 Before returning a result test whether the string ENCODING is in |
18363 | 332 the list `ogonek-name-encoding-alist'" |
18264 | 333 (let ((code-list (assoc encoding ogonek-name-encoding-alist))) |
334 (if (null code-list) | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
21701
diff
changeset
|
335 (error "! Name `%s' not known in `ogonek-name-encoding-alist'" |
18264 | 336 encoding) |
337 (cdr code-list)))) | |
338 | |
18363 | 339 ;; ---- An auxiliary function for zipping two lists of equal length ---- |
18264 | 340 |
341 (defun ogonek-zip-lists (xs ys) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
342 "Build a list of pairs from lists XS and YS of the same length." |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
343 (let ((pairs nil)) |
18264 | 344 (while xs |
345 (setq pairs (cons (cons (car xs) (car ys)) pairs)) | |
346 (setq xs (cdr xs)) | |
347 (setq ys (cdr ys))) | |
18363 | 348 ;; `pairs' are the function's result |
18264 | 349 pairs)) |
350 | |
18363 | 351 ;; ---- An auxiliary function building a one-to-one recoding table ----- |
18264 | 352 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
353 (defun ogonek-build-table (recoding-pairs) |
18363 | 354 "Build a table required by Emacs's `translate-region' function. |
355 RECODING-PAIRS is a list of character pairs for which recoding | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
356 is not an identity. |
18264 | 357 By using the built-in `translate-region' function |
358 we gain better performance compared to converting characters | |
359 by a hand-written routine as it is done for prefix encodings." | |
360 (let ((table (make-string 256 0)) | |
361 (i 0)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
362 (while (< i 256) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
363 (aset table i i) |
18264 | 364 (setq i (1+ i))) |
18363 | 365 ;; make changes in `table' according to `recoding-pairs' |
18264 | 366 (while recoding-pairs |
367 (aset table (car (car recoding-pairs)) (cdr (car recoding-pairs))) | |
368 (setq recoding-pairs (cdr recoding-pairs))) | |
18363 | 369 ;; return the table just built |
18264 | 370 table)) |
371 | |
18363 | 372 ;; ---- Commands for one-to-one recoding ------------------------------- |
373 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
374 (defun ogonek-recode-region (start end from-encoding to-encoding) |
18363 | 375 "Recode text in a marked region in one-to-one manner. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
376 When called interactively ask the user for the names of the FROM- |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
377 and TO- encodings." |
18264 | 378 (interactive (progn (barf-if-buffer-read-only) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
379 (list |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
380 (region-beginning) |
18264 | 381 (region-end) |
382 (ogonek-read-encoding "From code" 'ogonek-from-encoding) | |
383 (ogonek-read-encoding "To code" 'ogonek-to-encoding)))) | |
384 (save-excursion | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
385 (translate-region |
18264 | 386 start end |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
387 (ogonek-build-table |
18264 | 388 (ogonek-zip-lists |
389 (ogonek-lookup-encoding from-encoding) | |
390 (ogonek-lookup-encoding to-encoding)))))) | |
391 | |
392 (defun ogonek-recode-buffer (from-encoding to-encoding) | |
18363 | 393 "Call `ogonek-recode-region' on the entire buffer. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
394 When called interactively ask the user for the names of the FROM- |
18363 | 395 and TO- encodings." |
18264 | 396 (interactive (progn (barf-if-buffer-read-only) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
397 (list |
18264 | 398 (ogonek-read-encoding "From code" 'ogonek-from-encoding) |
399 (ogonek-read-encoding "To code" 'ogonek-to-encoding)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
400 (ogonek-recode-region |
18264 | 401 (point-min) (point-max) from-encoding to-encoding)) |
402 | |
18363 | 403 ;; ---- Recoding with prefix notation ------------------------------- |
18264 | 404 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
405 (defconst ogonek-prefix-code '(?A ?C ?E ?L ?N ?O ?S ?X ?Z |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
406 ?a ?c ?e ?l ?n ?o ?s ?x ?z)) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
407 |
18264 | 408 (defun ogonek-prefixify-region (start end from-encoding prefix-char) |
18363 | 409 "In a region, replace FROM-encoded Polish characters with PREFIX pairs. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
410 A PREFIX pair generated consists of PREFIX-CHAR and the respective |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
411 character listed in the `ogonek-prefix-code' constant. |
18363 | 412 PREFIX-CHAR itself gets doubled." |
18264 | 413 (interactive (progn (barf-if-buffer-read-only) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
414 (list |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
415 (region-beginning) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
416 (region-end) |
18264 | 417 (ogonek-read-encoding "From code" 'ogonek-prefix-from-encoding) |
418 (ogonek-read-prefix "Prefix character" 'ogonek-prefix-char)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
419 (let* |
18264 | 420 ((from-code (ogonek-lookup-encoding from-encoding)) |
18363 | 421 (to-code ogonek-prefix-code) |
422 (recoding-pairs ; `ogonek-prefix-char' added for doubling | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
423 (ogonek-zip-lists |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
424 (cons prefix-char from-code) |
18264 | 425 (cons prefix-char to-code)))) |
426 (save-excursion | |
427 (goto-char start) | |
428 (while (< (point) end) | |
429 (let ((pair (assoc (following-char) recoding-pairs))) | |
430 (if (null pair) | |
18363 | 431 ;; not a Polish character -- skip it |
18264 | 432 (forward-char 1) |
18363 | 433 ;; Polish character -- insert a prefix pair instead |
18264 | 434 (delete-char 1) |
435 (insert ogonek-prefix-char) | |
436 (insert (cdr pair)) | |
18363 | 437 ;; the region is now one character longer |
18264 | 438 (setq end (1+ end)))))))) |
439 | |
440 (defun ogonek-prefixify-buffer (from-encoding prefix-char) | |
441 "Call `ogonek-prefixify-region' on the entire buffer." | |
442 (interactive (progn (barf-if-buffer-read-only) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
443 (list |
18264 | 444 (ogonek-read-encoding "From code" 'ogonek-prefix-from-encoding) |
445 (ogonek-read-prefix "Prefix character" 'ogonek-prefix-char)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
446 (ogonek-prefixify-region |
18264 | 447 (point-min) (point-max) from-encoding prefix-char)) |
448 | |
449 (defun ogonek-deprefixify-region (start end prefix-char to-encoding) | |
18363 | 450 "In a region, replace PREFIX pairs with their corresponding TO-encodings. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
451 PREFIX-CHAR followed by a Polish character from the `ogonek-prefix-code' |
18363 | 452 list is replaced with the corresponding TO-encoded character. A doubled |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
453 PREFIX-CHAR gets replaced with a single one. A combination of PREFIX-CHAR |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
454 followed by a non-Polish character, that is one not listed in the |
18363 | 455 `ogonek-prefix-code' constant, is left unchanged." |
18264 | 456 (interactive (progn (barf-if-buffer-read-only) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
457 (list (region-beginning) |
18264 | 458 (region-end) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
459 (ogonek-read-prefix |
18264 | 460 "Prefix character" 'ogonek-prefix-char) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
461 (ogonek-read-encoding |
18264 | 462 "To code" 'ogonek-prefix-to-encoding)))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
463 (let* |
18363 | 464 ((from-code ogonek-prefix-code) |
18264 | 465 (to-code (ogonek-lookup-encoding to-encoding)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
466 (recoding-pairs |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
467 (ogonek-zip-lists |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
468 (cons prefix-char from-code) |
18264 | 469 (cons prefix-char to-code)))) |
470 (save-excursion | |
471 (goto-char start) | |
472 (while (< (point) end) | |
473 (forward-char 1) | |
474 (if (or (not (= (preceding-char) prefix-char)) (= (point) end)) | |
18363 | 475 ;; non-prefix character or the end-of-region -- do nothing |
18264 | 476 () |
18363 | 477 ;; now, we can check the next character |
18264 | 478 (let ((pair (assoc (following-char) recoding-pairs))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
479 (if (null pair) |
18363 | 480 ;; `following-char' is not a Polish character nor it is |
481 ;; `prefix-char' since the one is among `recoding-pairs' | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
482 (forward-char 1) |
18363 | 483 ;; else prefix followed by a Polish character has been found |
484 ;; replace it by the corresponding Polish character | |
18264 | 485 (backward-char 1) |
486 (delete-char 2) | |
487 (insert (cdr pair)) | |
18363 | 488 ;; the region got shorter by one character |
18264 | 489 (setq end (1- end))))))))) |
490 | |
491 (defun ogonek-deprefixify-buffer (prefix-char to-encoding) | |
492 "Call `ogonek-deprefixify-region' on the entire buffer." | |
493 (interactive (progn (barf-if-buffer-read-only) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
494 (list |
18264 | 495 (ogonek-read-prefix "Prefix character" 'ogonek-prefix-char) |
496 (ogonek-read-encoding "To code" 'ogonek-prefix-to-encoding)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42686
diff
changeset
|
497 (ogonek-deprefixify-region |
18264 | 498 (point-min) (point-max) prefix-char to-encoding)) |
499 | |
500 (provide 'ogonek) | |
501 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79709
diff
changeset
|
502 ;; arch-tag: 672d7744-28ac-412b-965e-06a27e50d1d7 |
18264 | 503 ;;; ogonek.el ends here |