diff options
| author | Kenichi Handa | 1997-05-12 06:56:21 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-05-12 06:56:21 +0000 |
| commit | 8d6913995b4c84b26d66cedd3669239f7a1390d8 (patch) | |
| tree | f9c8fd2ca16e9b160f585a773694b72e8b70660d | |
| parent | 7c9b148e8095c4cb6224cbc9e4fe842d4221d5e8 (diff) | |
| download | emacs-8d6913995b4c84b26d66cedd3669239f7a1390d8.tar.gz emacs-8d6913995b4c84b26d66cedd3669239f7a1390d8.zip | |
(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.
| -rw-r--r-- | lisp/gnus/gnus-mule.el | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/lisp/gnus/gnus-mule.el b/lisp/gnus/gnus-mule.el index f90fa3848b5..aef9e81ca7a 100644 --- a/lisp/gnus/gnus-mule.el +++ b/lisp/gnus/gnus-mule.el | |||
| @@ -31,15 +31,23 @@ | |||
| 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) |
| @@ -72,7 +80,7 @@ coding-system for reading and writing respectively." | |||
| 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) |
| @@ -160,6 +168,31 @@ coding-system for reading and writing respectively." | |||
| 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." |
| @@ -169,15 +202,14 @@ coding-system for reading and writing respectively." | |||
| 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) |