annotate lisp/international/ogonek.el @ 91473:d9afb7a33dc0

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