annotate lisp/gnus/gnus-mule.el @ 19299:7cd7373cc021

(c-initialize-cc-mode): Set c-buffer-is-cc-mode to t. (c-initialize-cc-mode): Require 'cc-mode-19 if functionp is not bound. Check cc-mode-19 interface requirements. (c-mode, c++-mode, objc-mode, java-mode, idl-mode): Don't set comment-multi-line here. (c-mode): c-comment-start-regexp uses c-C++-comment-start-regexp to support line oriented comments.
author Richard M. Stallman <rms@gnu.org>
date Mon, 11 Aug 1997 22:11:27 +0000
parents 21855271c115
children e658839d837e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17315
a3ca5e15c82a Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents: 17081
diff changeset
1 ;;; gnus-mule.el --- Provide multilingual environment to GNUS
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: gnus, mule
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;; This package enables GNUS to code convert automatically
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;; accoding to a coding system specified for each news group.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 ;; Please put the following line in your .emacs:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; (add-hook 'gnus-startup-hook 'gnus-mule-initialize)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;; If you want to specify some coding system for a specific news
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;; group, add the fllowing line in your .emacs:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 ;; (gnus-mule-add-group "xxx.yyy.zzz" 'some-coding-system)
17757
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
34
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
35 ;; By default, only few news groups are registered as the target of
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
36 ;; code conversion. So, each regional users had better set an
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
37 ;; appropriate coding system for as below:
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
38 ;; (gnus-mule-add-group "" 'iso-2022-jp) ;; the case for Japanese
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 (require 'gnus)
17757
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
41 (require 'message)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 (defvar gnus-newsgroup-coding-systems nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 "Assoc list of news groups vs corresponding coding systems.
17757
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
45 Each element is has the form (PATTERN CODING-FOR-READ . CODING-FOR-POST),
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
46 where,
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
47 PATTERN is a regular expression matching news group names,
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
48 CODING-FOR-READ is a coding system of articles of the news groups, and
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
49 CODING-FOR-POST is a coding system to be encoded for posting articles
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
50 to the news groups.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 (defun gnus-mule-add-group (name coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 "Specify that articles of news group NAME are encoded in CODING-SYSTEM.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 All news groups deeper than NAME are also the target.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 If CODING-SYSTEM is a cons, the car and cdr part are regarded as
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 coding-system for reading and writing respectively."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 (if (not (consp coding-system))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 (setq coding-system (cons coding-system coding-system)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 (setq name (concat "^" (regexp-quote name)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 (let ((group (assoc name gnus-newsgroup-coding-systems)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 (if group
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 (setcdr group coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 (setq gnus-newsgroup-coding-systems
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 (cons (cons name coding-system) gnus-newsgroup-coding-systems)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 (defun gnus-mule-get-coding-system (group)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 "Return the coding system for news group GROUP."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (let ((groups gnus-newsgroup-coding-systems)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 (len -1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 ;; Find an entry which matches GROUP the best (i.e. longest).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 (while groups
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 (if (and (string-match (car (car groups)) group)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 (> (match-end 0) len))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 (setq len (match-end 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 coding-system (cdr (car groups))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 (setq groups (cdr groups)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 coding-system))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 ;; Flag to indicate if article buffer is already decoded or not.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 (defvar gnus-mule-article-decoded nil)
17757
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
83 ;; Coding system for reading articles of the current news group.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 (defvar gnus-mule-coding-system nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 (defvar gnus-mule-subject nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 (defvar gnus-mule-decoded-subject nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 (defvar gnus-mule-original-subject nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 ;; Encode (if ENCODING is t) or decode (if ENCODING is nil) the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 ;; region from START to END by CODING-SYSTEM.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 (defun gnus-mule-code-convert1 (start end coding-system encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 (if (< start end)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 (if encoding
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 (encode-coding-region start end coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 (decode-coding-region start end coding-system)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 ;; Encode (if ENCODING is t) or decode (if ENCODING is nil) the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 ;; current buffer by CODING-SYSTEM. Try not to move positions of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 ;; (window-start) and (point).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 (defun gnus-mule-code-convert (coding-system encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 (if coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 (let ((win (get-buffer-window (current-buffer))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 (if win
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 ;; We should keep (point) and (window-start).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 (save-window-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 (select-window win)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 (if encoding
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 ;; Simple way to assure point is on valid character boundary.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 (beginning-of-line))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 (gnus-mule-code-convert1 (point-min) (window-start)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 coding-system encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 (gnus-mule-code-convert1 (window-start) (point)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 coding-system encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 (gnus-mule-code-convert1 (point) (point-max)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 coding-system encoding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 (if (not (pos-visible-in-window-p))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 ;; point went out of window, move to the bottom of window.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 (move-to-window-line -1)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 ;; No window for the buffer, no need to worry about (point)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 ;; and (windos-start).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 (gnus-mule-code-convert1 (point-min) (point-max)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 coding-system encoding))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 )))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 ;; Set `gnus-mule-coding-system' to the coding system articles of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 ;; current news group is encoded. This function is set in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 ;; `gnus-select-group-hook'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 (defun gnus-mule-select-coding-system ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 (let ((coding-system (gnus-mule-get-coding-system gnus-newsgroup-name)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 (setq gnus-mule-coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 (if (and coding-system (coding-system-p (car coding-system)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 (car coding-system)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 ;; Decode the current article. This function is set in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 ;; `gnus-article-prepare-hook'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 (defun gnus-mule-decode-article ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 (gnus-mule-code-convert gnus-mule-coding-system nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 (setq gnus-mule-article-decoded t))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 ;; Decode the current summary buffer. This function is set in
17081
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
142 ;; `gnus-summary-generate-hook'.
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
143 ;; Made by <sangil@hugsvr.kaist.ac.kr>,
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
144 ;; coded by <crisp@hugsvr.kaist.ac.kr>.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 (defun gnus-mule-decode-summary ()
17081
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
146 (if gnus-mule-coding-system
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
147 (mapcar
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
148 (lambda (headers)
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
149 (let ((subject (aref headers 1))
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
150 (author (aref headers 2)))
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
151 (aset headers 1
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
152 (decode-coding-string subject gnus-mule-coding-system))
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
153 (aset headers 2
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
154 (decode-coding-string author gnus-mule-coding-system))))
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
155 gnus-newsgroup-headers)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 (defun gnus-mule-toggle-article-format ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 "Toggle decoding/encoding of the current article buffer."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 (let ((buf (get-buffer gnus-article-buffer)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 (if (and gnus-mule-coding-system buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 (set-buffer buf)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (let ((modif (buffer-modified-p))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 buffer-read-only)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (gnus-mule-code-convert gnus-mule-coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 gnus-mule-article-decoded)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (setq gnus-mule-article-decoded (not gnus-mule-article-decoded))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 (set-buffer-modified-p modif))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170
17757
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
171 ;; Encode a news article before sending it.
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
172 (defun gnus-mule-message-send-news-function ()
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
173 (let ((groups (message-fetch-field "newsgroups"))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
174 (idx 0)
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
175 coding-system coding-system-list group-list)
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
176 (if (not groups)
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
177 ;; We are not sending the current buffer via news.
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
178 nil
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
179 (while (string-match "[^ ,]+" groups idx)
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
180 (setq idx (match-end 0))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
181 (setq coding-system
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
182 (cdr (gnus-mule-get-coding-system
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
183 (substring groups (match-beginning 0) idx))))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
184 (if (not (memq coding-system coding-system-list))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
185 (setq coding-system-list (cons coding-system coding-system-list))))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
186 (if (> (length coding-system-list) 1)
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
187 (setq coding-system (read-coding-system "Coding system: ")))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
188 (if coding-system
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
189 (encode-coding-region (point-min) (point-max) coding-system)))))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
190
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
191 ;; Encode a mail message before sending it.
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
192 (defun gnus-mule-message-send-mail-function ()
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
193 (if sendmail-coding-system
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
194 (encode-coding-region (point-min) (point-max) sendmail-coding-system)))
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
195
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 (defun gnus-mule-initialize ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 "Do several settings for GNUS to enable automatic code conversion."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 ;; Convenient key definitions
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 (define-key gnus-article-mode-map "z" 'gnus-mule-toggle-article-format)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 (define-key gnus-summary-mode-map "z" 'gnus-mule-toggle-article-format)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 ;; Hook definition
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 (add-hook 'gnus-select-group-hook 'gnus-mule-select-coding-system)
17081
5810f3bb79d9 (gnus-mule-decode-summary): The function implemented correctly.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
204 (add-hook 'gnus-summary-generate-hook 'gnus-mule-decode-summary)
17757
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
205 (add-hook 'gnus-article-prepare-hook 'gnus-mule-decode-article)
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
206 (add-hook 'message-send-news-hook
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
207 'gnus-mule-message-send-news-function)
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
208 (add-hook 'message-send-mail-hook
f008897b73f0 (gnus-mule-message-send-news-function): New
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
209 'gnus-mule-message-send-mail-function))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210
17839
b4a81f70d905 Coding system names changed as follows:
Kenichi Handa <handa@m17n.org>
parents: 17757
diff changeset
211 (gnus-mule-add-group "" 'undecided)
18305
21855271c115 Adjusted for the coding system name change.
Kenichi Handa <handa@m17n.org>
parents: 17839
diff changeset
212 (gnus-mule-add-group "fj" 'iso-2022-7bit)
21855271c115 Adjusted for the coding system name change.
Kenichi Handa <handa@m17n.org>
parents: 17839
diff changeset
213 (gnus-mule-add-group "alt.chinese.text" 'chinese-hz)
21855271c115 Adjusted for the coding system name change.
Kenichi Handa <handa@m17n.org>
parents: 17839
diff changeset
214 (gnus-mule-add-group "alt.hk" 'chinese-hz)
21855271c115 Adjusted for the coding system name change.
Kenichi Handa <handa@m17n.org>
parents: 17839
diff changeset
215 (gnus-mule-add-group "alt.chinese.text.big5" 'chinese-big5)
21855271c115 Adjusted for the coding system name change.
Kenichi Handa <handa@m17n.org>
parents: 17839
diff changeset
216 (gnus-mule-add-group "soc.culture.vietnamese" '(nil . vietnamese-viqr))
21855271c115 Adjusted for the coding system name change.
Kenichi Handa <handa@m17n.org>
parents: 17839
diff changeset
217 (gnus-mule-add-group "relcom" 'cyrillic-koi8)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 (add-hook 'gnus-startup-hook 'gnus-mule-initialize)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221 ;; gnus-mule.el ends here