Hello Alec,

note that since 2.24 we have a neat markup function \with-string-transformer, 
which is called whenever a string is found, and does a lot of the logic for 
you (such as making sure this is called upon a string, not a complex markup:

\markup
  \with-string-transformer
  #(lambda (layout props str)
     (if (> (string-length str) 0)
         (let ((last-char (string-ref str (1- (string-length str))))
               (prefix (substring str 0 (1- (string-length str)))))
           (cond
            ((char=? last-char #\#)
             (markup
              #:concat (prefix #:hspace 0.2 #:fontsize -2.5 #:raise 0.6 
#:sharp)))
            ((char=? last-char #\b)
             (markup
              #:concat (prefix #:hspace 0.2 #:fontsize -2.5 #:raise 0.6 
#:flat)))
            (else str)))
         str))
  { "A#" "Bb" }

But then I’d think maybe here it would be useful to have an option for regex 
matching in \replace ...

Cheers,
Valentin

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to