Function: comint-redirect-results-list-from-process

comint-redirect-results-list-from-process is an autoloaded and byte-compiled function defined in comint.el.gz.

Signature

(comint-redirect-results-list-from-process PROCESS COMMAND REGEXP REGEXP-GROUP)

Documentation

Send COMMAND to PROCESS.

Return a list of expressions in the output which match REGEXP. REGEXP-GROUP is the regular expression group in REGEXP to use.

Source Code

;; Defined in /usr/src/emacs/lisp/comint.el.gz
;;;###autoload
(defun comint-redirect-results-list-from-process (process command regexp regexp-group)
  "Send COMMAND to PROCESS.
Return a list of expressions in the output which match REGEXP.
REGEXP-GROUP is the regular expression group in REGEXP to use."
  (let ((output-buffer " *Comint Redirect Work Buffer*")
	results)
    (with-current-buffer (get-buffer-create output-buffer)
      (erase-buffer)
      (comint-redirect-send-command-to-process command
					       output-buffer process nil t)
      ;; Wait for the process to complete
      (set-buffer (process-buffer process))
      (while (and (null comint-redirect-completed)
		  (accept-process-output process)))
      ;; Collect the output
      (set-buffer output-buffer)
      (goto-char (point-min))
      ;; Skip past the command, if it was echoed
      (and (looking-at (regexp-quote command))
	   (forward-line))
      (while (and (not (eobp))
		  (re-search-forward regexp nil t))
	(push (buffer-substring-no-properties
               (match-beginning regexp-group)
               (match-end regexp-group))
              results)
        (when (zerop (length (match-string 0)))
          ;; If the regexp can be empty (for instance, "^.*$"), we
          ;; don't advance, so ensure forward progress.
	  (forward-line 1)))
      (nreverse results))))