* gnus-art.el (gnus-default-article-saver): Add gnus-summary-save-in-pipe to
authorKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 2 Jul 2008 11:47:36 +0000 (11:47 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 2 Jul 2008 11:47:36 +0000 (11:47 +0000)
 choices.
(gnus-summary-save-in-pipe): Add :decode and :headers properties;
 use gnus-summary-pipe-output-default-command as the default command.
(gnus-summary-pipe-to-muttprint): Update gnus-summary-muttprint-program instead
 of gnus-last-shell-command.

* gnus-sum.el (gnus-summary-pipe-output-default-command): New user option.
(gnus-summary-muttprint-program): Mention the value will be changed.
(gnus-summary-save-article): Force showing of all headers.
(gnus-summary-pipe-output): Work with the 2nd argument HEADERS.

lisp/ChangeLog
lisp/gnus-art.el
lisp/gnus-sum.el

index 1b9bbfb..0ce3f48 100644 (file)
@@ -1,4 +1,19 @@
-2008-07-01  Rupert Swarbrick <rswarbrick@googlemail.com>  (tiny change)
+2008-07-02  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * gnus-art.el (gnus-default-article-saver): Add
+       gnus-summary-save-in-pipe to choices.
+       (gnus-summary-save-in-pipe): Add :decode and :headers properties; use
+       gnus-summary-pipe-output-default-command as the default command.
+       (gnus-summary-pipe-to-muttprint): Update gnus-summary-muttprint-program
+       instead of gnus-last-shell-command.
+
+       * gnus-sum.el (gnus-summary-pipe-output-default-command): New user
+       option.
+       (gnus-summary-muttprint-program): Mention the value will be changed.
+       (gnus-summary-save-article): Force showing of all headers.
+       (gnus-summary-pipe-output): Work with the 2nd argument HEADERS.
+
+2008-07-01  Rupert Swarbrick  <rswarbrick@googlemail.com>  (tiny change)
 
        * gnus-score.el (gnus-score-find-trace): Add "Total score" line.
 
index 2dc95ea..a8db53f 100644 (file)
@@ -552,13 +552,15 @@ Gnus provides the following functions:
 * gnus-summary-save-in-vm (use VM's folder format)
 * gnus-summary-write-to-file (article format -- overwrite)
 * gnus-summary-write-body-to-file (article body -- overwrite)
+* gnus-summary-save-in-pipe (article format)
 
 The symbol of each function may have the following properties:
 
 * :decode
 The value non-nil means save decoded articles.  This is meaningful
 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
-`gnus-summary-write-to-file', and `gnus-summary-write-body-to-file'.
+`gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
+`gnus-summary-save-in-pipe'.
 
 * :function
 The value specifies an alternative function which appends, not
@@ -581,6 +583,7 @@ headers should be saved."
                (function-item gnus-summary-save-in-vm)
                (function-item gnus-summary-write-to-file)
                (function-item gnus-summary-write-body-to-file)
+               (function-item gnus-summary-save-in-pipe)
                (function)))
 
 (defcustom gnus-article-save-coding-system
@@ -3936,39 +3939,43 @@ The directory to save in defaults to `gnus-article-save-directory'."
                  gnus-current-headers nil 'gnus-newsgroup-last-directory))
   (gnus-summary-save-body-in-file filename t))
 
+(put 'gnus-summary-save-in-pipe :decode t)
+(put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
 (defun gnus-summary-save-in-pipe (&optional command)
   "Pipe this article to subprocess."
-  (setq command
-       (cond ((and (eq command 'default)
-                   gnus-last-shell-command)
-              gnus-last-shell-command)
-             ((stringp command)
-              command)
-             (t (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"))
-                 gnus-last-shell-command))))
-  (when (string-equal command "")
-    (if gnus-last-shell-command
-       (setq command gnus-last-shell-command)
-      (error "A command is required")))
-  (gnus-eval-in-buffer-window gnus-article-buffer
+  (let ((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))))
+    (when (string-equal command "")
+      (if default
+         (setq command default)
+       (error "A command is required"))))
+  (gnus-eval-in-buffer-window gnus-save-article-buffer
     (save-restriction
       (widen)
       (shell-command-on-region (point-min) (point-max) command nil)))
-  (setq gnus-last-shell-command command))
+  (setq gnus-summary-pipe-output-default-command command))
 
 (defun gnus-summary-pipe-to-muttprint (&optional command)
   "Pipe this article to muttprint."
   (setq command (read-string
                 "Print using command: " gnus-summary-muttprint-program
                 nil gnus-summary-muttprint-program))
-  (gnus-summary-save-in-pipe command))
+  (let ((gnus-last-shell-command gnus-last-shell-command))
+    (gnus-summary-save-in-pipe command)
+    (setq gnus-summary-muttprint-program gnus-last-shell-command)))
 
 ;;; Article file names when saving.
 
index ba29ba6..7efd9d7 100644 (file)
@@ -1242,8 +1242,19 @@ that were fetched.  Say, for nnultimate groups."
   :group 'gnus-summary
   :type '(choice boolean regexp))
 
+(defcustom gnus-summary-pipe-output-default-command nil
+  "Command (and optional arguments) used to pipe article to subprocess.
+This will be used as the default command if it is non-nil.  The value
+will be updated if you modify it when executing the command
+`gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
+  :version "23.1" ;; No Gnus
+  :group 'gnus-summary
+  :type '(radio (const :tag "None" nil) (string :tag "Command")))
+
 (defcustom gnus-summary-muttprint-program "muttprint"
-  "Command (and optional arguments) used to run Muttprint."
+  "Command (and optional arguments) used to run Muttprint.
+The value will be updated if you modify it when executing the command
+`gnus-summary-muttprint'."
   :version "22.1"
   :group 'gnus-summary
   :type 'string)
@@ -11583,7 +11594,7 @@ will not be marked as saved."
                                              gnus-display-mime-function))
                (gnus-article-prepare-hook (when decode
                                             gnus-article-prepare-hook)))
-           (gnus-summary-select-article t nil nil article)
+           (gnus-summary-select-article t t nil article)
            (gnus-summary-goto-subject article)))
        (with-current-buffer save-buffer
          (erase-buffer)
@@ -11608,12 +11619,19 @@ 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), include the headers, too."
+If HEADERS (the symbolic prefix) is given, force including all headers."
   (interactive (gnus-interactive "P\ny"))
   (require 'gnus-art)
-  (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
-       (gnus-save-all-headers (or headers gnus-save-all-headers)))
-    (gnus-summary-save-article arg t))
+  (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))))