Changes committed gnus/lisp (ChangeLog gnus-art.el gnus-sum.el)

"Katsumi Yamaoka" <[email protected]> Wed, 30 Jul 2008 01:59:05 +0200
Newsgroups gmane.emacs.gnus.commits
Message-ID <[email protected]>
Modified: ChangeLog gnus-art.el gnus-sum.el

* gnus-art.el (gnus-summary-save-in-pipe): Generate work buffer always;
 don't redisplay article for raw contents; remove plural articles stuff.

* gnus-sum.el (gnus-summary-pipe-output): Pipe raw articles by symbolic
 prefix `r'; use gnus-summary-save-in-pipe directly instead of relying
 on gnus-summary-save-article; display results properly.


Index: ChangeLog
diff -u gnus/lisp/ChangeLog:7.1893 gnus/lisp/ChangeLog:7.1894
--- ChangeLog:7.1893	Tue Jul 29 01:47:19 2008
+++ ChangeLog	Wed Jul 30 01:59:05 2008
@@ -1,3 +1,12 @@
+2008-07-29  Katsumi Yamaoka  <[email protected]>
+
+	* gnus-art.el (gnus-summary-save-in-pipe): Generate work buffer always;
+	don't redisplay article for raw contents; remove plural articles stuff.
+
+	* gnus-sum.el (gnus-summary-pipe-output): Pipe raw articles by symbolic
+	prefix `r'; use gnus-summary-save-in-pipe directly instead of relying
+	on gnus-summary-save-article; display results properly.
+
 2008-07-28  Katsumi Yamaoka  <[email protected]>
 
 	* lpath.el: No need to fbind ns-focus-frame.
Index: gnus-art.el
diff -u gnus/lisp/gnus-art.el:7.278 gnus/lisp/gnus-art.el:7.279
--- gnus-art.el:7.278	Fri Jul 25 01:56:56 2008
+++ gnus-art.el	Wed Jul 30 01:59:05 2008
@@ -3955,60 +3955,41 @@
     last used for saving.
 Non-nil value for RAW overrides `:decode' and `:headers' properties
 and the raw article including all headers will be piped."
-  (let ((save-buffer gnus-save-article-buffer)
-	(default (or gnus-summary-pipe-output-default-command
-		     gnus-last-shell-command)))
-    ;; `gnus-save-article-buffer' should be a buffer containing the article
-    ;; contents if this function is called by way of the command
-    ;; `gnus-summary-pipe-output'.  OTOH, that the buffer does not exist
-    ;; means this function is called independently.
-    (unless (gnus-buffer-live-p save-buffer)
-      (let ((article (gnus-summary-article-number))
-	    (decode (unless raw
-		      (get 'gnus-summary-save-in-pipe :decode))))
-	(if article
-	    (if (vectorp (gnus-summary-article-header article))
-		(save-window-excursion
-		  (let ((gnus-display-mime-function
-			 (when decode
-			   gnus-display-mime-function))
-			(gnus-article-prepare-hook
-			 (when decode
-			   gnus-article-prepare-hook)))
-		    (gnus-summary-select-article t t nil article)
-		    (gnus-summary-goto-subject article))
-		  (insert-buffer-substring
-		   (prog1
-		       (if decode
-			   gnus-article-buffer
-			 gnus-original-article-buffer)
-		     (setq save-buffer
-			   (nnheader-set-temp-buffer " *Gnus Save*"))))
-		  ;; Remove unwanted headers.
-		  (when (and (not raw)
-			     (or (get 'gnus-summary-save-in-pipe :headers)
-				 (not gnus-save-all-headers)))
-		    (let ((gnus-visible-headers
-			   (or (symbol-value (get 'gnus-summary-save-in-pipe
-						  :headers))
-			       gnus-saved-headers gnus-visible-headers))
-			  (gnus-summary-buffer nil))
-		      (article-hide-headers 1 t))))
-	      (error "%d is not a real article" article))
-	  (error "No article to pipe"))))
+  (let ((article (gnus-summary-article-number))
+	(decode (unless raw
+		  (get 'gnus-summary-save-in-pipe :decode)))
+	save-buffer default)
+    (if article
+	(if (vectorp (gnus-summary-article-header article))
+	    (save-current-buffer
+	      (gnus-summary-select-article decode decode nil article)
+	      (insert-buffer-substring
+	       (prog1
+		   (if decode
+		       gnus-article-buffer
+		     gnus-original-article-buffer)
+		 (setq save-buffer
+		       (nnheader-set-temp-buffer " *Gnus Save*"))))
+	      ;; Remove unwanted headers.
+	      (when (and (not raw)
+			 (or (get 'gnus-summary-save-in-pipe :headers)
+			     (not gnus-save-all-headers)))
+		(let ((gnus-visible-headers
+		       (or (symbol-value (get 'gnus-summary-save-in-pipe
+					      :headers))
+			   gnus-saved-headers gnus-visible-headers))
+		      (gnus-summary-buffer nil))
+		  (article-hide-headers 1 t))))
+	  (error "%d is not a real article" article))
+      (error "No article to pipe"))
+    (setq default (or gnus-summary-pipe-output-default-command
+		      gnus-last-shell-command))
     (unless (stringp command)
       (setq command
 	    (if (and (eq command 'default) default)
 		default
-	      (gnus-read-shell-command
-	       (format
-		"Shell command on %s: "
-		(if (and gnus-number-of-articles-to-be-saved
-			 (> gnus-number-of-articles-to-be-saved 1))
-		    (format "these %d articles"
-			    gnus-number-of-articles-to-be-saved)
-		  "this article"))
-	       default))))
+	      (gnus-read-shell-command "Shell command on this article: "
+				       default))))
     (when (string-equal command "")
       (if default
 	  (setq command default)
Index: gnus-sum.el
diff -u gnus/lisp/gnus-sum.el:7.230 gnus/lisp/gnus-sum.el:7.231
--- gnus-sum.el:7.230	Wed Jul  2 13:47:36 2008
+++ gnus-sum.el	Wed Jul 30 01:59:05 2008
@@ -11613,29 +11613,69 @@
     (gnus-set-mode-line 'summary)
     n))
 
-(defun gnus-summary-pipe-output (&optional arg headers)
+(defun gnus-summary-pipe-output (&optional n sym)
   "Pipe the current article to a subprocess.
 If N is a positive number, pipe the N next articles.
 If N is a negative number, pipe the N previous articles.
 If N is nil and any articles have been marked with the process mark,
 pipe those articles instead.
-If HEADERS (the symbolic prefix) is given, force including all headers."
+The default command to which articles are piped is specified by the
+variable `gnus-summary-pipe-output-default-command'; if it is nil, you
+will be prompted for the command.
+
+The properties `:decode' and `:headers' that are put to the function
+symbol `gnus-summary-save-in-pipe' control whether this function
+decodes articles and what headers to keep (see the doc string for the
+`gnus-default-article-saver' variable).  If SYM (the symbolic prefix)
+is neither omitted nor the symbol `r', force including all headers
+regardless of the `:headers' property.  If it is the symbol `r',
+articles that are not decoded and include all headers will be piped
+no matter what the properties `:decode' and `:headers' are."
   (interactive (gnus-interactive "P\ny"))
   (require 'gnus-art)
-  (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
-    (if headers
-	(let ((gnus-save-all-headers t)
-	      (headers (get gnus-default-article-saver :headers)))
-	  (unwind-protect
-	      (progn
-		(put gnus-default-article-saver :headers nil)
-		(gnus-summary-save-article arg t))
-	    (put gnus-default-article-saver :headers headers)))
-      (gnus-summary-save-article arg t)))
-  (let ((buffer (get-buffer "*Shell Command Output*")))
-    (when (and buffer
-	       (not (zerop (buffer-size buffer))))
-      (gnus-configure-windows 'pipe))))
+  (let* ((articles (gnus-summary-work-articles n))
+	 (result-buffer "*Shell Command Output*")
+	 (all-headers (not (memq sym '(nil r))))
+	 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
+	 (raw (eq sym 'r))
+	 (headers (get 'gnus-summary-save-in-pipe :headers))
+	 command result)
+    (unless (numberp (car articles))
+      (error "No article to pipe"))
+    (setq command (gnus-read-shell-command
+		   (concat "Shell command on "
+			   (if (cdr articles)
+			       (format "these %d articles" (length articles))
+			     "this article")
+			   ": ")
+		   gnus-summary-pipe-output-default-command))
+    (when (string-equal command "")
+      (error "A command is required"))
+    (when all-headers
+      (put 'gnus-summary-save-in-pipe :headers nil))
+    (unwind-protect
+	(while articles
+	  (gnus-summary-goto-subject (pop articles))
+	  (save-window-excursion (gnus-summary-save-in-pipe command raw))
+	  (when (and (get-buffer result-buffer)
+		     (not (zerop (buffer-size (get-buffer result-buffer)))))
+	    (setq result (concat result (with-current-buffer result-buffer
+					  (buffer-string))))))
+      (put 'gnus-summary-save-in-pipe :headers headers))
+    (unless (zerop (length result))
+      (if (with-current-buffer (get-buffer-create result-buffer)
+	    (erase-buffer)
+	    (insert result)
+	    (prog1
+		(and (= (count-lines (point-min) (point)) 1)
+		     (progn
+		       (end-of-line 0)
+		       (<= (current-column)
+			   (window-width (minibuffer-window)))))
+	      (goto-char (point-min))))
+	  (message "%s" (substring result 0 -1))
+	(message nil)
+	(gnus-configure-windows 'pipe)))))
 
 (defun gnus-summary-save-article-mail (&optional arg)
   "Append the current article to a Unix mail box file.