comparison lisp/gnus/gnus-mule.el @ 17757:f008897b73f0

(gnus-mule-message-send-news-function): New function to encode text before sending by news. (gnus-mule-message-send-mail-function): New function to encode text before sending by mail. (gnus-mule-initialize): Add gnus-mule-message-send-news-function to the hook message-send-news-hook. Add gnus-mule-message-send-mail-function to the hook message-send-mail-hook.
author Kenichi Handa <handa@m17n.org>
date Mon, 12 May 1997 06:56:21 +0000
parents a3ca5e15c82a
children b4a81f70d905
comparison
equal deleted inserted replaced
17756:0000a992fd24 17757:f008897b73f0
29 ;; Please put the following line in your .emacs: 29 ;; Please put the following line in your .emacs:
30 ;; (add-hook 'gnus-startup-hook 'gnus-mule-initialize) 30 ;; (add-hook 'gnus-startup-hook 'gnus-mule-initialize)
31 ;; If you want to specify some coding system for a specific news 31 ;; If you want to specify some coding system for a specific news
32 ;; group, add the fllowing line in your .emacs: 32 ;; group, add the fllowing line in your .emacs:
33 ;; (gnus-mule-add-group "xxx.yyy.zzz" 'some-coding-system) 33 ;; (gnus-mule-add-group "xxx.yyy.zzz" 'some-coding-system)
34 ;; 34
35 ;; Decoding of summary buffer is not yet implemented. 35 ;; By default, only few news groups are registered as the target of
36 ;; code conversion. So, each regional users had better set an
37 ;; appropriate coding system for as below:
38 ;; (gnus-mule-add-group "" 'iso-2022-jp) ;; the case for Japanese
36 39
37 (require 'gnus) 40 (require 'gnus)
41 (require 'message)
38 42
39 (defvar gnus-newsgroup-coding-systems nil 43 (defvar gnus-newsgroup-coding-systems nil
40 "Assoc list of news groups vs corresponding coding systems. 44 "Assoc list of news groups vs corresponding coding systems.
41 Each element is a list of news group name and cons of coding systems 45 Each element is has the form (PATTERN CODING-FOR-READ . CODING-FOR-POST),
42 for reading and posting.") 46 where,
47 PATTERN is a regular expression matching news group names,
48 CODING-FOR-READ is a coding system of articles of the news groups, and
49 CODING-FOR-POST is a coding system to be encoded for posting articles
50 to the news groups.")
43 51
44 ;;;###autoload 52 ;;;###autoload
45 (defun gnus-mule-add-group (name coding-system) 53 (defun gnus-mule-add-group (name coding-system)
46 "Specify that articles of news group NAME are encoded in CODING-SYSTEM. 54 "Specify that articles of news group NAME are encoded in CODING-SYSTEM.
47 All news groups deeper than NAME are also the target. 55 All news groups deeper than NAME are also the target.
70 (setq groups (cdr groups))) 78 (setq groups (cdr groups)))
71 coding-system)) 79 coding-system))
72 80
73 ;; Flag to indicate if article buffer is already decoded or not.") 81 ;; Flag to indicate if article buffer is already decoded or not.")
74 (defvar gnus-mule-article-decoded nil) 82 (defvar gnus-mule-article-decoded nil)
75 ;; Codingsystem for reading articles of the current news group. 83 ;; Coding system for reading articles of the current news group.
76 (defvar gnus-mule-coding-system nil) 84 (defvar gnus-mule-coding-system nil)
77 (defvar gnus-mule-subject nil) 85 (defvar gnus-mule-subject nil)
78 (defvar gnus-mule-decoded-subject nil) 86 (defvar gnus-mule-decoded-subject nil)
79 (defvar gnus-mule-original-subject nil) 87 (defvar gnus-mule-original-subject nil)
80 88
158 (gnus-mule-code-convert gnus-mule-coding-system 166 (gnus-mule-code-convert gnus-mule-coding-system
159 gnus-mule-article-decoded) 167 gnus-mule-article-decoded)
160 (setq gnus-mule-article-decoded (not gnus-mule-article-decoded)) 168 (setq gnus-mule-article-decoded (not gnus-mule-article-decoded))
161 (set-buffer-modified-p modif)))))) 169 (set-buffer-modified-p modif))))))
162 170
171 ;; Encode a news article before sending it.
172 (defun gnus-mule-message-send-news-function ()
173 (let ((groups (message-fetch-field "newsgroups"))
174 (idx 0)
175 coding-system coding-system-list group-list)
176 (if (not groups)
177 ;; We are not sending the current buffer via news.
178 nil
179 (while (string-match "[^ ,]+" groups idx)
180 (setq idx (match-end 0))
181 (setq coding-system
182 (cdr (gnus-mule-get-coding-system
183 (substring groups (match-beginning 0) idx))))
184 (if (not (memq coding-system coding-system-list))
185 (setq coding-system-list (cons coding-system coding-system-list))))
186 (if (> (length coding-system-list) 1)
187 (setq coding-system (read-coding-system "Coding system: ")))
188 (if coding-system
189 (encode-coding-region (point-min) (point-max) coding-system)))))
190
191 ;; Encode a mail message before sending it.
192 (defun gnus-mule-message-send-mail-function ()
193 (if sendmail-coding-system
194 (encode-coding-region (point-min) (point-max) sendmail-coding-system)))
195
163 ;;;###autoload 196 ;;;###autoload
164 (defun gnus-mule-initialize () 197 (defun gnus-mule-initialize ()
165 "Do several settings for GNUS to enable automatic code conversion." 198 "Do several settings for GNUS to enable automatic code conversion."
166 ;; Convenient key definitions 199 ;; Convenient key definitions
167 (define-key gnus-article-mode-map "z" 'gnus-mule-toggle-article-format) 200 (define-key gnus-article-mode-map "z" 'gnus-mule-toggle-article-format)
168 (define-key gnus-summary-mode-map "z" 'gnus-mule-toggle-article-format) 201 (define-key gnus-summary-mode-map "z" 'gnus-mule-toggle-article-format)
169 ;; Hook definition 202 ;; Hook definition
170 (add-hook 'gnus-select-group-hook 'gnus-mule-select-coding-system) 203 (add-hook 'gnus-select-group-hook 'gnus-mule-select-coding-system)
171 (add-hook 'gnus-summary-generate-hook 'gnus-mule-decode-summary) 204 (add-hook 'gnus-summary-generate-hook 'gnus-mule-decode-summary)
172 (add-hook 'gnus-article-prepare-hook 'gnus-mule-decode-article)) 205 (add-hook 'gnus-article-prepare-hook 'gnus-mule-decode-article)
173 206 (add-hook 'message-send-news-hook
174 (gnus-mule-add-group "" 'iso-2022-7) ;; default coding system 207 'gnus-mule-message-send-news-function)
175 (gnus-mule-add-group "alt" 'no-conversion) 208 (add-hook 'message-send-mail-hook
176 (gnus-mule-add-group "comp" 'no-conversion) 209 'gnus-mule-message-send-mail-function))
177 (gnus-mule-add-group "gnu" 'no-conversion) 210
178 (gnus-mule-add-group "rec" 'no-conversion) 211 (gnus-mule-add-group "" 'automatic-conversion)
179 (gnus-mule-add-group "sci" 'no-conversion) 212 (gnus-mule-add-group "fj" 'iso-2022-7)
180 (gnus-mule-add-group "soc" 'no-conversion)
181 (gnus-mule-add-group "alt.chinese.text" 'hz-gb-2312) 213 (gnus-mule-add-group "alt.chinese.text" 'hz-gb-2312)
182 (gnus-mule-add-group "alt.hk" 'hz-gb-2312) 214 (gnus-mule-add-group "alt.hk" 'hz-gb-2312)
183 (gnus-mule-add-group "alt.chinese.text.big5" 'cn-big5) 215 (gnus-mule-add-group "alt.chinese.text.big5" 'cn-big5)
184 (gnus-mule-add-group "soc.culture.vietnamese" '(nil . viqr)) 216 (gnus-mule-add-group "soc.culture.vietnamese" '(nil . viqr))
185 217