lilypond-user
[Top][All Lists]
Advanced

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

Re: Text listing output in .txt file


From: David Kastrup
Subject: Re: Text listing output in .txt file
Date: Wed, 02 Aug 2017 20:33:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> Nevertheless here some coding, returning at least a little tracking info.
> Though, it's a crude coding and expensive, use at own risk ;)
>
> \version "2.19.64"
>
> remark =
> #(define-music-function (strg)(string?)
> #{
>   \withMusicProperty #'remark #strg <>
> #})
>
> %% writes remarks to <your-file-name>-remarks.txt
> writeRemark =
> #(define-void-function (mus)(ly:music?)
>   (music-map
>     (lambda (m)
>       (if (and (music-is-of-type? m 'event-chord)
>                (ly:music-property m 'remark #f))
>           (let* ((log-file
>                   (format #f "~a-remarks.txt" (ly:parser-output-name)))
>                  (port (open-file  log-file "a"))
>                  (origin (ly:music-property m 'origin)))
>             (format #t "\nRemark from ~a written to: ~a" origin log-file)
>             (format port "\n~a:\t~a" origin (ly:music-property m 'remark))
>             (close port)
>             m)
>           m))
>      mus)
>   mus)
>
> \writeRemark
>   {
>       \remark text
>     c4 d e f
>     \remark more-text
>     g a b c
>     \remark "further text: pitch is d, length 4"
>     d e f g
>   }

A few comments: it seems overkill to produce an actual music expression
here when the purpose is to correlate input position with remarks.

While it has the advantage of only writing out expressions put into
\writeRemark, there cannot be any location different from the current
input location anyway.  And that's available as (*location*) in a scheme
function already and passing it through a music expression will just
lead to duplicates or omissions (depending on how often the music
expression is placed in a \writeRemark).

-- 
David Kastrup



reply via email to

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