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