Gnus development mailing list
 help / color / mirror / Atom feed
* gnus-summary-save-parts enhancement
@ 2011-02-10 15:43 Antoine Levitt
  2011-02-10 16:27 ` Julien Danjou
  0 siblings, 1 reply; 7+ messages in thread
From: Antoine Levitt @ 2011-02-10 15:43 UTC (permalink / raw)
  To: ding

First of all, can someone merge this?

=== modified file 'lisp/gnus/gnus-sum.el'
--- lisp/gnus/gnus-sum.el       2011-02-05 00:11:16 +0000                      
+++ lisp/gnus/gnus-sum.el	2011-02-10 15:27:11 +0000
@@ -12087,7 +12087,7 @@
 			  gnus-summary-save-parts-default-mime)
 		      'gnus-summary-save-parts-type-history)
 	 (setq gnus-summary-save-parts-last-directory
-	       (read-file-name "Save to directory: "
+	       (read-directory-name "Save to directory: "
 			       gnus-summary-save-parts-last-directory
 			       nil t))
 	 current-prefix-arg))

It just clarifies that the completion asks for a directory and not a
file. Ido users need this or ido fails spectacularly.

Second of all, I think there should be a setting to only save
non-displayable content (typical use case is someone sends you several
pdf/doc/jpeg files, you want to use X m with "." but not save the
plaintext and HTML part). Here's another patch to do that (basically
adds a defcustom and an if, using mm-automatic-display-p).

=== modified file 'lisp/gnus/gnus-sum.el'                                      
--- lisp/gnus/gnus-sum.el       2011-02-05 00:11:16 +0000                      
+++ lisp/gnus/gnus-sum.el	2011-02-10 15:36:37 +0000
@@ -1259,6 +1259,13 @@
   :group 'gnus-summary
   :type 'regexp)
 
+(defcustom gnus-summary-save-parts-only-non-display nil
+  "*Whether to only save parts that are not displayed in
+  `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]). Check
+  is performed using `mm-automatic-display-p'."
+  :group 'gnus-summary
+  :type 'boolean)
+
 (defcustom gnus-read-all-available-headers nil
   "Whether Gnus should parse all headers made available to it.
 This is mostly relevant for slow back ends where the user may
@@ -12117,22 +12124,23 @@
     (when (if reverse
 	      (not (string-match type (mm-handle-media-type handle)))
 	    (string-match type (mm-handle-media-type handle)))
-      (let ((file (expand-file-name
-		   (gnus-map-function
-		    mm-file-name-rewrite-functions
-		    (file-name-nondirectory
-		     (or
-		      (mail-content-type-get
-		       (mm-handle-disposition handle) 'filename)
-		      (mail-content-type-get
-		       (mm-handle-type handle) 'name)
-		      (format "%s.%d.%d" gnus-newsgroup-name
-			      (cdr gnus-article-current)
-			      gnus-summary-save-parts-counter))))
-		   dir)))
-	(incf gnus-summary-save-parts-counter)
-	(unless (file-exists-p file)
-	  (mm-save-part-to-file handle file))))))
+      (unless (and gnus-summary-save-parts-only-non-display (mm-automatic-display-p handle))
+	(let ((file (expand-file-name
+		     (gnus-map-function
+		      mm-file-name-rewrite-functions
+		      (file-name-nondirectory
+		       (or
+			(mail-content-type-get
+			 (mm-handle-disposition handle) 'filename)
+			(mail-content-type-get
+			 (mm-handle-type handle) 'name)
+			(format "%s.%d.%d" gnus-newsgroup-name
+				(cdr gnus-article-current)
+				gnus-summary-save-parts-counter))))
+		     dir)))
+	  (incf gnus-summary-save-parts-counter)
+	  (unless (file-exists-p file)
+	    (mm-save-part-to-file handle file)))))))
 
 ;; Summary extract commands




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-12 16:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10 15:43 gnus-summary-save-parts enhancement Antoine Levitt
2011-02-10 16:27 ` Julien Danjou
2011-02-12  3:11   ` Eric Abrahamsen
2011-02-12 10:31     ` Antoine Levitt
2011-02-12 11:48       ` Eric Abrahamsen
2011-02-12 12:12         ` Antoine Levitt
2011-02-12 16:25           ` Eric Abrahamsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).