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-29 Katsumi Yamaoka <yamaoka@jpl.org>
+
+ * 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 <yamaoka@jpl.org>
* lpath.el: No need to fbind ns-focus-frame.
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)
(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.