[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Read multiple lines from an input-pipe
From: |
David Kastrup |
Subject: |
Re: Read multiple lines from an input-pipe |
Date: |
Wed, 30 Apr 2014 10:00:03 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
Urs Liska <address@hidden> writes:
> I've tried around for quite some time now to no avail, probably having
> tried _everything_ except the right solution ;-) so I have to come
> back here and ask.
>
> I now have this implementation:
>
> #(use-modules (ice-9 popen))
> #(use-modules (ice-9 rdelim))
>
> #(define (strsystem_internal cmd)
> (let* ((port (open-input-pipe cmd))
> (str (read-delimited "" port)))
> (close-pipe port)
> str))
>
> #(define-markup-command (gitCommand layout props cmd) (markup?)
> (let* ((result (string-split
> (strsystem_internal (string-append "git " cmd))
> #\newline)))
> (interpret-markup layout props
> (car result))))
>
> If I feed it a command returning multiple lines, e.g.
>
> \gitCommand "status"
>
> this will create a markup with the first line of "git status"' result.
>
> What way do I have to go to return either a \markuplist with all the
> lines or a number of \markups, one for each line?
You use define-markup-command-list instead of define-markup-command,
interpret-markup-list instead of interpret-markup, and result instead of
(car result).
--
David Kastrup