7829b51524d2b0fafc4bf8601ad7521361f7f21d
[elisp/tm.git] / gnus / gnus-mime.el
1 ;;; gnus-mime.el --- MIME extensions for Gnus
2
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Created: 1996/8/6
7 ;; Version: $Revision: 0.6 $
8 ;; Keywords: news, MIME, multimedia, multilingual, encoded-word
9
10 ;; This file is not part of GNU Emacs yet.
11
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
16
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program; see the file COPYING.  If not, write to
24 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Code:
28
29 (require 'tl-misc)
30
31
32 ;;; @ version
33 ;;;
34
35 (defconst gnus-mime-RCS-ID
36   "$Id: gnus-mime.el,v 0.6 1996/08/22 17:55:17 morioka Exp $")
37
38 (defconst gnus-mime-version
39   (get-version-string gnus-mime-RCS-ID))
40
41
42 ;;; @ variables
43 ;;;
44
45 (defvar gnus-show-mime t
46   "*If non-nil, do mime processing of articles.
47 The articles will simply be fed to the function given by
48 `gnus-show-mime-method'.")
49
50 (defvar gnus-show-mime-method 'gnus-article-preview-mime-message
51   "*Function to process a MIME message.
52 The function is called from the article buffer.")
53
54 (defvar gnus-decode-encoded-word-method 'gnus-article-decode-encoded-word
55   "*Function to decode a MIME encoded-words.
56 The function is called from the article buffer.")
57
58 (defvar gnus-parse-headers-hook
59   '(gnus-set-summary-default-charset gnus-decode-rfc1522)
60   "*A hook called before parsing the headers.")
61
62
63 ;;; @ load
64 ;;;
65
66 (require 'gnus)
67 (autoload 'gnus-decode-rfc1522               "gnus-art-mime")
68 (autoload 'gnus-article-preview-mime-message "gnus-art-mime")
69 (autoload 'gnus-article-decode-encoded-word  "gnus-art-mime")
70 (autoload 'gnus-set-summary-default-charset  "gnus-sum-mime")
71 (require 'gnus-charset)
72
73
74 ;;; @ for tm-view
75 ;;;
76
77 (defun gnus-content-header-filter ()
78   (goto-char (point-min))
79   (mime-preview/cut-header)
80   (decode-mime-charset-region (point-min)(point-max) default-mime-charset)
81   (mime/decode-message-header)
82   )
83
84 (set-alist 'mime-viewer/content-header-filter-alist
85            'gnus-original-article-mode
86            (function gnus-content-header-filter))
87
88
89 (set-alist 'mime-viewer/code-converter-alist
90            'gnus-original-article-mode
91            (function mime-charset/decode-buffer))
92
93
94 (defun mime-viewer/quitting-method-for-gnus ()
95   (if (not gnus-show-mime)
96       (mime-viewer/kill-buffer))
97   (delete-other-windows)
98   (gnus-article-show-summary)
99   (if (or (not gnus-show-mime)
100           (null gnus-have-all-headers))
101       (gnus-summary-select-article nil t)
102     ))
103
104 (set-alist 'mime-viewer/quitting-method-alist
105            'gnus-original-article-mode
106            (function mime-viewer/quitting-method-for-gnus))
107 (set-alist 'mime-viewer/show-summary-method
108            'gnus-original-article-mode
109            (function mime-viewer/quitting-method-for-gnus))
110
111
112 ;;; @ for tm-partial
113 ;;;
114
115 (defun gnus-mime-partial-preview-function ()
116   (gnus-summary-preview-mime-message (gnus-summary-article-number))
117   )
118
119 (call-after-loaded
120  'tm-partial
121  (function
122   (lambda ()
123     (set-atype 'mime/content-decoding-condition
124                '((type . "message/partial")
125                  (method . mime-article/grab-message/partials)
126                  (major-mode . gnus-original-article-mode)
127                  (summary-buffer-exp . gnus-summary-buffer)
128                  ))
129     (set-alist 'tm-partial/preview-article-method-alist
130                'gnus-original-article-mode
131                'gnus-mime-partial-preview-function)
132     )))
133
134
135 ;;; @ end
136 ;;;
137
138 (provide 'gnus-mime)
139
140 (or (featurep 'gnus-load)
141     (progn
142       ;; for Gnus 5.0 .. 5.3
143       (provide 'gnus-sum)
144       (provide 'gnus-art)
145       
146       (or (boundp 'gnus-original-article-buffer)
147           (progn
148             ;; for Gnus 5.0.* and 5.1
149             (defvar gnus-original-article-buffer " *Original Article*")
150             
151             (defun gnus-article-setup-original-article-buffer ()
152               (save-excursion
153                 (set-buffer (get-buffer-create gnus-original-article-buffer))
154                 (erase-buffer)
155                 (insert-buffer gnus-article-buffer)
156                 (setq major-mode 'gnus-original-article-mode)
157                 ))
158             
159             (add-hook 'gnus-article-prepare-hook
160                       'gnus-article-setup-original-article-buffer)
161             
162             (setq gnus-strict-mime nil)
163             ))
164       
165       (if running-xemacs
166           (progn
167             ;; modified by Steven L. Baur <steve@miranova.com>
168             ;;  1995/12/6 (c.f. [tm-en:209])
169             (defun mime-editor/attach-to-news-reply-menu ()
170               "Arrange to attach MIME editor's popup menu to VM's"
171               (if (boundp 'news-reply-menu)
172                   (progn
173                     (setq news-reply-menu
174                           (append news-reply-menu
175                                   '("---")
176                                   mime-editor/popup-menu-for-xemacs))
177                     (remove-hook 'news-setup-hook
178                                  'mime-editor/attach-to-news-reply-menu)
179                     )))
180             (call-after-loaded
181              'tm-edit
182              (function
183               (lambda ()
184                 (add-hook 'news-setup-hook
185                           'mime-editor/attach-to-news-reply-menu)
186                 )))
187             ))
188       ))
189
190 (run-hooks 'gnus-mime-load-hook)
191
192 ;;; gnus-mime.el ends here