2 ;;; tm-sgnus.el --- tm-gnus module for September Gnus
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; MURATA Masahiro <murata@sol.cs.ritsumei.ac.jp>
9 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
10 ;;; Created: 1995/09/24
11 ;;; Version: $Revision: 7.33 $
12 ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
14 ;;; This file is part of tm (Tools for MIME).
16 ;;; This program is free software; you can redistribute it and/or
17 ;;; modify it under the terms of the GNU General Public License as
18 ;;; published by the Free Software Foundation; either version 2, or
19 ;;; (at your option) any later version.
21 ;;; This program is distributed in the hope that it will be useful,
22 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 ;;; General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with This program. If not, write to the Free Software
28 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
39 (eval-when-compile (require 'cl))
45 (defconst tm-gnus/RCS-ID
46 "$Id: tm-sgnus.el,v 7.33 1996/01/09 12:06:29 morioka Exp $")
48 (defconst tm-gnus/version
49 (concat (get-version-string tm-gnus/RCS-ID) " for September"))
55 (defvar tm-gnus/automatic-mime-preview t
56 "*If non-nil, show MIME processed article.
57 This variable is set to `gnus-show-mime'.")
59 (setq gnus-show-mime tm-gnus/automatic-mime-preview)
62 ;;; @ command functions
65 (defun tm-gnus/view-message (arg)
66 "MIME decode and play this message."
68 (let ((gnus-break-pages nil))
69 (gnus-summary-select-article t t)
71 (pop-to-buffer gnus-original-article-buffer t)
72 (let (buffer-read-only)
73 (if (text-property-any (point-min) (point-max) 'invisible t)
74 (remove-text-properties (point-min) (point-max)
75 gnus-hidden-properties)
77 (mime/viewer-mode nil nil nil gnus-original-article-buffer
81 (defun tm-gnus/summary-scroll-down ()
82 "Scroll down one line current article."
84 (gnus-summary-scroll-up -1)
87 (defun tm-gnus/summary-toggle-header (&optional arg)
89 (if tm-gnus/automatic-mime-preview
92 (set-buffer gnus-article-buffer)
94 (goto-char (point-min)) (search-forward "\n\n")
97 (mime-viewer/redisplay t)
99 (gnus-summary-select-article hidden t)
101 (gnus-summary-toggle-header arg))
104 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
105 (define-key gnus-summary-mode-map
106 "\e\r" (function tm-gnus/summary-scroll-down))
107 (define-key gnus-summary-mode-map
108 "t" (function tm-gnus/summary-toggle-header))
114 (defun mime-viewer/quitting-method-for-sgnus ()
115 (if (not gnus-show-mime)
116 (mime-viewer/kill-buffer))
117 (delete-other-windows)
118 (gnus-article-show-summary)
119 (if (or (not gnus-show-mime)
120 (null gnus-have-all-headers))
121 (gnus-summary-select-article nil t)
127 (set-alist 'mime-viewer/quitting-method-alist
128 'gnus-original-article-mode
129 (function mime-viewer/quitting-method-for-sgnus))
130 (set-alist 'mime-viewer/show-summary-method
131 'gnus-original-article-mode
132 (function mime-viewer/quitting-method-for-sgnus))
139 (defun tm-gnus/partial-preview-function ()
140 (tm-gnus/view-message (gnus-summary-article-number))
146 (set-atype 'mime/content-decoding-condition
147 '((type . "message/partial")
148 (method . mime-article/grab-message/partials)
149 (major-mode . gnus-original-article-mode)
150 (summary-buffer-exp . gnus-summary-buffer)
152 (set-alist 'tm-partial/preview-article-method-alist
153 'gnus-original-article-mode
154 'tm-gnus/partial-preview-function)
161 (defun tm-gnus/article-reset-variable ()
162 (setq tm-gnus/automatic-mime-preview nil)
165 (add-hook 'gnus-article-prepare-hook 'tm-gnus/article-reset-variable)
167 (defun tm-gnus/preview-article ()
168 (make-local-variable 'tm:mother-button-dispatcher)
169 (setq tm:mother-button-dispatcher
170 (function gnus-article-push-button))
171 (let ((mime-viewer/ignored-field-regexp "^:$"))
172 (mime/viewer-mode nil nil nil gnus-original-article-buffer
175 (setq tm-gnus/automatic-mime-preview t)
176 (run-hooks 'tm-gnus/article-prepare-hook)
179 (setq gnus-show-mime-method (function tm-gnus/preview-article))
181 (defun tm-gnus/article-decode-encoded-word ()
182 (mime/decode-message-header)
183 (run-hooks 'tm-gnus/article-prepare-hook)
186 (setq gnus-decode-encoded-word-method
187 (function tm-gnus/article-decode-encoded-word))
193 (defun tm-gnus/forward-insert-buffer (buffer)
196 (if gnus-signature-before-forwarded-message
197 (goto-char (point-max))
198 (goto-char (point-min))
200 (concat "^" (regexp-quote mail-header-separator) "$"))
202 ;; Narrow to the area we are to insert.
203 (narrow-to-region (point) (point))
204 ;; Insert the separators and the forwarded buffer.
205 (mime-editor/insert-tag "message" "rfc822")
206 (insert-buffer-substring buffer)
207 ;; Delete any invisible text.
208 (goto-char (point-min))
210 (while (setq beg (next-single-property-change (point) 'invisible))
212 (delete-region beg (or (next-single-property-change
219 (cond ((string-match "XEmacs" emacs-version)
221 (fset 'gnus-forward-insert-buffer 'tm-gnus/forward-insert-buffer)
226 '(fset 'gnus-forward-insert-buffer 'tm-gnus/forward-insert-buffer)
234 (defun tm-gnus/bbdb-setup ()
235 (if (memq 'bbdb/gnus-update-record gnus-article-prepare-hook)
237 (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record)
238 (add-hook 'tm-gnus/article-prepare-hook 'bbdb/gnus-update-record)
241 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)