tm 7.33.
[elisp/tm.git] / gnus / tm-sgnus.el
1 ;;;
2 ;;; tm-sgnus.el --- tm-gnus module for September GNUS
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: 1995/09/24
10 ;;; Version: $Revision: 7.22 $
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-list)
31 (require 'tl-misc)
32 (require 'tm-view)
33 (require 'gnus)
34 (require 'tm-gd5)
35
36
37 ;;; @ version
38 ;;;
39
40 (defconst tm-gnus/RCS-ID
41   "$Id: tm-sgnus.el,v 7.22 1995/12/11 12:50:58 morioka Exp $")
42
43 (defconst tm-gnus/version
44   (concat (get-version-string tm-gnus/RCS-ID) " for September"))
45
46
47 ;;; @ variables
48 ;;;
49
50 (defvar tm-gnus/automatic-mime-preview t
51   "*If non-nil, show MIME processed article.
52 This variable is set to `gnus-show-mime'.")
53
54 (setq gnus-show-mime tm-gnus/automatic-mime-preview)
55
56
57 ;;; @ command functions
58 ;;;
59
60 (defun tm-gnus/view-message (arg)
61   "MIME decode and play this message."
62   (interactive "P")
63   (let ((gnus-break-pages nil))
64     (gnus-summary-select-article t t)
65     )
66   (pop-to-buffer gnus-original-article-buffer t)
67   (let (buffer-read-only)
68     (if (text-property-any (point-min) (point-max) 'invisible t)
69         (remove-text-properties (point-min) (point-max)
70                                 gnus-hidden-properties)
71       ))
72   (mime/viewer-mode nil nil nil gnus-original-article-buffer
73                     gnus-article-buffer)
74   )
75
76 (defun tm-gnus/summary-scroll-down ()
77   "Scroll down one line current article."
78   (interactive)
79   (gnus-summary-scroll-up -1)
80   )
81
82 (defun tm-gnus/summary-toggle-header (&optional arg)
83   (interactive "P")
84   (if tm-gnus/automatic-mime-preview
85       (let ((mime-viewer/ignored-field-regexp
86              (if (save-excursion
87                    (set-buffer gnus-article-buffer)
88                    (some-element
89                     (lambda (field)
90                       (rfc822/get-field-body field)
91                       )
92                     mime-viewer/ignored-field-list))
93                  mime-viewer/ignored-field-regexp
94                "^:$")))
95         (gnus-summary-select-article t t)
96         )
97     (gnus-summary-toggle-header arg)
98     ))
99
100 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
101 (define-key gnus-summary-mode-map
102   "\e\r" (function tm-gnus/summary-scroll-down))
103 (define-key gnus-summary-mode-map
104   "t" (function tm-gnus/summary-toggle-header))
105
106
107 ;;; @ for tm-view
108 ;;;
109
110 (defun mime-viewer/quitting-method-for-sgnus ()
111   (if (not gnus-show-mime)
112       (mime-viewer/kill-buffer))
113   (delete-other-windows)
114   (gnus-article-show-summary)
115   (if (or (not gnus-show-mime)
116           (null gnus-have-all-headers))
117       (gnus-summary-select-article nil t)
118     ))
119
120 (call-after-loaded
121  'tm-view
122  (lambda ()
123    (set-alist 'mime-viewer/quitting-method-alist
124               'gnus-original-article-mode
125               (function mime-viewer/quitting-method-for-sgnus))
126    ))
127
128
129 ;;; @ for tm-partial
130 ;;;
131
132 (defun tm-gnus/partial-preview-function ()
133   (tm-gnus/view-message (gnus-summary-article-number))
134   )
135
136 (call-after-loaded
137  'tm-partial
138  (lambda ()
139    (set-atype 'mime/content-decoding-condition
140               '((type . "message/partial")
141                 (method . mime-article/grab-message/partials)
142                 (major-mode . gnus-original-article-mode)
143                 (summary-buffer-exp . gnus-summary-buffer)
144                 ))
145    (set-alist 'tm-partial/preview-article-method-alist
146               'gnus-original-article-mode
147               'tm-gnus/partial-preview-function)
148    ))
149
150
151 ;;; @ article filter
152 ;;;
153
154 (defun tm-gnus/article-reset-variable ()
155   (setq tm-gnus/automatic-mime-preview nil)
156   )
157
158 (add-hook 'gnus-article-prepare-hook 'tm-gnus/article-reset-variable)
159
160 (defun tm-gnus/preview-article ()
161   (make-local-variable 'tm:mother-button-dispatcher)
162   (setq tm:mother-button-dispatcher
163         (function gnus-article-push-button))
164   (mime/viewer-mode nil nil nil gnus-original-article-buffer
165                     gnus-article-buffer)
166   (setq tm-gnus/automatic-mime-preview t)
167   (run-hooks 'tm-gnus/article-prepare-hook)
168   )
169
170 (setq gnus-show-mime-method (function tm-gnus/preview-article))
171
172 (defun tm-gnus/article-decode-encoded-word ()
173   (mime/decode-message-header)
174   (run-hooks 'tm-gnus/article-prepare-hook)
175   )
176
177 (setq gnus-decode-encoded-word-method
178       (function tm-gnus/article-decode-encoded-word))
179
180 (or (fboundp 'tm::gnus-article-hide-headers-if-wanted)
181     (fset 'tm::gnus-article-hide-headers-if-wanted
182           (symbol-function 'gnus-article-hide-headers-if-wanted))
183     )
184
185 (defun gnus-article-hide-headers-if-wanted ()
186   (or tm-gnus/automatic-mime-preview
187       (tm::gnus-article-hide-headers-if-wanted)
188       ))
189
190
191 ;;; @ for BBDB
192 ;;;
193
194 (defun tm-gnus/bbdb-setup ()
195   (if (memq 'bbdb/gnus-update-record gnus-article-prepare-hook)
196       (progn
197         (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record)
198         (add-hook 'tm-gnus/article-prepare-hook 'bbdb/gnus-update-record)
199         )))
200
201 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
202
203 (tm-gnus/bbdb-setup)
204
205
206 ;;; @ end
207 ;;;
208
209 (provide 'tm-sgnus)