tm 7.46.1.
[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.20 1996/03/04 08:18:09 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-gnus4)
54        (cond ((not (boundp 'nnheader-encoded-words-decoding))
55               (require 'tm-ew-d)
56               (defun tm-gnus/decode-summary-from-and-subjects ()
57                 (mapcar (lambda (header)
58                           (let ((from (mail-header-from header))
59                                 (subj (mail-header-subject header))
60                                 )
61                             (mail-header-set-from
62                              header
63                              (if from
64                                  (mime-eword/decode-string from)
65                                ""))
66                             (mail-header-set-subject
67                              header
68                              (if subj
69                                  (mime-eword/decode-string subj)
70                                ""))
71                             ))
72                         gnus-newsgroup-headers))
73               (add-hook 'gnus-select-group-hook
74                         (function tm-gnus/decode-summary-from-and-subjects))
75               ))
76        )
77       ((fboundp 'gnus-article-prepare)
78        ;; for GNUS 3.15 .. 4.*
79        (require 'tm-gd3)
80        (require 'tm-gnus4)
81        (add-hook 'gnus-select-group-hook 'tm-gnus/decode-summary-subjects)
82        (fset 'gnus-article-set-mode-line
83              (function tm-gnus/article-set-mode-line))
84        
85        (or (fboundp 'tm:gnus-article-delete-headers)
86            (fset 'tm:gnus-article-delete-headers
87                  (symbol-function 'gnus-article-delete-headers))
88            )
89        (defun gnus-article-delete-headers ()
90          (or tm-gnus/automatic-mime-preview
91              (tm:gnus-article-delete-headers)
92              ))
93        
94        (require 'gnuspost)
95        (or (fboundp 'tm-gnus/original-news-reply)
96            (fset 'tm-gnus/original-news-reply
97                  (symbol-function 'gnus-news-reply))
98            )
99        (defun gnus-news-reply (&optional yank)
100          (if (eq major-mode 'mime/viewer-mode)
101              (let ((major-mode 'gnus-article-mode))
102                (tm-gnus/original-news-reply yank)
103                )
104            (tm-gnus/original-news-reply yank)
105            ))
106        )
107       ((string-match "^GNUS 3" gnus-version)
108        ;; for GNUS 3.14.*
109        (require 'tm-gnus3)
110        (defvar gnus-article-buffer gnus-Article-buffer)
111        ))
112
113
114 ;;; @ for tm-edit
115 ;;;
116
117 ;; suggested by OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
118 ;;      1995/11/08 (c.f. [tm ML:1067])
119 (defun tm-gnus/insert-article (&optional message)
120   (interactive)
121   (let (;; for Emacs 19
122         (mail-citation-hook '(mime-editor/inserted-message-filter))
123         news-reply-header-hook
124         mail-yank-hooks
125         
126         ;; for Emacs 18
127         (mail-yank-ignored-headers mime-editor/yank-ignored-field-regexp)
128         (news-make-reply-yank-header (function
129                                       (lambda (message-id from) "")
130                                       ))
131         (news-yank-original-quoting-indicator "")
132         
133         ;; select raw article buffer
134         (mail-reply-buffer
135          (save-excursion
136            (set-buffer gnus-article-buffer)
137            (if (eq major-mode 'mime/viewer-mode)
138                mime::preview/article-buffer
139              gnus-article-buffer)))
140         )
141     (news-reply-yank-original 0)
142     ))
143
144 ;;; modified by Steven L. Baur <steve@miranova.com>
145 ;;;     1995/12/6 (c.f. [tm-en:209])
146 (defun mime-editor/attach-to-news-reply-menu ()
147   "Arrange to attach MIME editor's popup menu to VM's"
148   (if (boundp 'news-reply-menu)
149       (progn
150         (setq news-reply-menu (append news-reply-menu
151                                       '("---")
152                                       mime-editor/popup-menu-for-xemacs))
153         (remove-hook 'news-setup-hook
154                      'mime-editor/attach-to-news-reply-menu)
155         )))
156
157 (call-after-loaded
158  'tm-edit
159  (function
160   (lambda ()
161     (set-alist
162      'mime-editor/message-inserter-alist
163      'news-reply-mode (function tm-gnus/insert-article))
164     
165     (autoload 'tm-mail/insert-message "tm-mail")
166     (set-alist 'mime-editor/message-inserter-alist
167                'mail-mode (function tm-mail/insert-message))
168     (if (string-match "XEmacs\\|Lucid" emacs-version)
169         (add-hook 'news-setup-hook 'mime-editor/attach-to-news-reply-menu)
170       )
171     )))
172
173
174 ;;; @ end
175 ;;;
176
177 (provide 'tm-gnus)
178
179 (run-hooks 'tm-gnus-load-hook)
180
181 ;;; tm-gnus.el ends here