[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-user
Subject: Re: Read multiple lines from an input-pipe
From: Urs Liska <ul () openlilylib ! org>
Date: 2014-04-30 8:26:29
Message-ID: 5360B3B5.5000301 () openlilylib ! org
[Download RAW message or body]
Am 30.04.2014 10:15, schrieb Urs Liska:
> Am 30.04.2014 10:00, schrieb David Kastrup:
>> Urs Liska <ul@openlilylib.org> 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).
>>
>
> Thank you for that. However,
> (interpret-markup-list layout props result)
> returns all strings concatenated to one line. In the documentation on
> http://www.lilypond.org/doc/v2.18/Documentation/extending/new-markup-list-command-definition.html
> the function
> make-justified-lines-markup-list
> is used. Is there something similar that I can use here?
>
> Urs
>
OK, I found my way through it myself :-) The working code is
#(define-markup-command (gitCommand layout props cmd) (markup?)
(let* ((result (string-split
(strsystem_internal (string-append "git " cmd))
#\newline)))
(interpret-markup layout props
#{ \markup \column #result #})))
Best
Urs
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic