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