Mercurial > emacs
annotate lisp/gnus/mm-partial.el @ 90772:b15334b4a9c3
(coding_alloc_by_making_gap): New arg offset.
(alloc_destination): Call coding_alloc_by_making_gap with the arg
offset.
(decode_coding_iso_2022): Update coding->safe_charsets.
(decode_coding_gap): Temporarily set
current_buffer->text->inhibit_shrinking to 1.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 23 Feb 2007 06:02:23 +0000 |
parents | 95d0cdf160ea |
children | f55f9811f5d7 |
rev | line source |
---|---|
31717 | 1 ;;; mm-partial.el --- showing message/partial |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, |
75347 | 4 ;; 2005, 2006, 2007 Free Software Foundation, Inc. |
31717 | 5 |
6 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu> | |
7 ;; Keywords: message partial | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published | |
13 ;; by the Free Software Foundation; either version 2, or (at your | |
14 ;; option) any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, but | |
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 ;; General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
31717 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Code: | |
29 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
30 (eval-when-compile (require 'cl)) |
31717 | 31 |
32 (require 'gnus-sum) | |
33 (require 'mm-util) | |
34 (require 'mm-decode) | |
35 | |
36 (defun mm-partial-find-parts (id &optional art) | |
37 (let ((headers (save-excursion | |
38 (set-buffer gnus-summary-buffer) | |
39 gnus-newsgroup-headers)) | |
40 phandles header) | |
41 (while (setq header (pop headers)) | |
42 (unless (eq (aref header 0) art) | |
43 (mm-with-unibyte-buffer | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
44 (gnus-request-article-this-buffer (aref header 0) |
31717 | 45 gnus-newsgroup-name) |
46 (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
|
47 (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
|
48 nil gnus-article-loose-mime)) nid) |
31717 | 49 (if (consp (car nhandles)) |
50 (mm-destroy-parts nhandles) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
51 (setq nid (cdr (assq 'id |
31717 | 52 (cdr (mm-handle-type nhandles))))) |
53 (if (not (equal id nid)) | |
54 (mm-destroy-parts nhandles) | |
55 (push nhandles phandles)))))))) | |
56 phandles)) | |
57 | |
58 ;;;###autoload | |
59 (defun mm-inline-partial (handle &optional no-display) | |
60 "Show the partial part of HANDLE. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
61 This function replaces the buffer of HANDLE with a buffer contains |
31717 | 62 the entire message. |
63 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
|
64 (let ((id (cdr (assq 'id (cdr (mm-handle-type handle))))) |
31717 | 65 phandles |
66 (b (point)) (n 1) total | |
67 phandle nn ntotal | |
68 gnus-displaying-mime handles buffer) | |
69 (unless (mm-handle-cache handle) | |
70 (unless id | |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
33176
diff
changeset
|
71 (error "Can not find message/partial id")) |
31717 | 72 (setq phandles |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
73 (sort (cons handle |
31717 | 74 (mm-partial-find-parts |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
75 id |
31717 | 76 (save-excursion |
77 (set-buffer gnus-summary-buffer) | |
78 (gnus-summary-article-number)))) | |
79 #'(lambda (a b) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
80 (let ((anumber (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
81 (cdr (assq 'number |
31717 | 82 (cdr (mm-handle-type a)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
83 (bnumber (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
84 (cdr (assq 'number |
31717 | 85 (cdr (mm-handle-type b))))))) |
86 (< anumber bnumber))))) | |
87 (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
|
88 (mm-merge-handles gnus-article-mime-handles phandles)) |
31717 | 89 (save-excursion |
33176
aa40591dba57
(mm-inline-partial): Space-prefix temp buffer
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
90 (set-buffer (generate-new-buffer " *mm*")) |
31717 | 91 (while (setq phandle (pop phandles)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
92 (setq nn (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
93 (cdr (assq 'number |
31717 | 94 (cdr (mm-handle-type phandle)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
95 (setq ntotal (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
96 (cdr (assq 'total |
31717 | 97 (cdr (mm-handle-type phandle)))))) |
98 (if ntotal | |
99 (if total | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
100 (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
|
101 (error "The numbers of total are different")) |
31717 | 102 (setq total ntotal))) |
103 (unless (< nn n) | |
104 (unless (eq nn n) | |
105 (error "Missing part %d" n)) | |
106 (mm-insert-part phandle) | |
107 (goto-char (point-max)) | |
108 (when (not (eq 0 (skip-chars-backward "\r\n"))) | |
109 ;; remove tail blank spaces except one | |
110 (if (looking-at "\r?\n") | |
111 (goto-char (match-end 0))) | |
112 (delete-region (point) (point-max))) | |
113 (setq n (+ n 1)))) | |
114 (unless total | |
115 (error "Don't known the total number of")) | |
116 (if (<= n total) | |
117 (error "Missing part %d" n)) | |
118 (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
|
119 (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
|
120 (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
|
121 (1- (point)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
122 (point-max)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
123 (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
|
124 (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
|
125 (insert "MIME-Version: 1.0\n"))) |
31717 | 126 (setcar handle (current-buffer)) |
127 (mm-handle-set-cache handle t))) | |
128 (unless no-display | |
129 (save-excursion | |
130 (save-restriction | |
131 (narrow-to-region b b) | |
132 (mm-insert-part handle) | |
133 (let (gnus-article-mime-handles) | |
134 (run-hooks 'gnus-article-decode-hook) | |
135 (gnus-article-prepare-display) | |
136 (setq handles gnus-article-mime-handles)) | |
137 (when handles | |
138 ;; It is in article buffer. | |
139 (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
|
140 (mm-merge-handles gnus-article-mime-handles handles))) |
31717 | 141 (mm-handle-set-undisplayer |
142 handle | |
143 `(lambda () | |
144 (let (buffer-read-only) | |
145 (condition-case nil | |
146 ;; This is only valid on XEmacs. | |
147 (mapcar (lambda (prop) | |
148 (remove-specifier | |
149 (face-property 'default prop) (current-buffer))) | |
150 '(background background-pixmap foreground)) | |
151 (error nil)) | |
152 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))) | |
153 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
154 (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
|
155 |
52401 | 156 ;;; 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
|
157 ;;; mm-partial.el ends here |