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