Mercurial > emacs
annotate lisp/gnus/mm-partial.el @ 98019:72564311fb7b
Add local variable setting for change-log-default-name.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 06 Sep 2008 02:55:23 +0000 |
parents | f42ef85caf91 |
children | a9dc0e7c3f2b |
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, |
79708 | 4 ;; 2005, 2006, 2007, 2008 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 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
31717 | 15 |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
19 ;; GNU General Public License for more details. |
31717 | 20 |
21 ;; You should have received a copy of the GNU General Public License | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
31717 | 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) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
35 (let ((headers (with-current-buffer gnus-summary-buffer |
31717 | 36 gnus-newsgroup-headers)) |
37 phandles header) | |
38 (while (setq header (pop headers)) | |
39 (unless (eq (aref header 0) art) | |
40 (mm-with-unibyte-buffer | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
41 (gnus-request-article-this-buffer (aref header 0) |
31717 | 42 gnus-newsgroup-name) |
43 (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
|
44 (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
|
45 nil gnus-article-loose-mime)) nid) |
31717 | 46 (if (consp (car nhandles)) |
47 (mm-destroy-parts nhandles) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
48 (setq nid (cdr (assq 'id |
31717 | 49 (cdr (mm-handle-type nhandles))))) |
50 (if (not (equal id nid)) | |
51 (mm-destroy-parts nhandles) | |
52 (push nhandles phandles)))))))) | |
53 phandles)) | |
54 | |
55 ;;;###autoload | |
56 (defun mm-inline-partial (handle &optional no-display) | |
57 "Show the partial part of HANDLE. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
58 This function replaces the buffer of HANDLE with a buffer contains |
31717 | 59 the entire message. |
60 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
|
61 (let ((id (cdr (assq 'id (cdr (mm-handle-type handle))))) |
31717 | 62 phandles |
63 (b (point)) (n 1) total | |
64 phandle nn ntotal | |
65 gnus-displaying-mime handles buffer) | |
66 (unless (mm-handle-cache handle) | |
67 (unless id | |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
33176
diff
changeset
|
68 (error "Can not find message/partial id")) |
31717 | 69 (setq phandles |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
70 (sort (cons handle |
31717 | 71 (mm-partial-find-parts |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
72 id |
31717 | 73 (save-excursion |
74 (set-buffer gnus-summary-buffer) | |
75 (gnus-summary-article-number)))) | |
76 #'(lambda (a b) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
77 (let ((anumber (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
78 (cdr (assq 'number |
31717 | 79 (cdr (mm-handle-type a)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
80 (bnumber (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 b))))))) |
83 (< anumber bnumber))))) | |
84 (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
|
85 (mm-merge-handles gnus-article-mime-handles phandles)) |
31717 | 86 (save-excursion |
33176
aa40591dba57
(mm-inline-partial): Space-prefix temp buffer
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
87 (set-buffer (generate-new-buffer " *mm*")) |
31717 | 88 (while (setq phandle (pop phandles)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
89 (setq nn (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
90 (cdr (assq 'number |
31717 | 91 (cdr (mm-handle-type phandle)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
92 (setq ntotal (string-to-number |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
93 (cdr (assq 'total |
31717 | 94 (cdr (mm-handle-type phandle)))))) |
95 (if ntotal | |
96 (if total | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
97 (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
|
98 (error "The numbers of total are different")) |
31717 | 99 (setq total ntotal))) |
100 (unless (< nn n) | |
101 (unless (eq nn n) | |
102 (error "Missing part %d" n)) | |
103 (mm-insert-part phandle) | |
104 (goto-char (point-max)) | |
105 (when (not (eq 0 (skip-chars-backward "\r\n"))) | |
106 ;; remove tail blank spaces except one | |
107 (if (looking-at "\r?\n") | |
108 (goto-char (match-end 0))) | |
109 (delete-region (point) (point-max))) | |
110 (setq n (+ n 1)))) | |
111 (unless total | |
112 (error "Don't known the total number of")) | |
113 (if (<= n total) | |
114 (error "Missing part %d" n)) | |
115 (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
|
116 (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
|
117 (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
|
118 (1- (point)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
119 (point-max)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
120 (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
|
121 (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
|
122 (insert "MIME-Version: 1.0\n"))) |
31717 | 123 (setcar handle (current-buffer)) |
124 (mm-handle-set-cache handle t))) | |
125 (unless no-display | |
126 (save-excursion | |
127 (save-restriction | |
128 (narrow-to-region b b) | |
129 (mm-insert-part handle) | |
130 (let (gnus-article-mime-handles) | |
131 (run-hooks 'gnus-article-decode-hook) | |
132 (gnus-article-prepare-display) | |
133 (setq handles gnus-article-mime-handles)) | |
134 (when handles | |
135 ;; It is in article buffer. | |
136 (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
|
137 (mm-merge-handles gnus-article-mime-handles handles))) |
31717 | 138 (mm-handle-set-undisplayer |
139 handle | |
140 `(lambda () | |
141 (let (buffer-read-only) | |
142 (condition-case nil | |
143 ;; This is only valid on XEmacs. | |
144 (mapcar (lambda (prop) | |
145 (remove-specifier | |
146 (face-property 'default prop) (current-buffer))) | |
147 '(background background-pixmap foreground)) | |
148 (error nil)) | |
149 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))) | |
150 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
151 (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
|
152 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
153 ;; 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
|
154 ;;; mm-partial.el ends here |