2 ;;; tm-gnus3.el --- tm-gnus module for GNUS 3.*
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1993 .. 1996 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.9 $
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.9 1996/06/06 16:44:17 shuhei-k 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 (truncate-string subject (min (string-width subject)
110 (if (> (string-width subject) maxlen) "..." "")
111 (make-string (max 0 (- 17 (string-width subject))) ? )
113 (set-buffer-modified-p t))
115 (fset 'gnus-Article-set-mode-line 'tm-gnus/article-set-mode-line)
118 ;;; @ change MIME encoded-word decoding mode, decoding or non decoding.
121 (defun tm-gnus/set-decoding-mode (arg)
122 "Set MIME encoded-word processing.
123 With arg, turn MIME encoded-word processing on iff arg is positive."
124 (setq tm-gnus/decoding-mode arg)
125 (setq gnus-have-all-headers (not gnus-have-all-headers))
126 (gnus-summary-select-article (not gnus-have-all-headers) t)
129 (defun tm-gnus/toggle-decoding-mode ()
130 "Toggle MIME encoded-word processing.
131 With arg, turn MIME encoded-word processing on iff arg is positive."
133 (tm-gnus/set-decoding-mode (not tm-gnus/decoding-mode))
140 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
142 (defun tm-gnus/view-message (arg)
143 "MIME decode and play this message."
145 (let ((gnus-break-pages nil))
146 (gnus-Subject-select-article t t)
148 (pop-to-buffer gnus-Article-buffer t)
156 (set-alist 'mime-viewer/quitting-method-alist
158 (if (string-match (regexp-quote "3.14.4") gnus-version)
161 (mime-viewer/kill-buffer)
162 (delete-other-windows)
163 (gnus-Article-show-summary)
167 (mime-viewer/kill-buffer)
168 (delete-other-windows)
169 (gnus-Article-show-subjects)
178 ;; suggested by OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
179 ;; 1995/11/08 (c.f. [tm ML:1067])
180 (defun tm-gnus/insert-article (&optional message)
182 (let (;; for Emacs 18
183 (mail-yank-ignored-headers mime-editor/yank-ignored-field-regexp)
184 (news-make-reply-yank-header (function
185 (lambda (message-id from) "")
187 (news-yank-original-quoting-indicator "")
189 ;; select raw article buffer
192 (set-buffer gnus-article-buffer)
193 (if (eq major-mode 'mime/viewer-mode)
194 mime::preview/article-buffer
195 gnus-article-buffer)))
197 (news-reply-yank-original 0)
205 'mime-editor/message-inserter-alist
206 'news-reply-mode (function tm-gnus/insert-article))
208 (autoload 'tm-mail/insert-message "tm-mail")
209 (set-alist 'mime-editor/message-inserter-alist
210 'mail-mode (function tm-mail/insert-message))
221 (set-atype 'mime/content-decoding-condition
222 '((type . "message/partial")
223 (method . mime-article/grab-message/partials)
224 (major-mode . gnus-Article-mode)
225 (summary-buffer-exp . gnus-Subject-buffer)
228 (set-alist 'tm-partial/preview-article-method-alist
232 (tm-gnus/view-message (gnus-Subject-article-number))
237 ;;; @ Summary decoding
240 (add-hook 'gnus-Select-group-hook (function tm-gnus/decode-summary-subjects))
246 (define-key gnus-Subject-mode-map "\et" 'tm-gnus/toggle-decoding-mode)
247 (define-key gnus-Subject-mode-map "v" 'tm-gnus/view-message)
249 (defun tm-gnus/decode-encoded-word-if-you-need ()
250 (if (and tm-gnus/decoding-mode
251 (cond ((boundp 'all-headers) (not all-headers))
254 (mime/decode-message-header)
256 (run-hooks 'tm-gnus/article-prepare-hook)
259 (add-hook 'gnus-Article-prepare-hook
260 (function tm-gnus/decode-encoded-word-if-you-need) t)
273 (autoload 'tm-bbdb/update-record "tm-bbdb")
275 (defun tm-gnus/bbdb-setup ()
276 (if (memq 'bbdb/gnus-update-record gnus-Article-prepare-hook)
278 (remove-hook 'gnus-Article-prepare-hook 'bbdb/gnus-update-record)
279 (add-hook 'gnus-Article-prepare-hook 'tm-bbdb/update-record)
282 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
292 ;;; tm-gnus3.el ends here