bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: several rmail-related functions do not interact well with full heade


From: Eli Zaretskii
Subject: Re: several rmail-related functions do not interact well with full header
Date: Sat, 02 Feb 2002 19:12:11 +0200

> From: Boris Aronov <aronov@ziggy.poly.edu>
> Date: Mon, 28 Jan 2002 19:41:31 -0500 (EST)
> 
> When one does "t" in RMAIL to toggle full display of headers, several
> RMAIL functions break.  They assume that full display is NOT on.  They
> should be wrapped in code that saves the state of the toggle, then
> sets it to whatever they expect and then resets it, if necessary.
> 
> Examples:  go to any rmail file, type "t" and invoke
> rmail-redecode-body.  Or load "uce.el" and invoke uce-reply-...
> same effect.

Thank you for your report.  The patches below should fix
rmail-redecode-body and uce.el.

I tried several other commands that look for the "EOOH" header, but
all those I tried seemed to work regardless of header pruning.  If you
know additional commands that fail, please tell what they are and how
to reproduce the failure.


2002-02-02  Eli Zaretskii  <eliz@is.elta.co.il>

        * mail/uce.el (uce-reply-to-uce): Prune the headers before copying
        the message text into the *mail* buffer, and restore the pruned
        state after that.

        * mail/rmail.el (rmail-redecode-body): Prune the headers before
        looking for X-Coding-System header, and restore the pruned state
        before returning.

Index: lisp/mail/rmail.el
===================================================================
RCS file: /cvs/emacs/lisp/mail/rmail.el,v
retrieving revision 1.349
retrieving revision 1.349.4.1
diff -u -r1.349 -r1.349.4.1
--- lisp/mail/rmail.el  16 Sep 2001 07:55:19 -0000      1.349
+++ lisp/mail/rmail.el  2 Feb 2002 16:58:33 -0000       1.349.4.1
@@ -2449,43 +2449,51 @@
     (or (eq major-mode 'rmail-mode)
        (switch-to-buffer rmail-buffer))
     (save-excursion
-      (unwind-protect
-         (let ((msgbeg (rmail-msgbeg rmail-current-message))
-               (msgend (rmail-msgend rmail-current-message))
-               x-coding-header)
-           (narrow-to-region msgbeg msgend)
-           (goto-char (point-min))
-           (when (search-forward "\n*** EOOH ***\n" (point-max) t)
-             (narrow-to-region msgbeg (point)))
-           (goto-char (point-min))
-           (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
-               (let ((old-coding (intern (match-string 1)))
-                     (buffer-read-only nil))
-                 (check-coding-system old-coding)
-                 ;; Make sure the new coding system uses the same EOL
-                 ;; conversion, to prevent ^M characters from popping
-                 ;; up all over the place.
-                 (setq coding
-                       (coding-system-change-eol-conversion
-                        coding
-                        (coding-system-eol-type old-coding)))
-                 (setq x-coding-header (point-marker))
-                 (narrow-to-region msgbeg msgend)
-                 (encode-coding-region (point) msgend old-coding)
-                 (decode-coding-region (point) msgend coding)
-                 (setq last-coding-system-used coding)
-                 ;; Rewrite the coding-system header according
-                 ;; to what we did.
-                 (goto-char x-coding-header)
-                 (delete-region (point)
-                                (save-excursion
-                                  (beginning-of-line)
-                                  (point)))
-                 (insert "X-Coding-System: "
-                         (symbol-name last-coding-system-used))
-                 (set-marker x-coding-header nil)
-                 (rmail-show-message))
-             (error "No X-Coding-System header found")))))))
+      (let ((pruned (rmail-msg-is-pruned)))
+       (unwind-protect
+           (let ((msgbeg (rmail-msgbeg rmail-current-message))
+                 (msgend (rmail-msgend rmail-current-message))
+                 x-coding-header)
+             ;; We need the message headers pruned (we later restore
+             ;; the pruned stat to what it was, see the end of
+             ;; unwind-protect form).
+             (or pruned
+                 (rmail-toggle-header 1))
+             (narrow-to-region msgbeg msgend)
+             (goto-char (point-min))
+             (when (search-forward "\n*** EOOH ***\n" (point-max) t)
+               (narrow-to-region msgbeg (point)))
+             (goto-char (point-min))
+             (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
+                 (let ((old-coding (intern (match-string 1)))
+                       (buffer-read-only nil))
+                   (check-coding-system old-coding)
+                   ;; Make sure the new coding system uses the same EOL
+                   ;; conversion, to prevent ^M characters from popping
+                   ;; up all over the place.
+                   (setq coding
+                         (coding-system-change-eol-conversion
+                          coding
+                          (coding-system-eol-type old-coding)))
+                   (setq x-coding-header (point-marker))
+                   (narrow-to-region msgbeg msgend)
+                   (encode-coding-region (point) msgend old-coding)
+                   (decode-coding-region (point) msgend coding)
+                   (setq last-coding-system-used coding)
+                   ;; Rewrite the coding-system header according
+                   ;; to what we did.
+                   (goto-char x-coding-header)
+                   (delete-region (point)
+                                  (save-excursion
+                                    (beginning-of-line)
+                                    (point)))
+                   (insert "X-Coding-System: "
+                           (symbol-name last-coding-system-used))
+                   (set-marker x-coding-header nil)
+                   (rmail-show-message))
+               (error "No X-Coding-System header found")))
+         (or pruned
+             (rmail-toggle-header 0)))))))
 
 ;; Find all occurrences of certain fields, and highlight them.
 (defun rmail-highlight-headers ()
Index: lisp/mail/uce.el
===================================================================
RCS file: /cvs/emacs/lisp/mail/uce.el,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -u -r1.8 -r1.8.4.1
--- lisp/mail/uce.el    13 Jul 2001 12:59:13 -0000      1.8
+++ lisp/mail/uce.el    2 Feb 2002 16:59:02 -0000       1.8.4.1
@@ -222,10 +222,15 @@
         (cond ((eq uce-mail-reader 'gnus) gnus-original-article-buffer)
               ((eq uce-mail-reader 'rmail) "RMAIL")
               (t (error 
-                  "Variable uce-mail-reader set to unrecognized value")))))
+                  "Variable uce-mail-reader set to unrecognized value"))))
+       (full-header-p (and (eq uce-mail-reader 'rmail)
+                           (not (rmail-msg-is-pruned)))))
     (or (get-buffer message-buffer)
        (error (concat "No buffer " message-buffer ", cannot find UCE")))
     (switch-to-buffer message-buffer)
+    ;; We need the message with headers pruned.
+    (if full-header-p
+       (rmail-toggle-header 1))
     (let ((to (mail-strip-quoted-names (mail-fetch-field "from" t)))
          (reply-to (mail-fetch-field "reply-to"))
          temp)
@@ -254,6 +259,9 @@
                 (rmail-maybe-set-message-counters)
                 (copy-region-as-kill (rmail-msgbeg rmail-current-message) 
                                      (rmail-msgend rmail-current-message))))))
+      ;; Restore the pruned header state we found.
+      (if full-header-p
+         (rmail-toggle-header 0))
       (switch-to-buffer "*mail*")
       (erase-buffer)
       (setq temp (point))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]