comparison lisp/international/swedish.el @ 583:3c0c1cd8428a

Initial revision
author Jim Blandy <jimb@redhat.com>
date Mon, 16 Mar 1992 20:39:05 +0000
parents
children 7cbd4fcd8b0f
comparison
equal deleted inserted replaced
582:a9c4bc19b2aa 583:3c0c1cd8428a
1 ;; Miscellaneous functions for dealing with Swedish.
2 ;; Copyright (C) 1988 Free Software Foundation, Inc.
3
4 ;; This file is part of GNU Emacs.
5
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 1, or (at your option)
9 ;; any later version.
10
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
15
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20
21 ;; Written by Howard Gayle. See case-table.el for details.
22
23 ;; See iso-swed.el for a description of the character set.
24
25 (require 'iso-syntax)
26
27 (defvar swedish-re
28 "[ \t\n]\\(och\\|att\\|en\\|{r\\|\\[R\\|p}\\|P\\]\\|som\\|det\\|av\\|den\\|f|r\\|F\\\\R\\)[ \t\n.,?!:;'\")}]"
29 "Regular expression for common Swedish words.")
30
31 (defvar swascii-to-8859-trans
32 (let ((string (make-string 256 ? ))
33 (i 0))
34 (while (< i 256)
35 (aset string i i)
36 (setq i (1+ i)))
37 (aset string ?\[ 196)
38 (aset string ?\] 197)
39 (aset string ?\\ 214)
40 (aset string ?^ 220)
41 (aset string ?\{ 228)
42 (aset string ?\} 229)
43 (aset string ?\` 233)
44 (aset string ?\| 246)
45 (aset string ?~ 252)
46 string)
47 "Trans table from SWASCII to 8859.")
48
49 ; $ is not converted because it almost always means US
50 ; dollars, not general currency sign. @ is not converted
51 ; because it is more likely to be an at sign in a mail address
52 ; than an E with acute accent.
53
54 (defun swascii-to-8859-buffer ()
55 "Convert characters in buffer from Swedish/Finnish-ascii to ISO 8859/1.
56 Works even on read-only buffers. `$' and `@' are not converted."
57 (interactive)
58 (let ((buffer-read-only nil))
59 (translate-region (point-min) (point-max) swascii-to-8859-trans)))
60
61 (defun swascii-to-8859-buffer-maybe ()
62 "Call swascii-to-8859-buffer if the buffer looks like Swedish-ascii.
63 Leaves point just after the word that looks Swedish."
64 (interactive)
65 (let ((case-fold-search t))
66 (if (re-search-forward swedish-re nil t)
67 (swascii-to-8859-buffer))))
68
69 (setq rmail-show-message-hook 'swascii-to-8859-buffer-maybe)
70
71 (or (boundp 'news-group-hook-alist) (setq news-group-hook-alist nil))
72 (setq news-group-hook-alist
73 (append '(("^swnet." . swascii-to-8859-buffer-maybe))
74 news-group-hook-alist))
75
76 (defvar 8859-to-swascii-trans
77 (let ((string (make-string 256 ? ))
78 (i 0))
79 (while (< i 256)
80 (aset string i i)
81 (setq i (1+ i)))
82 (aset string 164 ?$)
83 (aset string 196 ?\[)
84 (aset string 197 ?\])
85 (aset string 201 ?@)
86 (aset string 214 ?\\)
87 (aset string 220 ?^)
88 (aset string 228 ?\{)
89 (aset string 229 ?\})
90 (aset string 233 ?\`)
91 (aset string 246 ?\|)
92 (aset string 252 ?~)
93 string)
94 "8859 to SWASCII trans table.")
95
96 (defun 8859-to-swascii-buffer ()
97 "Convert characters in buffer from ISO 8859/1 to Swedish/Finnish-ascii."
98 (interactive "*")
99 (translate-region (point-min) (point-max) 8859-to-swascii-trans))
100
101 (setq mail-send-hook '8859-to-swascii-buffer)
102 (setq news-inews-hook '8859-to-swascii-buffer)
103
104 ;; It's not clear what purpose is served by a separate
105 ;; Swedish mode that differs from Text mode only in having
106 ;; a separate abbrev table. Nothing says that the abbrevs you
107 ;; define in Text mode have to be English!
108
109 ;(defvar swedish-mode-abbrev-table nil
110 ; "Abbrev table used while in swedish mode.")
111 ;(define-abbrev-table 'swedish-mode-abbrev-table ())
112
113 ;(defun swedish-mode ()
114 ; "Major mode for editing Swedish text intended for humans to
115 ;read. Special commands:\\{text-mode-map}
116 ;Turning on swedish-mode calls the value of the variable
117 ;text-mode-hook, if that value is non-nil."
118 ; (interactive)
119 ; (kill-all-local-variables)
120 ; (use-local-map text-mode-map)
121 ; (setq mode-name "Swedish")
122 ; (setq major-mode 'swedish-mode)
123 ; (setq local-abbrev-table swedish-mode-abbrev-table)
124 ; (set-syntax-table text-mode-syntax-table)
125 ; (run-hooks 'text-mode-hook))
126
127 ;(defun indented-swedish-mode ()
128 ; "Major mode for editing indented Swedish text intended for
129 ;humans to read.\\{indented-text-mode-map}
130 ;Turning on indented-swedish-mode calls the value of the
131 ;variable text-mode-hook, if that value is non-nil."
132 ; (interactive)
133 ; (kill-all-local-variables)
134 ; (use-local-map text-mode-map)
135 ; (define-abbrev-table 'swedish-mode-abbrev-table ())
136 ; (setq local-abbrev-table swedish-mode-abbrev-table)
137 ; (set-syntax-table text-mode-syntax-table)
138 ; (make-local-variable 'indent-line-function)
139 ; (setq indent-line-function 'indent-relative-maybe)
140 ; (use-local-map indented-text-mode-map)
141 ; (setq mode-name "Indented Swedish")
142 ; (setq major-mode 'indented-swedish-mode)
143 ; (run-hooks 'text-mode-hook))
144
145 (provide 'swedish)