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