This commit was generated by cvs2svn to compensate for changes in r542,
[elisp/tm.git] / gnus / gnus-art-mime.el
1 ;;; gnus-art-mime.el --- MIME extension for article mode of Gnus
2
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Created: 1996/8/6
7 ;; Version:
8 ;;      $Id: gnus-art-mime.el,v 0.5 1996/08/17 02:45:14 morioka Exp $
9 ;; Keywords: news, MIME, multimedia, multilingual, encoded-word
10
11 ;; This file is not part of GNU Emacs yet.
12
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program; see the file COPYING.  If not, write to
25 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Code:
29
30 (require 'emu)
31 (require 'gnus-art)
32
33 (autoload 'mime-eword/decode-region "tm-ew-d"
34   "Decode MIME encoded-words in region." t)
35 (autoload 'mime/decode-message-header "tm-ew-d"
36   "Decode MIME encoded-words in message header." t)
37 (autoload 'mime/viewer-mode "tm-view"
38   "Major mode for viewing MIME message." t)
39
40
41 (defun gnus-decode-rfc1522 ()
42   (goto-char (point-min))
43   (if (re-search-forward "^[0-9]+\t" nil t)
44       (progn
45         (goto-char (point-min))
46         ;; for XOVER
47         (while (re-search-forward "^[0-9]+\t\\([^\t]+\\)\t" nil t)
48           (mime-eword/decode-region (match-beginning 1) (match-end 1)
49                                     'unfolding 'must-unfold)
50           (if (re-search-forward "[^\t]+" nil t)
51               (mime-eword/decode-region (match-beginning 0)(match-end 0)
52                                         'unfolding 'must-unfold)
53             )
54           ))
55     (mime-eword/decode-region (point-min)(point-max) t)
56     ))
57
58
59 ;;; @ article filter
60 ;;;
61
62 (defun gnus-article-preview-mime-message ()
63   (make-local-variable 'tm:mother-button-dispatcher)
64   (setq tm:mother-button-dispatcher
65         (function gnus-article-push-button))
66   (let ((mime-viewer/ignored-field-regexp "^:$")
67         (default-mime-charset
68           (save-excursion
69             (set-buffer gnus-summary-buffer)
70             default-mime-charset))
71         )
72     (save-window-excursion
73       (mime/viewer-mode nil nil nil gnus-original-article-buffer
74                         gnus-article-buffer
75                         gnus-article-mode-map)
76       ))
77   (run-hooks 'tm-gnus/article-prepare-hook)
78   )
79
80 (defun gnus-article-decode-encoded-word ()
81   (decode-mime-charset-region (point-min)(point-max)
82                               (save-excursion
83                                 (set-buffer gnus-summary-buffer)
84                                 default-mime-charset))
85   (mime/decode-message-header)
86   (run-hooks 'tm-gnus/article-prepare-hook)
87   )
88
89
90 ;;; @ for BBDB
91 ;;;
92
93 (call-after-loaded
94  'bbdb
95  (function
96   (lambda ()
97     (require 'tm-bbdb)
98     )))
99
100 (autoload 'tm-bbdb/update-record "tm-bbdb")
101
102 (defun tm-gnus/bbdb-setup ()
103   (if (memq 'bbdb/gnus-update-record gnus-article-prepare-hook)
104       (progn
105         (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record)
106         (add-hook 'gnus-article-display-hook 'tm-bbdb/update-record)
107         )))
108
109 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
110
111 (tm-gnus/bbdb-setup)
112
113
114 ;;; @ end
115 ;;;
116
117 (provide 'gnus-art-mime)
118
119 ;;; gnus-art-mime.el ends here