Function: gnus-summary-pipe-output

gnus-summary-pipe-output is an interactive and byte-compiled function defined in gnus-sum.el.gz.

Signature

(gnus-summary-pipe-output &optional N SYM)

Documentation

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. 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.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(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.
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") gnus-summary-mode)
  (require 'gnus-art)
  (let* ((articles (gnus-summary-work-articles n))
	 (result-buffer shell-command-buffer-name)
	 (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 (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 (gnus-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)))))