diff options
| author | Richard M. Stallman | 1997-03-20 04:55:20 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-03-20 04:55:20 +0000 |
| commit | 55a42e8cdfbc83f4f9701ab47f29cd831b886d09 (patch) | |
| tree | 95e7298c29a15e9dc25250b5b9926855cb2fa942 | |
| parent | ca57718c8e4bbea2e7b5a2c09df26818e05fa026 (diff) | |
| download | emacs-55a42e8cdfbc83f4f9701ab47f29cd831b886d09.tar.gz emacs-55a42e8cdfbc83f4f9701ab47f29cd831b886d09.zip | |
(rmail-retry-failure): Special handling for mime.
(mail-mime-unsent-header): New variable.
| -rw-r--r-- | lisp/mail/rmail.el | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 8eb37907f4c..8fc8f012457 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -2621,11 +2621,16 @@ typically for purposes of moderating a list." | |||
| 2621 | "^|? *---+ +Message text follows: +---+ *|?$") | 2621 | "^|? *---+ +Message text follows: +---+ *|?$") |
| 2622 | "A regexp that matches the separator before the text of a failed message.") | 2622 | "A regexp that matches the separator before the text of a failed message.") |
| 2623 | 2623 | ||
| 2624 | (defvar mail-mime-unsent-header "^Content-Type: message/rfc822 *$" | ||
| 2625 | "A regexp that matches the header of a MIME body part with a failed message.") | ||
| 2626 | |||
| 2624 | (defun rmail-retry-failure () | 2627 | (defun rmail-retry-failure () |
| 2625 | "Edit a mail message which is based on the contents of the current message. | 2628 | "Edit a mail message which is based on the contents of the current message. |
| 2626 | For a message rejected by the mail system, extract the interesting headers and | 2629 | For a message rejected by the mail system, extract the interesting headers and |
| 2627 | the body of the original message. | 2630 | the body of the original message. |
| 2628 | The variable `mail-unsent-separator' should match the string that | 2631 | If the failed message is a MIME multipart message, it is searched for a |
| 2632 | body part with a header which matches the variable `mail-mime-unsent-header'. | ||
| 2633 | Otherwise, the variable `mail-unsent-separator' should match the string that | ||
| 2629 | delimits the returned original message. | 2634 | delimits the returned original message. |
| 2630 | The variable `rmail-retry-ignored-headers' is a regular expression | 2635 | The variable `rmail-retry-ignored-headers' is a regular expression |
| 2631 | specifying headers which should not be copied into the new message." | 2636 | specifying headers which should not be copied into the new message." |
| @@ -2637,23 +2642,34 @@ specifying headers which should not be copied into the new message." | |||
| 2637 | (save-excursion | 2642 | (save-excursion |
| 2638 | ;; Narrow down to just the quoted original message | 2643 | ;; Narrow down to just the quoted original message |
| 2639 | (rmail-beginning-of-message) | 2644 | (rmail-beginning-of-message) |
| 2640 | (let ((case-fold-search t)) | 2645 | (let* ((case-fold-search t) |
| 2641 | (if (search-forward "This is a MIME-encapsulated message\n\n--" nil t) | 2646 | (top (point)) |
| 2647 | (content-type | ||
| 2648 | (save-restriction | ||
| 2649 | ;; Fetch any content-type header in current message | ||
| 2650 | (search-forward "\n\n") (narrow-to-region top (point)) | ||
| 2651 | (mail-fetch-field "Content-Type") )) ) | ||
| 2652 | ;; Handle MIME multipart bounce messages | ||
| 2653 | (if (and content-type | ||
| 2654 | (string-match | ||
| 2655 | ";[\n\t ]*boundary=\"?\\([-0-9a-z'()+_,./:=?]+\\)\"?" | ||
| 2656 | content-type)) | ||
| 2642 | (let ((codestring | 2657 | (let ((codestring |
| 2643 | (buffer-substring (progn (beginning-of-line) (point)) | 2658 | (concat "\n--" |
| 2644 | (progn (end-of-line) (point))))) | 2659 | (substring content-type (match-beginning 1) |
| 2645 | (or (re-search-forward mail-unsent-separator nil t) | 2660 | (match-end 1))))) |
| 2661 | (or (re-search-forward mail-mime-unsent-header nil t) | ||
| 2646 | (error "Cannot find beginning of header in failed message")) | 2662 | (error "Cannot find beginning of header in failed message")) |
| 2647 | (or (and (search-forward codestring nil t) | 2663 | (or (search-forward "\n\n" nil t) |
| 2648 | (search-forward "\n\n" nil t)) | ||
| 2649 | (error "Cannot find end of Mime data in failed message")) | 2664 | (error "Cannot find end of Mime data in failed message")) |
| 2650 | (setq bounce-start (point)) | 2665 | (setq bounce-start (point)) |
| 2651 | (save-excursion | 2666 | (or (search-forward codestring nil t) |
| 2652 | (goto-char (point-max)) | 2667 | (error "Cannot find end of Mime data in failed message")) |
| 2653 | (search-backward codestring) | 2668 | (setq bounce-end (match-beginning 0)) |
| 2654 | (setq bounce-end (point))) | 2669 | ; (or (search-forward "\n\n" nil t) |
| 2655 | (or (search-forward "\n\n" nil t) | 2670 | ; (error "Cannot find end of header in failed message")) |
| 2656 | (error "Cannot find end of header in failed message"))) | 2671 | ) |
| 2672 | ;; non-MIME bounce | ||
| 2657 | (or (re-search-forward mail-unsent-separator nil t) | 2673 | (or (re-search-forward mail-unsent-separator nil t) |
| 2658 | (error "Cannot parse this as a failure message")) | 2674 | (error "Cannot parse this as a failure message")) |
| 2659 | (skip-chars-forward "\n") | 2675 | (skip-chars-forward "\n") |