4
|
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 1.1.1.1 1996/12/18 03:55:31 steve 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 GNU Emacs; see the file COPYING. If not, write to the
|
|
25 ;; 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-mime)
|
|
32 (require 'gnus-art)
|
|
33 (require 'tm-view)
|
|
34
|
|
35 (autoload 'mime-eword/decode-region "tm-ew-d"
|
|
36 "Decode MIME encoded-words in region." t)
|
|
37 (autoload 'mime/decode-message-header "tm-ew-d"
|
|
38 "Decode MIME encoded-words in message header." t)
|
|
39
|
|
40
|
|
41 ;;; @ encoded-word
|
|
42 ;;;
|
|
43
|
|
44 ;;; `gnus-decode-rfc1522' of Gnus works only Q-encoded iso-8859-1
|
|
45 ;;; encoded-words. In addition, it does not apply decoding rule of
|
|
46 ;;; RFC 1522 and it does not do unfolding. So gnus-mime defines own
|
|
47 ;;; function using tm-ew-d.
|
|
48
|
|
49 (defun gnus-decode-rfc1522 ()
|
|
50 (goto-char (point-min))
|
|
51 (if (re-search-forward "^[0-9]+\t" nil t)
|
|
52 (progn
|
|
53 (goto-char (point-min))
|
|
54 ;; for XOVER
|
|
55 (while (re-search-forward "^[0-9]+\t\\([^\t]+\\)\t" nil t)
|
|
56 (mime-eword/decode-region (match-beginning 1) (match-end 1)
|
|
57 'unfolding 'must-unfold)
|
|
58 (if (re-search-forward "[^\t]+" nil t)
|
|
59 (mime-eword/decode-region (match-beginning 0)(match-end 0)
|
|
60 'unfolding 'must-unfold)
|
|
61 )
|
|
62 ))
|
|
63 (mime-eword/decode-region (point-min)(point-max) t)
|
|
64 ))
|
|
65
|
|
66
|
|
67 ;;; @ article filter
|
|
68 ;;;
|
|
69
|
|
70 (defun gnus-article-preview-mime-message ()
|
|
71 (make-local-variable 'tm:mother-button-dispatcher)
|
|
72 (setq tm:mother-button-dispatcher
|
|
73 (function gnus-article-push-button))
|
|
74 (let ((mime-viewer/ignored-field-regexp "^:$")
|
|
75 (default-mime-charset
|
|
76 (save-excursion
|
|
77 (set-buffer gnus-summary-buffer)
|
|
78 default-mime-charset))
|
|
79 )
|
|
80 (save-window-excursion
|
|
81 (mime/viewer-mode nil nil nil gnus-original-article-buffer
|
|
82 gnus-article-buffer
|
|
83 gnus-article-mode-map)
|
|
84 ))
|
|
85 (run-hooks 'tm-gnus/article-prepare-hook)
|
|
86 )
|
|
87
|
|
88 (defun gnus-article-decode-encoded-word ()
|
|
89 (decode-mime-charset-region (point-min)(point-max)
|
|
90 (save-excursion
|
|
91 (set-buffer gnus-summary-buffer)
|
|
92 default-mime-charset))
|
|
93 (mime/decode-message-header)
|
|
94 (run-hooks 'tm-gnus/article-prepare-hook)
|
|
95 )
|
|
96
|
|
97
|
|
98 ;;; @ for tm-view
|
|
99 ;;;
|
|
100
|
|
101 (defun gnus-content-header-filter ()
|
|
102 (goto-char (point-min))
|
|
103 (mime-preview/cut-header)
|
|
104 (decode-mime-charset-region (point-min)(point-max) default-mime-charset)
|
|
105 (mime/decode-message-header)
|
|
106 )
|
|
107
|
|
108 (defun mime-viewer/quitting-method-for-gnus ()
|
|
109 (if (not gnus-show-mime)
|
|
110 (mime-viewer/kill-buffer))
|
|
111 (delete-other-windows)
|
|
112 (gnus-article-show-summary)
|
|
113 (if (or (not gnus-show-mime)
|
|
114 (null gnus-have-all-headers))
|
|
115 (gnus-summary-select-article nil t)
|
|
116 ))
|
|
117
|
|
118 (call-after-loaded
|
|
119 'tm-view
|
|
120 (lambda ()
|
|
121 (set-alist 'mime-viewer/content-header-filter-alist
|
|
122 'gnus-original-article-mode
|
|
123 (function gnus-content-header-filter))
|
|
124
|
|
125 (set-alist 'mime-viewer/code-converter-alist
|
|
126 'gnus-original-article-mode
|
|
127 (function mime-charset/decode-buffer))
|
|
128
|
|
129 (set-alist 'mime-viewer/quitting-method-alist
|
|
130 'gnus-original-article-mode
|
|
131 (function mime-viewer/quitting-method-for-gnus))
|
|
132
|
|
133 (set-alist 'mime-viewer/show-summary-method
|
|
134 'gnus-original-article-mode
|
|
135 (function mime-viewer/quitting-method-for-gnus))
|
|
136 ))
|
|
137
|
|
138
|
|
139 ;;; @ for BBDB
|
|
140 ;;;
|
|
141
|
|
142 (call-after-loaded
|
|
143 'bbdb
|
|
144 (function
|
|
145 (lambda ()
|
|
146 (require 'tm-bbdb)
|
|
147 )))
|
|
148
|
|
149 (autoload 'tm-bbdb/update-record "tm-bbdb")
|
|
150
|
|
151 (defun tm-gnus/bbdb-setup ()
|
|
152 (if (and (boundp 'gnus-article-prepare-hook)
|
|
153 (memq 'bbdb/gnus-update-record gnus-article-prepare-hook)
|
|
154 )
|
|
155 (progn
|
|
156 (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record)
|
|
157 (add-hook 'gnus-article-display-hook 'tm-bbdb/update-record)
|
|
158 )))
|
|
159
|
|
160 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
|
|
161
|
|
162 (tm-gnus/bbdb-setup)
|
|
163
|
|
164
|
|
165 ;;; @ end
|
|
166 ;;;
|
|
167
|
|
168 (provide 'gnus-art-mime)
|
|
169
|
|
170 ;;; gnus-art-mime.el ends here
|