comparison lisp/subr.el @ 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 de0ef99eb027
children d6b46513e321
comparison
equal deleted inserted replaced
86171:9ae0e3ae0cca 86172:e8cb5c919219
1536 This makes or adds to an entry on `after-load-alist'. 1536 This makes or adds to an entry on `after-load-alist'.
1537 FILE should be the name of a library, with no directory name." 1537 FILE should be the name of a library, with no directory name."
1538 (eval-after-load file (read))) 1538 (eval-after-load file (read)))
1539 1539
1540 ;;;; Process stuff. 1540 ;;;; Process stuff.
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)))))
1541 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)
1545 (defun open-network-stream (name buffer host service) 1562 (defun open-network-stream (name buffer host service)