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