1 ;;; mm-partial.el --- showing message/partial
2 ;; Copyright (C) 2000 Free Software Foundation, Inc.
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
5 ;; Keywords: message partial
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 2, or (at your
12 ;; option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
35 (defun mm-partial-find-parts (id &optional art)
36 (let ((headers (save-excursion
37 (set-buffer gnus-summary-buffer)
38 gnus-newsgroup-headers))
39 phandles handles header)
40 (while (setq header (pop headers))
41 (unless (eq (aref header 0) art)
42 (mm-with-unibyte-buffer
43 (gnus-request-article-this-buffer (aref header 0)
45 (when (search-forward id nil t)
46 (let ((nhandles (mm-dissect-buffer)) nid)
47 (setq handles gnus-article-mime-handles)
48 (if (consp (car nhandles))
49 (mm-destroy-parts nhandles)
50 (setq nid (cdr (assq 'id
51 (cdr (mm-handle-type nhandles)))))
52 (if (not (equal id nid))
53 (mm-destroy-parts nhandles)
54 (push nhandles phandles))))))))
58 (defun mm-inline-partial (handle)
59 (let ((id (cdr (assq 'id (cdr (mm-handle-type handle)))))
61 (b (point)) (n 1) total
63 gnus-displaying-mime handles buffer)
64 (unless (mm-handle-cache handle)
66 (error "Can not find message/partial id."))
69 (mm-partial-find-parts
72 (set-buffer gnus-summary-buffer)
73 (gnus-summary-article-number))))
75 (let ((anumber (string-to-number
77 (cdr (mm-handle-type a))))))
78 (bnumber (string-to-number
80 (cdr (mm-handle-type b)))))))
81 (< anumber bnumber)))))
82 (setq gnus-article-mime-handles
83 (append (if (listp (car gnus-article-mime-handles))
84 gnus-article-mime-handles
85 (list gnus-article-mime-handles))
88 (set-buffer (generate-new-buffer "*mm*"))
89 (while (setq phandle (pop phandles))
90 (setq nn (string-to-number
92 (cdr (mm-handle-type phandle))))))
93 (setq ntotal (string-to-number
95 (cdr (mm-handle-type phandle))))))
98 (unless (eq total ntotal)
99 (error "The numbers of total are different."))
100 (setq total ntotal)))
103 (error "Missing part %d" n))
104 (mm-insert-part phandle)
105 (goto-char (point-max))
108 (error "Don't known the total number of"))
110 (error "Missing part %d" n))
111 (kill-buffer (mm-handle-buffer handle))
112 (setcar handle (current-buffer))
113 (mm-handle-set-cache handle t)))
116 (narrow-to-region b b)
117 (mm-insert-part handle)
118 (let (gnus-article-mime-handles)
119 (run-hooks 'gnus-article-decode-hook)
120 (gnus-article-prepare-display)
121 (setq handles gnus-article-mime-handles))
123 ;; It is in article buffer.
124 (setq gnus-article-mime-handles
125 (nconc (if (listp (car gnus-article-mime-handles))
126 gnus-article-mime-handles
127 (list gnus-article-mime-handles))
128 (if (listp (car handles))
129 handles (list handles)))))
130 (mm-handle-set-undisplayer
133 (let (buffer-read-only)
135 ;; This is only valid on XEmacs.
136 (mapcar (lambda (prop)
138 (face-property 'default prop) (current-buffer)))
139 '(background background-pixmap foreground))
141 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))
143 ;; mm-partial.el ends here