[mew-int 00849] Re: Saving attachment mail (one more)

Tatsuya Kinoshita tats at example.com
Wed Apr 24 23:37:12 JST 2002


In message [mew-int 00843], on Tue, 16 Apr 2002,
Tatsuya Kinoshita <tats at example.com> wrote:

> However, part-3.1, 3.2, 3.3 are not extracted even if a part is
> Message/Rfc822.  It's a problem, I think.  I know that Mailman
> uses this format for a digest mail.
> 
> And also, I hope to extract a single message by `C-u B'.
> 
> I planned this feature, but I've not implemented it yet...

I've done it.  See the patch that is attached to this mail.

Now I can extract part-3.1, 3.2, ... from Mailman's digest mail
by `B' or `C-u B'.

Note: If part-3 is CT: Message/Rfc822 (not Multipart/*),
part-3.1, 3.2, ... are not extracted.

-- 
Tatsuya Kinoshita
-------------- next part --------------

 This patch is written by Tatsuya Kinoshita.  Copyright is disclaimed.

diff -ur mew.orig/mew-edit.el mew/mew-edit.el
--- mew.orig/mew-edit.el	Thu Apr 11 21:33:09 2002
+++ mew/mew-edit.el	Wed Apr 24 23:31:04 2002
@@ -419,50 +419,63 @@
 ;;; Burst
 ;;;
 
-(defun mew-summary-burst-body (fld msg folder)
+(defun mew-summary-burst-body (fld msg folder &optional num)
   (save-excursion
     (let ((buf (generate-new-buffer mew-buffer-prefix))
-	  ret errmsg entry multi mstr m n len)
+	  ret errmsg mstr m)
       (set-buffer buf)
       (mew-erase-buffer)
       (mew-insert-message fld msg mew-cs-text-for-read nil)
       (mew-dinfo-set 1 nil nil nil) ;; xxx
       (mew-decode-for-edit)
-      (setq multi (mew-syntax-get-part mew-decode-syntax))
       (mew-local-folder-check folder)
       (cond
-       ((not (mew-syntax-multipart-p multi))
+       ((not (mew-syntax-multipart-p (mew-syntax-get-part mew-decode-syntax)))
 	(message "Cannot burst"))
        ((not (setq mstr (mew-folder-new-message folder 'num-only)))
 	(setq errmsg (format "Error in %s. Nothing was processed" folder)))
        (t
-	(setq m (string-to-int mstr))
-	(setq len (- (length multi) mew-syntax-magic))
-	(setq n 1)
-	(while (<= n len)
-	  (setq entry (mew-syntax-get-entry mew-decode-syntax (list n)))
-	  (if (not
-	       (string=
-		(mew-syntax-get-value (mew-syntax-get-ct entry) 'cap)
-		mew-ct-msg))
-	      () ;; return value
-	    (mew-frwlet
-	     mew-cs-dummy mew-cs-text-for-write
-	     (write-region
-	      (mew-syntax-get-begin entry)
-	      ;; This is RFC 822 message.
-	      ;; So, body is a single text/plain.
-	      (mew-syntax-get-end (mew-syntax-get-part entry))
-	      (mew-expand-folder folder (int-to-string m))
-	      nil 'no-msg))
-	    (setq m (1+ m)))
-	  (setq n (1+ n)))
-	(mew-touch-folder folder)
-	(setq ret (list mstr (int-to-string (1- m))))))
+	(setq m (mew-summary-burst-part (mew-syntax-get-part mew-decode-syntax)
+					folder (string-to-int mstr) num))
+	(if (= m (string-to-int mstr))
+	    (message "Nothing was processed")
+	  (mew-touch-folder folder)
+	  (setq ret (list mstr (int-to-string (1- m)))))))
       (mew-remove-buffer buf)
       (if errmsg (error errmsg))
       ret)))
 
+(defun mew-summary-burst-part (part folder newmsg &optional num)
+  (let (n len nums entry)
+    (setq n 1)
+    (cond
+     (num
+      (setq nums (mew-syntax-number-to-nums num))
+      (setq len 1))
+     (t
+      (setq nums (list n))
+      (setq len (- (length part) mew-syntax-magic))))
+    (while (<= n len)
+      (setq entry (mew-syntax-get-entry part nums))
+      (cond
+       ((mew-syntax-multipart-p entry)
+	(setq newmsg (mew-summary-burst-part entry folder newmsg)))
+       ((string= (mew-syntax-get-value (mew-syntax-get-ct entry) 'cap)
+		 mew-ct-msg)
+	(mew-frwlet
+	 mew-cs-dummy mew-cs-text-for-write
+	 (write-region
+	  (mew-syntax-get-begin entry)
+	  ;; This is RFC 822 message.
+	  ;; So, body is a single text/plain.
+	  (mew-syntax-get-end (mew-syntax-get-part entry))
+	  (mew-expand-folder folder (int-to-string newmsg))
+	  nil 'no-msg))
+	(setq newmsg (1+ newmsg))))
+      (setq n (1+ n))
+      (setq nums (list n)))
+    newmsg))
+
 (defvar mew-burst-last-folder nil)
 
 (defun mew-input-burst-folder ()
@@ -473,16 +486,18 @@
      (setq mew-burst-last-folder (mew-input-folder default)) ;; local folder
      mew-burst-last-folder))
 
-(defun mew-summary-burst ()
-  "De-capsulate messages embedded in this message."
-  (interactive)
+(defun mew-summary-burst (&optional arg)
+  "De-capsulate messages embedded in this message.
+If called with '\\[universal-argument]', the current part is de-capsulated."
+  (interactive "P")
   (mew-summary-msg-or-part
    (let ((fld (mew-summary-folder-name))
 	 (msg (mew-summary-message-number2))
 	 (folder (mew-input-burst-folder))
+	 (num (if arg (mew-syntax-number)))
 	 ret)
      (message "Bursting...")
-     (setq ret (mew-summary-burst-body fld msg folder))
+     (setq ret (mew-summary-burst-body fld msg folder num))
      (when ret
        (message "Bursting...done")
        (if (y-or-n-p (format "Go to %s? " folder))


More information about the Mew-int mailing list