;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Created: 1995/09/24
-;;; Version: $Revision: 7.50 $
+;;; Version: $Revision: 7.53 $
;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
;;;
;;; This file is part of tm (Tools for MIME).
;;;
(defconst tm-gnus/RCS-ID
- "$Id: tm-sgnus.el,v 7.50 1996/04/11 16:10:56 morioka Exp $")
+ "$Id: tm-sgnus.el,v 7.53 1996/04/25 12:07:08 morioka Exp $")
(defconst tm-gnus/version
(concat (get-version-string tm-gnus/RCS-ID) " for September"))
(make-local-variable 'tm:mother-button-dispatcher)
(setq tm:mother-button-dispatcher
(function gnus-article-push-button))
- (let ((mime-viewer/ignored-field-regexp "^:$"))
+ (let ((mime-viewer/ignored-field-regexp "^:$")
+ (mime/default-coding-system
+ (save-excursion
+ (set-buffer gnus-summary-buffer)
+ mime/default-coding-system)))
(mime/viewer-mode nil nil nil gnus-original-article-buffer
gnus-article-buffer)
)
(setq gnus-show-mime-method (function tm-gnus/preview-article))
(defun tm-gnus/article-decode-encoded-word ()
- (tm-gnus/code-convert-region-to-emacs (point-min)(point-max)
- mime/default-coding-system)
+ (code-convert-region (point-min)(point-max)
+ (save-excursion
+ (set-buffer gnus-summary-buffer)
+ mime/default-coding-system)
+ *internal*)
(mime/decode-message-header)
(run-hooks 'tm-gnus/article-prepare-hook)
)
(setq gnus-decode-encoded-word-method
(function tm-gnus/article-decode-encoded-word))
-(if (boundp 'MULE)
- (progn
- (define-service-coding-system gnus-nntp-service nil *noconv*)
- (if (and (boundp 'nntp-server-process)
- (processp nntp-server-process)
- )
- (set-process-coding-system nntp-server-process *noconv* *noconv*)
- )
-
- (or (fboundp 'tm-gnus/original-request-article)
- (fset 'tm-gnus/original-request-article
- (symbol-function 'gnus-request-article))
- )
-
- (defun gnus-request-article (article group &optional buffer)
- (let ((file-coding-system-for-read *noconv*))
- (tm-gnus/original-request-article article group buffer)
- ))
-
- (defun tm-gnus/prepare-save-mail-function ()
- (setq file-coding-system *noconv*)
- )
- (add-hook 'nnmbox-prepare-save-mail-hook
- 'tm-gnus/prepare-save-mail-function)
- (add-hook 'nnbabyl-prepare-save-mail-hook
- 'tm-gnus/prepare-save-mail-function)
- (add-hook 'nnml-prepare-save-mail-hook
- 'tm-gnus/prepare-save-mail-function)
- (add-hook 'nnmh-prepare-save-mail-hook
- 'tm-gnus/prepare-save-mail-function)
- (add-hook 'nnfolder-prepare-save-mail-hook
- 'tm-gnus/prepare-save-mail-function)
-
- (defun tm-gnus/nnheader-find-file-noselect (&rest args)
- (let ((file-coding-system-for-read *noconv*))
- (apply (function find-file-noselect) args)
- ))
- (eval-after-load
- "nnheader"
- '(fset 'nnheader-find-file-noselect
- 'tm-gnus/nnheader-find-file-noselect)
- )
-
- (defun tm-gnus/nnmail-get-new-mail (&rest args)
- (let ((file-coding-system-for-read *noconv*))
- (apply (function tm-gnus/original-nnmail-get-new-mail) args)
- ))
- (eval-after-load
- "nnmail"
- '(progn (or (fboundp 'tm-gnus/original-nnmail-get-new-mail)
- (fset 'tm-gnus/original-nnmail-get-new-mail
- (symbol-function 'nnmail-get-new-mail))
- )
- (fset 'nnmail-get-new-mail 'tm-gnus/nnmail-get-new-mail)
- ))
- ))
+;; (if (boundp 'MULE)
+;; (progn
+;; (define-service-coding-system gnus-nntp-service nil *noconv*)
+;; (if (and (boundp 'nntp-server-process)
+;; (processp nntp-server-process)
+;; )
+;; (set-process-coding-system nntp-server-process *noconv* *noconv*)
+;; )
+;;
+;; (or (fboundp 'tm-gnus/original-request-article)
+;; (fset 'tm-gnus/original-request-article
+;; (symbol-function 'gnus-request-article))
+;; )
+;;
+;; (defun gnus-request-article (article group &optional buffer)
+;; (let ((file-coding-system-for-read *noconv*))
+;; (tm-gnus/original-request-article article group buffer)
+;; ))
+;;
+;; (defun tm-gnus/nnheader-find-file-noselect (&rest args)
+;; (let ((file-coding-system-for-read *noconv*))
+;; (apply (function find-file-noselect) args)
+;; ))
+;; (eval-after-load
+;; "nnheader"
+;; '(fset 'nnheader-find-file-noselect
+;; 'tm-gnus/nnheader-find-file-noselect)
+;; )
+;;
+;; (defun tm-gnus/nnmail-get-new-mail (&rest args)
+;; (let ((file-coding-system-for-read *noconv*))
+;; (apply (function tm-gnus/original-nnmail-get-new-mail) args)
+;; ))
+;; (eval-after-load
+;; "nnmail"
+;; '(progn (or (fboundp 'tm-gnus/original-nnmail-get-new-mail)
+;; (fset 'tm-gnus/original-nnmail-get-new-mail
+;; (symbol-function 'nnmail-get-new-mail))
+;; )
+;; (fset 'nnmail-get-new-mail 'tm-gnus/nnmail-get-new-mail)
+;; ))
+;; ))
+
+
+;;; @ for MULE
+;;;
+
+(defvar gnus-newsgroup-default-coding-system-alist nil)
+
+(defun gnus-set-newsgroup-default-coding-system (ng cs)
+ "Define CS as default coding system for newsgroup NG."
+ (set-alist 'gnus-newsgroup-default-coding-system-alist
+ (concat "^" (regexp-quote ng) "\\($\\|\\.\\)")
+ cs))
+
+(cond
+ ((boundp 'MULE)
+ (define-service-coding-system gnus-nntp-service nil *noconv*)
+ (if (and (boundp 'nntp-server-process)
+ (processp nntp-server-process)
+ )
+ (set-process-coding-system nntp-server-process *noconv* *noconv*)
+ )
+ (call-after-loaded
+ 'nnheader
+ (lambda ()
+ (defun nnheader-find-file-noselect (filename &optional nowarn rawfile)
+ (let ((file-coding-system-for-read '*noconv*))
+ (find-file-noselect filename nowarn rawfile)
+ ))
+ (defun nnheader-insert-raw-file-contents
+ (filename &optional visit beg end replace)
+ (let ((file-coding-system-for-read '*noconv*))
+ (insert-file-contents filename visit beg end replace)
+ ))
+ ;;(fset 'nnheader-raw-write-region 'si:write-region)
+ ))
+ (defun tm-gnus/prepare-save-mail-function ()
+ (setq file-coding-system *noconv*)
+ )
+ (add-hook 'nnmail-prepare-save-mail-hook
+ 'tm-gnus/prepare-save-mail-function)
+ ;; (add-hook 'nnmbox-prepare-save-mail-hook
+ ;; 'tm-gnus/prepare-save-mail-function)
+ ;; (add-hook 'nnbabyl-prepare-save-mail-hook
+ ;; 'tm-gnus/prepare-save-mail-function)
+ ;; (add-hook 'nnml-prepare-save-mail-hook
+ ;; 'tm-gnus/prepare-save-mail-function)
+ ;; (add-hook 'nnmh-prepare-save-mail-hook
+ ;; 'tm-gnus/prepare-save-mail-function)
+ ;; (add-hook 'nnfolder-prepare-save-mail-hook
+ ;; 'tm-gnus/prepare-save-mail-function)
+
+ (gnus-set-newsgroup-default-coding-system "alt.chinese.text" '*hz*)
+ (gnus-set-newsgroup-default-coding-system "alt.chinese.text.big5" '*big5*)
+ (gnus-set-newsgroup-default-coding-system "han" '*euc-kr*)
+ (gnus-set-newsgroup-default-coding-system "relcom" '*koi8*)
+ ))
;;; @ summary filter
;;;
-(cond ((not (boundp 'nnheader-encoded-words-decoding))
- (require 'tm-ew-d)
-
- (defun tm-gnus/decode-summary-from-and-subjects ()
- (mapcar
- (lambda (header)
- (let ((from (or (mail-header-from header) ""))
- (subj (or (mail-header-subject header) ""))
- (method (car gnus-current-select-method))
- )
- (if (eq method 'nntp)
- (progn
- (setq from
- (code-convert-string
- from mime/default-coding-system *internal*))
- (setq subj
- (code-convert-string
- subj mime/default-coding-system *internal*))
- ))
- (mail-header-set-from
- header (mime-eword/decode-string from))
- (mail-header-set-subject
- header (mime-eword/decode-string subj))
- ))
- gnus-newsgroup-headers))
-
- (add-hook 'gnus-select-group-hook
- (function tm-gnus/decode-summary-from-and-subjects))
+(defun tm-gnus/decode-summary-from-and-subjects ()
+ (let ((rest gnus-newsgroup-default-coding-system-alist)
+ cell)
+ (catch 'tag
+ (while (setq cell (car rest))
+ (if (string-match (car cell) gnus-newsgroup-name)
+ (throw 'tag
+ (progn
+ (make-local-variable 'mime/default-coding-system)
+ (setq mime/default-coding-system (cdr cell))
+ )))
+ (setq rest (cdr rest))
+ )))
+ (mapcar
+ (lambda (header)
+ (let ((from (or (mail-header-from header) ""))
+ (subj (or (mail-header-subject header) ""))
+ (method (car gnus-current-select-method))
+ )
+ (if (eq method 'nntp)
+ (progn
+ (setq from
+ (code-convert-string
+ from mime/default-coding-system *internal*))
+ (setq subj
+ (code-convert-string
+ subj mime/default-coding-system *internal*))
+ ))
+ (mail-header-set-from
+ header (mime-eword/decode-string from))
+ (mail-header-set-subject
+ header (mime-eword/decode-string subj))
))
+ gnus-newsgroup-headers))
+
+(or (boundp 'nnheader-encoded-words-decoding)
+ (add-hook 'gnus-select-group-hook
+ #'tm-gnus/decode-summary-from-and-subjects)
+ )
;;; @ for BBDB