Mercurial > emacs
changeset 86172:e8cb5c919219
(process-lines): Move here from ../admin/admin.el.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 17 Nov 2007 03:42:22 +0000 |
parents | 9ae0e3ae0cca |
children | 4fbadbd4abb0 |
files | lisp/subr.el |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/subr.el Sat Nov 17 02:51:49 2007 +0000 +++ b/lisp/subr.el Sat Nov 17 03:42:22 2007 +0000 @@ -1539,6 +1539,23 @@ ;;;; Process stuff. +(defun process-lines (program &rest args) + "Execute PROGRAM with ARGS, returning its output as a list of lines. +Signal an error if the program returns with a non-zero exit status." + (with-temp-buffer + (let ((status (apply 'call-process program nil (current-buffer) nil args))) + (unless (eq status 0) + (error "%s exited with status %s" program status)) + (goto-char (point-min)) + (let (lines) + (while (not (eobp)) + (setq lines (cons (buffer-substring-no-properties + (line-beginning-position) + (line-end-position)) + lines)) + (forward-line 1)) + (nreverse lines))))) + ;; open-network-stream is a wrapper around make-network-process. (when (featurep 'make-network-process)