tm 7.27.1.
[elisp/tm.git] / gnus / tm-gnus4.el
1 ;;;
2 ;;; tm-gnus4.el --- tm-gnus module for GNUS 4, 5.0.* and 5.1.*.
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;;; Created: 1993/11/20 (merged tm-gnus5.el)
10 ;;; Version: $Revision: 7.4 $
11 ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
12 ;;;
13 ;;; This file is part of tm (Tools for MIME).
14 ;;;
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.
19 ;;;
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.
24 ;;;
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.
28
29 (require 'tl-str)
30 (require 'tl-misc)
31
32
33 ;;; @ version
34 ;;;
35
36 (defconst tm-gnus/RCS-ID
37   "$Id: tm-gnus4.el,v 7.4 1995/11/21 03:02:27 morioka Exp $")
38
39 (defconst tm-gnus/version
40   (concat (get-version-string tm-gnus/RCS-ID) " for 4 .. 5.1"))
41
42
43 ;;; @ variable
44 ;;;
45
46 (defvar tm-gnus/automatic-mime-preview t
47   "*If non-nil, show MIME processed article.
48 This variable is set to `gnus-show-mime'.")
49
50
51 ;;; @ for tm-view
52 ;;;
53
54 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
55
56 (defun tm-gnus/view-message (arg)
57   "MIME decode and play this message."
58   (interactive "P")
59   (let ((gnus-break-pages nil))
60     (gnus-summary-select-article t t)
61     )
62   (pop-to-buffer gnus-article-buffer t)
63   (mime/viewer-mode)
64   )
65
66 (defun tm-gnus/summary-scroll-down ()
67   "Scroll down one line current article."
68   (interactive)
69   (gnus-summary-scroll-up -1)
70   )
71
72 (defun mime-viewer/quitting-method-for-gnus4 ()
73   (mime-viewer/kill-buffer)
74   (delete-other-windows)
75   (gnus-article-show-summary)
76   (if (null gnus-have-all-headers)
77       (gnus-summary-select-article nil t)
78     ))
79
80 (call-after-loaded
81  'tm-view
82  (function
83   (lambda ()
84     (set-alist 'mime-viewer/quitting-method-alist
85                'gnus-article-mode
86                (function mime-viewer/quitting-method-for-gnus4))
87     )))
88
89
90 ;;; @ for tm-partial
91 ;;;
92
93 (call-after-loaded
94  'tm-partial
95  (function
96   (lambda ()
97     (set-atype 'mime/content-decoding-condition
98                '((type . "message/partial")
99                  (method . mime-article/grab-message/partials)
100                  (major-mode . gnus-article-mode)
101                  (summary-buffer-exp . gnus-summary-buffer)
102                  ))
103     
104     (set-alist 'tm-partial/preview-article-method-alist
105                'gnus-article-mode
106                (function
107                 (lambda ()
108                   (tm-gnus/view-message (gnus-summary-article-number))
109                   )))
110     )))
111
112
113 ;;; @ set up
114 ;;;
115
116 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
117 (define-key gnus-summary-mode-map
118   "\e\r" (function tm-gnus/summary-scroll-down))
119
120 (defun tm-gnus/decode-encoded-word-if-you-need ()
121   (if (not gnus-have-all-headers)
122       (progn
123         (mime/decode-message-header)
124         (run-hooks 'tm-gnus/article-prepare-hook)
125         )))
126
127 (defvar tm-gnus/original-article-buffer " *Original Article*")
128
129 (defun tm-gnus/preview-article-if-you-need ()
130   (if (not gnus-have-all-headers)
131       (let ((str (buffer-string))
132             (obuf (get-buffer tm-gnus/original-article-buffer))
133             (pbuf (current-buffer))
134             )
135         (if obuf
136             (progn
137               (set-buffer obuf)
138               (setq buffer-read-only nil)
139               (erase-buffer)
140               )
141           (setq obuf (get-buffer-create tm-gnus/original-article-buffer))
142           (set-buffer obuf)
143           )
144         (insert str)
145         (gnus-article-mode)
146         (set-buffer pbuf)
147         (make-local-variable 'tm:mother-button-dispatcher)
148         (setq tm:mother-button-dispatcher
149               (function gnus-article-push-button))
150         (mime/viewer-mode
151          nil nil nil tm-gnus/original-article-buffer gnus-article-buffer)
152         (setq buffer-read-only nil)
153         (gnus-article-show-summary)
154         (run-hooks 'tm-gnus/article-prepare-hook)
155         )))
156
157 (setq gnus-show-mime-method
158       (if tm-gnus/automatic-mime-preview
159           (function tm-gnus/preview-article-if-you-need)
160         (function tm-gnus/decode-encoded-word-if-you-need)
161         ))
162
163 (setq gnus-show-mime t)
164
165
166 ;;; @ for BBDB
167 ;;;
168
169 (defun tm-gnus/bbdb-setup ()
170   (if (memq 'bbdb/gnus-update-record gnus-article-prepare-hook)
171       (progn
172         (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record)
173         (add-hook 'tm-gnus/article-prepare-hook 'bbdb/gnus-update-record)
174         )))
175
176 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
177
178 (tm-gnus/bbdb-setup)
179
180
181 ;;; @ end
182 ;;;
183
184 (provide 'tm-gnus4)