diff options
| author | Glenn Morris | 2007-11-17 03:42:22 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-11-17 03:42:22 +0000 |
| commit | d43c8d03328f16f7b5ac27f46b60911ff483131b (patch) | |
| tree | e0bad7a04f85ed435d2bd13f7dbc7d14db88b737 | |
| parent | efb67a5e8dea3b4bb9af250757a9e97db5c5a9a0 (diff) | |
| download | emacs-d43c8d03328f16f7b5ac27f46b60911ff483131b.tar.gz emacs-d43c8d03328f16f7b5ac27f46b60911ff483131b.zip | |
(process-lines): Move here from ../admin/admin.el.
| -rw-r--r-- | lisp/subr.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index c110390b44a..5a88fa4fd5d 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1539,6 +1539,23 @@ FILE should be the name of a library, with no directory name." | |||
| 1539 | 1539 | ||
| 1540 | ;;;; Process stuff. | 1540 | ;;;; Process stuff. |
| 1541 | 1541 | ||
| 1542 | (defun process-lines (program &rest args) | ||
| 1543 | "Execute PROGRAM with ARGS, returning its output as a list of lines. | ||
| 1544 | Signal an error if the program returns with a non-zero exit status." | ||
| 1545 | (with-temp-buffer | ||
| 1546 | (let ((status (apply 'call-process program nil (current-buffer) nil args))) | ||
| 1547 | (unless (eq status 0) | ||
| 1548 | (error "%s exited with status %s" program status)) | ||
| 1549 | (goto-char (point-min)) | ||
| 1550 | (let (lines) | ||
| 1551 | (while (not (eobp)) | ||
| 1552 | (setq lines (cons (buffer-substring-no-properties | ||
| 1553 | (line-beginning-position) | ||
| 1554 | (line-end-position)) | ||
| 1555 | lines)) | ||
| 1556 | (forward-line 1)) | ||
| 1557 | (nreverse lines))))) | ||
| 1558 | |||
| 1542 | ;; open-network-stream is a wrapper around make-network-process. | 1559 | ;; open-network-stream is a wrapper around make-network-process. |
| 1543 | 1560 | ||
| 1544 | (when (featurep 'make-network-process) | 1561 | (when (featurep 'make-network-process) |