lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read multiple lines from an input-pipe


From: Urs Liska
Subject: Re: Read multiple lines from an input-pipe
Date: Wed, 30 Apr 2014 10:26:29 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

Am 30.04.2014 10:15, schrieb Urs Liska:
Am 30.04.2014 10:00, schrieb David Kastrup:
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).


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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]