Mercurial > emacs
annotate lisp/gnus/mm-partial.el @ 89971:cce1c0ee76ee
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-36
Merge from emacs--cvs-trunk--0, emacs--gnus--5.10, gnus--rel--5.10
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Merge from emacs--gnus--5.10, gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-524
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-534
Update from CVS
* miles@gnu.org--gnu-2004/emacs--gnus--5.10--base-0
tag of miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-464
* miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-1
Import from CVS branch gnus-5_10-branch
* miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-2
Merge from lorentey@elte.hu--2004/emacs--multi-tty--0, emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-3
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-4
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-18
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-19
Remove autoconf-generated files from archive
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-20
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 09 Sep 2004 09:36:36 +0000 |
parents | 561b856c5b1f 55fd4f77387a |
children | f9a65d7ebd29 |
rev | line source |
---|---|
31717 | 1 ;;; mm-partial.el --- showing message/partial |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
2 ;; Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. |
31717 | 3 |
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu> | |
5 ;; Keywords: message partial | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
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. | |
13 | |
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. | |
18 | |
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. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
31717 | 29 |
30 (require 'gnus-sum) | |
31 (require 'mm-util) | |
32 (require 'mm-decode) | |
33 | |
34 (defun mm-partial-find-parts (id &optional art) | |
35 (let ((headers (save-excursion | |
36 (set-buffer gnus-summary-buffer) | |
37 gnus-newsgroup-headers)) | |
38 phandles header) | |
39 (while (setq header (pop headers)) | |
40 (unless (eq (aref header 0) art) | |
41 (mm-with-unibyte-buffer | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
42 (gnus-request-article-this-buffer (aref header 0) |
31717 | 43 gnus-newsgroup-name) |
44 (when (search-forward id nil t) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
45 (let ((nhandles (mm-dissect-buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
46 nil gnus-article-loose-mime)) nid) |
31717 | 47 (if (consp (car nhandles)) |
48 (mm-destroy-parts nhandles) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
49 (setq nid (cdr (assq 'id |
31717 | 50 (cdr (mm-handle-type nhandles))))) |
51 (if (not (equal id nid)) | |
52 (mm-destroy-parts nhandles) | |
53 (push nhandles phandles)))))))) | |
54 phandles)) | |
55 | |
56 ;;;###autoload | |
57 (defun mm-inline-partial (handle &optional no-display) | |
58 "Show the partial part of HANDLE. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
59 This function replaces the buffer of HANDLE with a buffer contains |
31717 | 60 the entire message. |
61 If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing." | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
62 (let ((id (cdr (assq 'id (cdr (mm-handle-type handle))))) |
31717 | 63 phandles |
64 (b (point)) (n 1) total | |
65 phandle nn ntotal | |
66 gnus-displaying-mime handles buffer) | |
67 (unless (mm-handle-cache handle) | |
68 (unless id | |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
33176
diff
changeset
|
69 (error "Can not find message/partial id")) |
31717 | 70 (setq phandles |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
71 (sort (cons handle |
31717 | 72 (mm-partial-find-parts |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
73 id |
31717 | 74 (save-excursion |
75 (set-buffer gnus-summary-buffer) | |
76 (gnus-summary-article-number)))) | |
77 #'(lambda (a b) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
78 (let ((anumber (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
79 (cdr (assq 'number |
31717 | 80 (cdr (mm-handle-type a)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
81 (bnumber (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
82 (cdr (assq 'number |
31717 | 83 (cdr (mm-handle-type b))))))) |
84 (< anumber bnumber))))) | |
85 (setq gnus-article-mime-handles | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
86 (mm-merge-handles gnus-article-mime-handles phandles)) |
31717 | 87 (save-excursion |
33176
aa40591dba57
(mm-inline-partial): Space-prefix temp buffer
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
88 (set-buffer (generate-new-buffer " *mm*")) |
31717 | 89 (while (setq phandle (pop phandles)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
90 (setq nn (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
91 (cdr (assq 'number |
31717 | 92 (cdr (mm-handle-type phandle)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
93 (setq ntotal (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
94 (cdr (assq 'total |
31717 | 95 (cdr (mm-handle-type phandle)))))) |
96 (if ntotal | |
97 (if total | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
98 (unless (eq total ntotal) |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
33176
diff
changeset
|
99 (error "The numbers of total are different")) |
31717 | 100 (setq total ntotal))) |
101 (unless (< nn n) | |
102 (unless (eq nn n) | |
103 (error "Missing part %d" n)) | |
104 (mm-insert-part phandle) | |
105 (goto-char (point-max)) | |
106 (when (not (eq 0 (skip-chars-backward "\r\n"))) | |
107 ;; remove tail blank spaces except one | |
108 (if (looking-at "\r?\n") | |
109 (goto-char (match-end 0))) | |
110 (delete-region (point) (point-max))) | |
111 (setq n (+ n 1)))) | |
112 (unless total | |
113 (error "Don't known the total number of")) | |
114 (if (<= n total) | |
115 (error "Missing part %d" n)) | |
116 (kill-buffer (mm-handle-buffer handle)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
117 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
118 (let ((point (if (search-forward "\n\n" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
119 (1- (point)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
120 (point-max)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
121 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
122 (unless (re-search-forward "^mime-version:" point t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
123 (insert "MIME-Version: 1.0\n"))) |
31717 | 124 (setcar handle (current-buffer)) |
125 (mm-handle-set-cache handle t))) | |
126 (unless no-display | |
127 (save-excursion | |
128 (save-restriction | |
129 (narrow-to-region b b) | |
130 (mm-insert-part handle) | |
131 (let (gnus-article-mime-handles) | |
132 (run-hooks 'gnus-article-decode-hook) | |
133 (gnus-article-prepare-display) | |
134 (setq handles gnus-article-mime-handles)) | |
135 (when handles | |
136 ;; It is in article buffer. | |
137 (setq gnus-article-mime-handles | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
138 (mm-merge-handles gnus-article-mime-handles handles))) |
31717 | 139 (mm-handle-set-undisplayer |
140 handle | |
141 `(lambda () | |
142 (let (buffer-read-only) | |
143 (condition-case nil | |
144 ;; This is only valid on XEmacs. | |
145 (mapcar (lambda (prop) | |
146 (remove-specifier | |
147 (face-property 'default prop) (current-buffer))) | |
148 '(background background-pixmap foreground)) | |
149 (error nil)) | |
150 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))) | |
151 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
152 (provide 'mm-partial) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
153 |
52401 | 154 ;;; arch-tag: 460e7424-05f2-4a1d-a0f2-70ec081eff7d |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
33176
diff
changeset
|
155 ;;; mm-partial.el ends here |