5d22a5d9ccaa344344245ca3545b165ff4f53b39
[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.4 1996/08/12 09:00: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.  If not, write to the Free Software
25 ;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 ;;; Code:
28
29 (require 'tm-view)
30 (require 'gnus-art)
31
32 (defun gnus-decode-rfc1522 ()
33   (goto-char (point-min))
34   (if (re-search-forward "^[0-9]+\t" nil t)
35       (progn
36         (goto-char (point-min))
37         ;; for XOVER
38         (while (re-search-forward "^[0-9]+\t\\([^\t]+\\)\t" nil t)
39           (mime-eword/decode-region (match-beginning 1) (match-end 1)
40                                     'unfolding 'must-unfold)
41           (if (re-search-forward "[^\t]+" nil t)
42               (mime-eword/decode-region (match-beginning 0)(match-end 0)
43                                         'unfolding 'must-unfold)
44             )
45           ))
46     (mime-eword/decode-region (point-min)(point-max) t)
47     ))
48
49
50 ;;; @ article filter
51 ;;;
52
53 (defun gnus-article-preview-mime-message ()
54   (make-local-variable 'tm:mother-button-dispatcher)
55   (setq tm:mother-button-dispatcher
56         (function gnus-article-push-button))
57   (let ((mime-viewer/ignored-field-regexp "^:$")
58         (default-mime-charset
59           (save-excursion
60             (set-buffer gnus-summary-buffer)
61             default-mime-charset))
62         )
63     (save-window-excursion
64       (mime/viewer-mode nil nil nil gnus-original-article-buffer
65                         gnus-article-buffer
66                         gnus-article-mode-map)
67       ))
68   (run-hooks 'tm-gnus/article-prepare-hook)
69   )
70
71 (defun gnus-article-decode-encoded-word ()
72   (decode-mime-charset-region (point-min)(point-max)
73                               (save-excursion
74                                 (set-buffer gnus-summary-buffer)
75                                 default-mime-charset))
76   (mime/decode-message-header)
77   (run-hooks 'tm-gnus/article-prepare-hook)
78   )
79
80
81 ;;; @ for BBDB
82 ;;;
83
84 (call-after-loaded
85  'bbdb
86  (function
87   (lambda ()
88     (require 'tm-bbdb)
89     )))
90
91 (autoload 'tm-bbdb/update-record "tm-bbdb")
92
93 (defun tm-gnus/bbdb-setup ()
94   (if (memq 'bbdb/gnus-update-record gnus-article-prepare-hook)
95       (progn
96         (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record)
97         (add-hook 'gnus-article-display-hook 'tm-bbdb/update-record)
98         )))
99
100 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
101
102 (tm-gnus/bbdb-setup)
103
104
105 ;;; @ end
106 ;;;
107
108 (provide 'gnus-art-mime)
109
110 ;;; gnus-art-mime.el ends here