diff options
| author | Richard M. Stallman | 2011-07-06 12:44:33 -0400 |
|---|---|---|
| committer | Richard M. Stallman | 2011-07-06 12:44:33 -0400 |
| commit | aa8a705c161b87c5ff6f61b7d8041efb6918f46e (patch) | |
| tree | 976c4a6818aab87f9e0eb30eb830b7aa79fb2459 | |
| parent | 596a09585fcc1a5c9391a3e9d536ec042a5666ba (diff) | |
| download | emacs-aa8a705c161b87c5ff6f61b7d8041efb6918f46e.tar.gz emacs-aa8a705c161b87c5ff6f61b7d8041efb6918f46e.zip | |
rmailmm.el: record truncated mime entities.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/mail/rmailmm.el | 39 |
2 files changed, 38 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e26ad08244f..080f9494996 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2011-07-06 Richard Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * mail/rmailmm.el: Give entity a new slot, TRUNCATED. | ||
| 4 | (rmail-mime-entity): New arg TRUNCATED. | ||
| 5 | (rmail-mime-entity-truncated, rmail-mime-entity-set-truncated): | ||
| 6 | New functions. | ||
| 7 | (rmail-mime-save): Warn if entity is truncated. | ||
| 8 | (rmail-mime-toggle-hidden): Likewise, for showing. | ||
| 9 | (rmail-mime-process-multipart): Record when an entity is truncated. | ||
| 10 | |||
| 1 | 2011-07-06 Lars Magne Ingebrigtsen <larsi@gnus.org> | 11 | 2011-07-06 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 12 | ||
| 3 | * progmodes/grep.el (rgrep): Don't bind `process-connection-type', | 13 | * progmodes/grep.el (rgrep): Don't bind `process-connection-type', |
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el index 651defeaf46..5b8405dc499 100644 --- a/lisp/mail/rmailmm.el +++ b/lisp/mail/rmailmm.el | |||
| @@ -153,20 +153,21 @@ MIME entities.") | |||
| 153 | ;;; MIME-entity object | 153 | ;;; MIME-entity object |
| 154 | 154 | ||
| 155 | (defun rmail-mime-entity (type disposition transfer-encoding | 155 | (defun rmail-mime-entity (type disposition transfer-encoding |
| 156 | display header tagline body children handler) | 156 | display header tagline body children handler |
| 157 | &optional truncated) | ||
| 157 | "Retrun a newly created MIME-entity object from arguments. | 158 | "Retrun a newly created MIME-entity object from arguments. |
| 158 | 159 | ||
| 159 | A MIME-entity is a vector of 9 elements: | 160 | A MIME-entity is a vector of 10 elements: |
| 160 | 161 | ||
| 161 | [TYPE DISPOSITION TRANSFER-ENCODING DISPLAY HEADER TAGLINE BODY | 162 | [TYPE DISPOSITION TRANSFER-ENCODING DISPLAY HEADER TAGLINE BODY |
| 162 | CHILDREN HANDLER] | 163 | CHILDREN HANDLER TRUNCATED] |
| 163 | 164 | ||
| 164 | TYPE and DISPOSITION correspond to MIME headers Content-Type and | 165 | TYPE and DISPOSITION correspond to MIME headers Content-Type and |
| 165 | Cotent-Disposition respectively, and has this format: | 166 | Content-Disposition respectively, and have this format: |
| 166 | 167 | ||
| 167 | \(VALUE (ATTRIBUTE . VALUE) (ATTRIBUTE . VALUE) ...) | 168 | \(VALUE (ATTRIBUTE . VALUE) (ATTRIBUTE . VALUE) ...) |
| 168 | 169 | ||
| 169 | VALUE is a string and ATTRIBUTE is a symbol. | 170 | Each VALUE is a string and each ATTRIBUTE is a string. |
| 170 | 171 | ||
| 171 | Consider the following header, for example: | 172 | Consider the following header, for example: |
| 172 | 173 | ||
| @@ -208,9 +209,12 @@ entity have one or more children. A \"message/rfc822\" entity | |||
| 208 | has just one child. Any other entity has no child. | 209 | has just one child. Any other entity has no child. |
| 209 | 210 | ||
| 210 | HANDLER is a function to insert the entity according to DISPLAY. | 211 | HANDLER is a function to insert the entity according to DISPLAY. |
| 211 | It is called with one argument ENTITY." | 212 | It is called with one argument ENTITY. |
| 213 | |||
| 214 | TRUNCATED is non-nil if the text of this entity was truncated." | ||
| 215 | |||
| 212 | (vector type disposition transfer-encoding | 216 | (vector type disposition transfer-encoding |
| 213 | display header tagline body children handler)) | 217 | display header tagline body children handler truncated)) |
| 214 | 218 | ||
| 215 | ;; Accessors for a MIME-entity object. | 219 | ;; Accessors for a MIME-entity object. |
| 216 | (defsubst rmail-mime-entity-type (entity) (aref entity 0)) | 220 | (defsubst rmail-mime-entity-type (entity) (aref entity 0)) |
| @@ -222,6 +226,9 @@ It is called with one argument ENTITY." | |||
| 222 | (defsubst rmail-mime-entity-body (entity) (aref entity 6)) | 226 | (defsubst rmail-mime-entity-body (entity) (aref entity 6)) |
| 223 | (defsubst rmail-mime-entity-children (entity) (aref entity 7)) | 227 | (defsubst rmail-mime-entity-children (entity) (aref entity 7)) |
| 224 | (defsubst rmail-mime-entity-handler (entity) (aref entity 8)) | 228 | (defsubst rmail-mime-entity-handler (entity) (aref entity 8)) |
| 229 | (defsubst rmail-mime-entity-truncated (entity) (aref entity 9)) | ||
| 230 | (defsubst rmail-mime-entity-set-truncated (entity truncated) | ||
| 231 | (aset entity 9 truncated)) | ||
| 225 | 232 | ||
| 226 | (defsubst rmail-mime-message-p () | 233 | (defsubst rmail-mime-message-p () |
| 227 | "Non-nil if and only if the current message is a MIME." | 234 | "Non-nil if and only if the current message is a MIME." |
| @@ -237,6 +244,10 @@ It is called with one argument ENTITY." | |||
| 237 | (directory (button-get button 'directory)) | 244 | (directory (button-get button 'directory)) |
| 238 | (data (button-get button 'data)) | 245 | (data (button-get button 'data)) |
| 239 | (ofilename filename)) | 246 | (ofilename filename)) |
| 247 | (if (and (not (stringp data)) | ||
| 248 | (rmail-mime-entity-truncated data)) | ||
| 249 | (unless (y-or-n-p "This entity is truncated; save anyway? ") | ||
| 250 | (error "Aborted"))) | ||
| 240 | (setq filename (expand-file-name | 251 | (setq filename (expand-file-name |
| 241 | (read-file-name (format "Save as (default: %s): " filename) | 252 | (read-file-name (format "Save as (default: %s): " filename) |
| 242 | directory | 253 | directory |
| @@ -387,6 +398,11 @@ The value is a vector [ INDEX HEADER TAGLINE BODY END], where | |||
| 387 | (if (and rmail-mime-mbox-buffer (= (aref segment 1) (point-min))) | 398 | (if (and rmail-mime-mbox-buffer (= (aref segment 1) (point-min))) |
| 388 | (let ((new (aref (rmail-mime-entity-display entity) 1))) | 399 | (let ((new (aref (rmail-mime-entity-display entity) 1))) |
| 389 | (aset new 0 t)))) | 400 | (aset new 0 t)))) |
| 401 | ;; Query as a warning before showing if truncated. | ||
| 402 | (if (and (not (stringp entity)) | ||
| 403 | (rmail-mime-entity-truncated entity)) | ||
| 404 | (unless (y-or-n-p "This entity is truncated; show anyway? ") | ||
| 405 | (error "Aborted"))) | ||
| 390 | ;; Enter the shown mode. | 406 | ;; Enter the shown mode. |
| 391 | (rmail-mime-shown-mode entity) | 407 | (rmail-mime-shown-mode entity) |
| 392 | ;; Force this body shown. | 408 | ;; Force this body shown. |
| @@ -816,7 +832,7 @@ The other arguments are the same as `rmail-mime-multipart-handler'." | |||
| 816 | (let ((boundary (cdr (assq 'boundary content-type))) | 832 | (let ((boundary (cdr (assq 'boundary content-type))) |
| 817 | (subtype (cadr (split-string (car content-type) "/"))) | 833 | (subtype (cadr (split-string (car content-type) "/"))) |
| 818 | (index 0) | 834 | (index 0) |
| 819 | beg end next entities) | 835 | beg end next entities truncated) |
| 820 | (unless boundary | 836 | (unless boundary |
| 821 | (rmail-mm-get-boundary-error-message | 837 | (rmail-mm-get-boundary-error-message |
| 822 | "No boundary defined" content-type content-disposition | 838 | "No boundary defined" content-type content-disposition |
| @@ -845,7 +861,7 @@ The other arguments are the same as `rmail-mime-multipart-handler'." | |||
| 845 | (setq beg (point-min)) | 861 | (setq beg (point-min)) |
| 846 | 862 | ||
| 847 | (while (or (and (search-forward boundary nil t) | 863 | (while (or (and (search-forward boundary nil t) |
| 848 | (setq end (match-beginning 0))) | 864 | (setq truncated nil end (match-beginning 0))) |
| 849 | ;; If the boundary does not appear at all, | 865 | ;; If the boundary does not appear at all, |
| 850 | ;; the message was truncated. | 866 | ;; the message was truncated. |
| 851 | ;; Handle the rest of the truncated message | 867 | ;; Handle the rest of the truncated message |
| @@ -854,7 +870,7 @@ The other arguments are the same as `rmail-mime-multipart-handler'." | |||
| 854 | (and (save-excursion | 870 | (and (save-excursion |
| 855 | (skip-chars-forward "\n") | 871 | (skip-chars-forward "\n") |
| 856 | (> (point-max) (point))) | 872 | (> (point-max) (point))) |
| 857 | (setq end (point-max)))) | 873 | (setq truncated t end (point-max)))) |
| 858 | ;; If this is the last boundary according to RFC 2046, hide the | 874 | ;; If this is the last boundary according to RFC 2046, hide the |
| 859 | ;; epilogue, else hide the boundary only. Use a marker for | 875 | ;; epilogue, else hide the boundary only. Use a marker for |
| 860 | ;; `next' because `rmail-mime-show' may change the buffer. | 876 | ;; `next' because `rmail-mime-show' may change the buffer. |
| @@ -862,7 +878,7 @@ The other arguments are the same as `rmail-mime-multipart-handler'." | |||
| 862 | (setq next (point-max-marker))) | 878 | (setq next (point-max-marker))) |
| 863 | ((looking-at "[ \t]*\n") | 879 | ((looking-at "[ \t]*\n") |
| 864 | (setq next (copy-marker (match-end 0) t))) | 880 | (setq next (copy-marker (match-end 0) t))) |
| 865 | ((= end (point-max)) | 881 | (truncated |
| 866 | ;; We're handling what's left of a truncated message. | 882 | ;; We're handling what's left of a truncated message. |
| 867 | (setq next (point-max-marker))) | 883 | (setq next (point-max-marker))) |
| 868 | (t | 884 | (t |
| @@ -886,6 +902,7 @@ The other arguments are the same as `rmail-mime-multipart-handler'." | |||
| 886 | ;; Display a tagline. | 902 | ;; Display a tagline. |
| 887 | (aset (aref (rmail-mime-entity-display child) 1) 1 | 903 | (aset (aref (rmail-mime-entity-display child) 1) 1 |
| 888 | (aset (rmail-mime-entity-tagline child) 2 t)) | 904 | (aset (rmail-mime-entity-tagline child) 2 t)) |
| 905 | (rmail-mime-entity-set-truncated child truncated) | ||
| 889 | (push child entities))) | 906 | (push child entities))) |
| 890 | 907 | ||
| 891 | (delete-region end next) | 908 | (delete-region end next) |