On 20.04.2018 22:52, Thomas Morley wrote:
make-replace-markup

Nice, thanks! I’d not have had any memory of there being such a markup function.

For the record, I attach what I’ll be working with.

Best, Simon
\version "2.19.80"
\include "ly-utility.ily"

#(define modernise-apostrophes? #f)
replaceDoubleApostrophes =
#(define-music-function (mus)(ly:music?)
   (music-map
    (lambda (m)
      (if (music-is-of-type? m 'lyric-event)
          (let ((txt (ly:music-property m 'text))
                (replacement (if modernise-apostrophes? "" "’")))
            (if (string? txt)
                (begin
                 (ly:music-set-property! m 'text
                   (make-replace-markup
                    (list (cons "’’" replacement))
                    txt))
                 m)
                m))
          m))
    mus))
\addToplevelMusicFunctions replaceDoubleApostrophes

<<
  { 4 }
  \addlyrics { test’’ }
>>
\version "2.19.53"

musicFunctionDummy = #(define-music-function (mus) (ly:music?) mus)

addToplevelMusicFunctions =
#(define-scheme-function (names) (symbol-list-or-symbol?)
   (let* ((name-list (if (list? names) names (list names)))
          (lookup-function (lambda (name) (let ((fn (ly:parser-lookup name)))
                                            (if (equal? fn '())
                                                musicFunctionDummy
                                                fn))))
          (fn-list (map lookup-function name-list)))
     (set! toplevel-music-functions (append fn-list toplevel-music-functions))))
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to