Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; swedish.el --- miscellaneous functions for dealing with Swedish |
c88ab9ce | 2 | |
73b0cd50 | 3 | ;; Copyright (C) 1988, 2001-2011 |
f2e3589a | 4 | ;; Free Software Foundation, Inc. |
58142744 | 5 | |
e5167999 ER |
6 | ;; Author: Howard Gayle |
7 | ;; Maintainer: FSF | |
a1d15b3e | 8 | ;; Keywords: i18n |
3b4a6e27 JB |
9 | |
10 | ;; This file is part of GNU Emacs. | |
11 | ||
4936186e | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
3b4a6e27 | 13 | ;; it under the terms of the GNU General Public License as published by |
4936186e GM |
14 | ;; the Free Software Foundation, either version 3 of the License, or |
15 | ;; (at your option) any later version. | |
3b4a6e27 JB |
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 | |
4936186e | 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
3b4a6e27 | 24 | |
55535639 PJ |
25 | ;;; Commentary: |
26 | ||
e94a9773 GM |
27 | ;; This file has been obsolete since Emacs 22.1. |
28 | ||
0584a38f DL |
29 | ;; Fixme: Is this actually used? if so, it should be in language, |
30 | ;; possibly as a feature property of Swedish, probably defining a | |
31 | ;; `swascii' coding system. | |
32 | ||
e5167999 | 33 | ;;; Code: |
3b4a6e27 JB |
34 | |
35 | ;; Written by Howard Gayle. See case-table.el for details. | |
36 | ||
37 | ;; See iso-swed.el for a description of the character set. | |
38 | ||
623f1465 JB |
39 | (defvar mail-send-hook) |
40 | (defvar news-group-hook-alist) | |
41 | (defvar news-inews-hook) | |
6f42bcf2 | 42 | |
3b4a6e27 JB |
43 | (defvar swedish-re |
44 | "[ \t\n]\\(och\\|att\\|en\\|{r\\|\\[R\\|p}\\|P\\]\\|som\\|det\\|av\\|den\\|f|r\\|F\\\\R\\)[ \t\n.,?!:;'\")}]" | |
45 | "Regular expression for common Swedish words.") | |
46 | ||
47 | (defvar swascii-to-8859-trans | |
48 | (let ((string (make-string 256 ? )) | |
49 | (i 0)) | |
50 | (while (< i 256) | |
51 | (aset string i i) | |
52 | (setq i (1+ i))) | |
53 | (aset string ?\[ 196) | |
54 | (aset string ?\] 197) | |
55 | (aset string ?\\ 214) | |
56 | (aset string ?^ 220) | |
57 | (aset string ?\{ 228) | |
58 | (aset string ?\} 229) | |
59 | (aset string ?\` 233) | |
60 | (aset string ?\| 246) | |
61 | (aset string ?~ 252) | |
62 | string) | |
63 | "Trans table from SWASCII to 8859.") | |
64 | ||
65 | ; $ is not converted because it almost always means US | |
66 | ; dollars, not general currency sign. @ is not converted | |
67 | ; because it is more likely to be an at sign in a mail address | |
68 | ; than an E with acute accent. | |
69 | ||
70 | (defun swascii-to-8859-buffer () | |
71 | "Convert characters in buffer from Swedish/Finnish-ascii to ISO 8859/1. | |
72 | Works even on read-only buffers. `$' and `@' are not converted." | |
73 | (interactive) | |
74 | (let ((buffer-read-only nil)) | |
75 | (translate-region (point-min) (point-max) swascii-to-8859-trans))) | |
76 | ||
77 | (defun swascii-to-8859-buffer-maybe () | |
78 | "Call swascii-to-8859-buffer if the buffer looks like Swedish-ascii. | |
79 | Leaves point just after the word that looks Swedish." | |
80 | (interactive) | |
81 | (let ((case-fold-search t)) | |
82 | (if (re-search-forward swedish-re nil t) | |
83 | (swascii-to-8859-buffer)))) | |
84 | ||
85 | (setq rmail-show-message-hook 'swascii-to-8859-buffer-maybe) | |
86 | ||
3b4a6e27 JB |
87 | (setq news-group-hook-alist |
88 | (append '(("^swnet." . swascii-to-8859-buffer-maybe)) | |
6f42bcf2 | 89 | (bound-and-true-p news-group-hook-alist))) |
3b4a6e27 JB |
90 | |
91 | (defvar 8859-to-swascii-trans | |
92 | (let ((string (make-string 256 ? )) | |
93 | (i 0)) | |
94 | (while (< i 256) | |
95 | (aset string i i) | |
96 | (setq i (1+ i))) | |
97 | (aset string 164 ?$) | |
98 | (aset string 196 ?\[) | |
99 | (aset string 197 ?\]) | |
100 | (aset string 201 ?@) | |
101 | (aset string 214 ?\\) | |
102 | (aset string 220 ?^) | |
103 | (aset string 228 ?\{) | |
104 | (aset string 229 ?\}) | |
105 | (aset string 233 ?\`) | |
106 | (aset string 246 ?\|) | |
107 | (aset string 252 ?~) | |
108 | string) | |
109 | "8859 to SWASCII trans table.") | |
110 | ||
111 | (defun 8859-to-swascii-buffer () | |
112 | "Convert characters in buffer from ISO 8859/1 to Swedish/Finnish-ascii." | |
113 | (interactive "*") | |
114 | (translate-region (point-min) (point-max) 8859-to-swascii-trans)) | |
115 | ||
116 | (setq mail-send-hook '8859-to-swascii-buffer) | |
117 | (setq news-inews-hook '8859-to-swascii-buffer) | |
118 | ||
119 | ;; It's not clear what purpose is served by a separate | |
120 | ;; Swedish mode that differs from Text mode only in having | |
121 | ;; a separate abbrev table. Nothing says that the abbrevs you | |
122 | ;; define in Text mode have to be English! | |
123 | ||
124 | ;(defvar swedish-mode-abbrev-table nil | |
125 | ; "Abbrev table used while in swedish mode.") | |
126 | ;(define-abbrev-table 'swedish-mode-abbrev-table ()) | |
127 | ||
128 | ;(defun swedish-mode () | |
129 | ; "Major mode for editing Swedish text intended for humans to | |
130 | ;read. Special commands:\\{text-mode-map} | |
131 | ;Turning on swedish-mode calls the value of the variable | |
132 | ;text-mode-hook, if that value is non-nil." | |
133 | ; (interactive) | |
134 | ; (kill-all-local-variables) | |
135 | ; (use-local-map text-mode-map) | |
136 | ; (setq mode-name "Swedish") | |
137 | ; (setq major-mode 'swedish-mode) | |
138 | ; (setq local-abbrev-table swedish-mode-abbrev-table) | |
139 | ; (set-syntax-table text-mode-syntax-table) | |
0124295f | 140 | ; (run-mode-hooks 'text-mode-hook)) |
3b4a6e27 JB |
141 | |
142 | ;(defun indented-swedish-mode () | |
143 | ; "Major mode for editing indented Swedish text intended for | |
144 | ;humans to read.\\{indented-text-mode-map} | |
145 | ;Turning on indented-swedish-mode calls the value of the | |
146 | ;variable text-mode-hook, if that value is non-nil." | |
147 | ; (interactive) | |
148 | ; (kill-all-local-variables) | |
149 | ; (use-local-map text-mode-map) | |
150 | ; (define-abbrev-table 'swedish-mode-abbrev-table ()) | |
151 | ; (setq local-abbrev-table swedish-mode-abbrev-table) | |
152 | ; (set-syntax-table text-mode-syntax-table) | |
153 | ; (make-local-variable 'indent-line-function) | |
154 | ; (setq indent-line-function 'indent-relative-maybe) | |
155 | ; (use-local-map indented-text-mode-map) | |
156 | ; (setq mode-name "Indented Swedish") | |
157 | ; (setq major-mode 'indented-swedish-mode) | |
0124295f | 158 | ; (run-mode-hooks 'text-mode-hook)) |
3b4a6e27 JB |
159 | |
160 | (provide 'swedish) | |
c88ab9ce ER |
161 | |
162 | ;;; swedish.el ends here |