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