2 ;;; tm-gnus3.el --- tm-gnus module for GNUS 3.*
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1993,1994,1995 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;;; Created: 1993/11/20
10 ;;; Version: $Revision: 7.4 $
11 ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
13 ;;; This file is part of tm (Tools for MIME).
15 ;;; This program is free software; you can redistribute it and/or
16 ;;; modify it under the terms of the GNU General Public License as
17 ;;; published by the Free Software Foundation; either version 2, or
18 ;;; (at your option) any later version.
20 ;;; This program is distributed in the hope that it will be useful,
21 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 ;;; General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with This program. If not, write to the Free Software
27 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
37 (autoload 'mime/decode-message-header
38 "tm-ew-d" "Decode MIME encoded-words in message header." t)
39 (autoload 'mime-eword/decode-string
40 "tm-ew-d" "Decode MIME encoded-words in string." t)
42 (fset 'gnus-summary-select-article 'gnus-Subject-select-article)
48 (defconst tm-gnus/RCS-ID
49 "$Id: tm-gnus3.el,v 7.4 1996/01/23 04:53:43 morioka Exp $")
51 (defconst tm-gnus/version
52 (concat (get-version-string tm-gnus/RCS-ID) " for GNUS 3"))
58 (defvar tm-gnus/decoding-mode t "*Decode MIME header if non-nil.")
64 (defun tm-gnus/add-decoding-mode-to-mode-line ()
65 (or (assq 'tm-gnus/decoding-mode minor-mode-alist)
66 (setq minor-mode-alist
67 (cons (list 'tm-gnus/decoding-mode " MIME")
71 (if (not (string-match "^GNUS 3\.14\.4" gnus-version))
73 (add-hook 'gnus-Article-mode-hook
76 (make-local-variable 'minor-mode-alist)
77 (tm-gnus/add-decoding-mode-to-mode-line)
81 (add-hook 'gnus-Article-mode-hook
82 (function tm-gnus/add-decoding-mode-to-mode-line))
85 ;;; @@ to decode subjects in mode-line
87 ;; This function imported from gnus.el.
89 ;; New implementation in gnus 3.14.3
92 (defun tm-gnus/article-set-mode-line ()
93 "Set Article mode line string.
94 If you don't like it, define your own gnus-article-set-mode-line."
95 (let ((maxlen 15) ;Maximum subject length
97 (if gnus-current-headers
98 (mime-eword/decode-string
99 (nntp-header-subject gnus-current-headers))
102 ;; The value must be a string to escape %-constructs because of subject.
103 (setq mode-line-buffer-identification
104 (format "GNUS: %s%s %s%s%s"
106 (if gnus-current-article
107 (format "/%d" gnus-current-article) "")
108 (rightful-boundary-short-string subject
109 (min (string-width subject)
111 (if (> (string-width subject) maxlen) "..." "")
112 (make-string (max 0 (- 17 (string-width subject))) ? )
114 (set-buffer-modified-p t))
116 (fset 'gnus-Article-set-mode-line 'tm-gnus/article-set-mode-line)
119 ;;; @ change MIME encoded-word decoding mode, decoding or non decoding.
122 (defun tm-gnus/set-decoding-mode (arg)
123 "Set MIME encoded-word processing.
124 With arg, turn MIME encoded-word processing on iff arg is positive."
125 (setq tm-gnus/decoding-mode arg)
126 (setq gnus-have-all-headers (not gnus-have-all-headers))
127 (gnus-summary-select-article (not gnus-have-all-headers) t)
130 (defun tm-gnus/toggle-decoding-mode ()
131 "Toggle MIME encoded-word processing.
132 With arg, turn MIME encoded-word processing on iff arg is positive."
134 (tm-gnus/set-decoding-mode (not tm-gnus/decoding-mode))
141 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
143 (defun tm-gnus/view-message (arg)
144 "MIME decode and play this message."
146 (let ((gnus-break-pages nil))
147 (gnus-Subject-select-article t t)
149 (pop-to-buffer gnus-Article-buffer t)
157 (set-alist 'mime-viewer/quitting-method-alist
159 (if (string-match (regexp-quote "3.14.4") gnus-version)
162 (mime-viewer/kill-buffer)
163 (delete-other-windows)
164 (gnus-Article-show-summary)
168 (mime-viewer/kill-buffer)
169 (delete-other-windows)
170 (gnus-Article-show-subjects)
183 (set-atype 'mime/content-decoding-condition
184 '((type . "message/partial")
185 (method . mime-article/grab-message/partials)
186 (major-mode . gnus-Article-mode)
187 (summary-buffer-exp . gnus-Subject-buffer)
190 (set-alist 'tm-partial/preview-article-method-alist
194 (tm-gnus/view-message (gnus-Subject-article-number))
199 ;;; @ Summary decoding
202 (add-hook 'gnus-Select-group-hook (function tm-gnus/decode-summary-subjects))
208 (define-key gnus-Subject-mode-map "\et" 'tm-gnus/toggle-decoding-mode)
209 (define-key gnus-Subject-mode-map "v" 'tm-gnus/view-message)
211 (defun tm-gnus/decode-encoded-word-if-you-need ()
212 (if (and tm-gnus/decoding-mode
213 (cond ((boundp 'all-headers) (not all-headers))
216 (mime/decode-message-header)
218 (run-hooks 'tm-gnus/article-prepare-hook)
221 (add-hook 'gnus-Article-prepare-hook
222 (function tm-gnus/decode-encoded-word-if-you-need) t)
228 (defun tm-gnus/bbdb-setup ()
229 (if (memq 'bbdb/gnus-update-record gnus-Article-prepare-hook)
231 (remove-hook 'gnus-Article-prepare-hook 'bbdb/gnus-update-record)
232 (add-hook 'tm-gnus/article-prepare-hook 'bbdb/gnus-update-record)
235 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
252 ;;; tm-gnus3.el ends here