tm 7.41.2.
[elisp/tm.git] / gnus / tm-gnus.el
1 ;;;
2 ;;; tm-gnus.el --- MIME extension for GNUS
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1993 .. 1996 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; modified by KOBAYASHI Shuhei <shuhei@cmpt01.phys.tohoku.ac.jp>
9 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
10 ;;; Created: 1993/11/20 (obsolete mol's gnus-mime.el)
11 ;;; Version:
12 ;;;     $Id: tm-gnus.el,v 7.16 1996/01/25 02:41:11 morioka Exp $
13 ;;; Keywords: news, MIME, multimedia, encoded-word, multilingual
14 ;;;
15 ;;; This file is part of tm (Tools for MIME).
16 ;;;
17 ;;; This program is free software; you can redistribute it and/or
18 ;;; modify it under the terms of the GNU General Public License as
19 ;;; published by the Free Software Foundation; either version 2, or
20 ;;; (at your option) any later version.
21 ;;;
22 ;;; This program is distributed in the hope that it will be useful,
23 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25 ;;; General Public License for more details.
26 ;;;
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with This program.  If not, write to the Free Software
29 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
30 ;;;
31 ;;; Code:
32
33 (require 'gnus)
34
35
36 ;;; @ variables
37 ;;;
38
39 (defvar tm-gnus/startup-hook nil)
40
41
42 ;;; @ set up
43 ;;;
44
45 (cond ((boundp 'gnus-original-article-buffer)
46        ;; for September Gnus and Gnus 5.2 ..
47        (require 'tm-sgnus)
48        )
49       ((or (string-match
50             "^\\((ding) Gnus\\|Gnus v5\\|September Gnus\\)" gnus-version)
51            (fboundp 'mail-header-from))
52        ;; for Gnus 5.0 .. 5.1.*
53        (require 'tm-gd5)
54        (require 'tm-gnus4)
55
56        (set-alist 'mime-viewer/content-header-filter-alist
57                   'gnus-article-mode
58                   (function tm-gnus/content-header-filter))
59        (set-alist 'mime-viewer/code-converter-alist
60                   'gnus-article-mode
61                   (function tm-gnus/code-convert-region-to-emacs))
62
63        (defvar tm-gnus/code-converted nil)
64        (defun tm-gnus/maybe-code-convert ()
65          (or tm-gnus/automatic-mime-preview
66              (let ((mid (rfc822/get-field-body "Message-Id")))
67                (or
68                 (and tm-gnus/code-converted
69                      (string-equal tm-gnus/code-converted mid))
70                 (progn
71                   (tm-gnus/code-convert-region-to-emacs
72                    (point-min)(point-max)
73                    mime/default-coding-system)
74                   (tm-gnus/decode-encoded-word-if-you-need)
75                   (setq tm-gnus/code-converted mid)
76                   )))))
77        (add-hook 'gnus-article-display-hook 'tm-gnus/maybe-code-convert)
78        )
79       ((fboundp 'gnus-article-prepare)
80        ;; for GNUS 3.15 .. 4.*
81        (require 'tm-gd3)
82        (require 'tm-gnus4)
83        (add-hook 'gnus-select-group-hook 'tm-gnus/decode-summary-subjects)
84        (fset 'gnus-article-set-mode-line
85              (function tm-gnus/article-set-mode-line))
86        
87        (or (fboundp 'tm:gnus-article-delete-headers)
88            (fset 'tm:gnus-article-delete-headers
89                  (symbol-function 'gnus-article-delete-headers))
90            )
91        (defun gnus-article-delete-headers ()
92          (or tm-gnus/automatic-mime-preview
93              (tm:gnus-article-delete-headers)
94              ))
95        
96        (require 'gnuspost)
97        (or (fboundp 'tm-gnus/original-news-reply)
98            (fset 'tm-gnus/original-news-reply
99                  (symbol-function 'gnus-news-reply))
100            )
101        (defun gnus-news-reply (&optional yank)
102          (if (eq major-mode 'mime/viewer-mode)
103              (let ((major-mode 'gnus-article-mode))
104                (tm-gnus/original-news-reply yank)
105                )
106            (tm-gnus/original-news-reply yank)
107            ))
108        )
109       ((string-match "^GNUS 3" gnus-version)
110        ;; for GNUS 3.14.*
111        (require 'tm-gnus3)
112        (defvar gnus-article-buffer gnus-Article-buffer)
113        ))
114
115
116 ;;; @ for tm-edit
117 ;;;
118
119 ;; suggested by OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
120 ;;      1995/11/08 (c.f. [tm ML:1067])
121 (defun tm-gnus/insert-article (&optional message)
122   (interactive)
123   (let (;; for Emacs 19
124         (mail-citation-hook '(mime-editor/inserted-message-filter))
125         news-reply-header-hook
126         mail-yank-hooks
127         
128         ;; for Emacs 18
129         (mail-yank-ignored-headers mime-editor/yank-ignored-field-regexp)
130         (news-make-reply-yank-header (function
131                                       (lambda (message-id from) "")
132                                       ))
133         (news-yank-original-quoting-indicator "")
134         
135         ;; select raw article buffer
136         (mail-reply-buffer
137          (save-excursion
138            (set-buffer gnus-article-buffer)
139            (if (eq major-mode 'mime/viewer-mode)
140                mime::preview/article-buffer
141              gnus-article-buffer)))
142         )
143     (news-reply-yank-original 0)
144     ))
145
146 ;;; modified by Steven L. Baur <steve@miranova.com>
147 ;;;     1995/12/6 (c.f. [tm-en:209])
148 (defun mime-editor/attach-to-news-reply-menu ()
149   "Arrange to attach MIME editor's popup menu to VM's"
150   (if (boundp 'news-reply-menu)
151       (progn
152         (setq news-reply-menu (append news-reply-menu
153                                       '("---")
154                                       mime-editor/popup-menu-for-xemacs))
155         (remove-hook 'news-setup-hook
156                      'mime-editor/attach-to-news-reply-menu)
157         )))
158
159 (call-after-loaded
160  'tm-edit
161  (function
162   (lambda ()
163     (set-alist
164      'mime-editor/message-inserter-alist
165      'news-reply-mode (function tm-gnus/insert-article))
166     
167     (autoload 'tm-mail/insert-message "tm-mail")
168     (set-alist 'mime-editor/message-inserter-alist
169                'mail-mode (function tm-mail/insert-message))
170     (if (string-match "XEmacs\\|Lucid" emacs-version)
171         (add-hook 'news-setup-hook 'mime-editor/attach-to-news-reply-menu)
172       )
173     )))
174
175
176 ;;; @ end
177 ;;;
178
179 (provide 'tm-gnus)
180
181 (run-hooks 'tm-gnus-load-hook)
182
183 ;;; tm-gnus.el ends here