On 09/16/2016 01:10 AM, Urs Liska wrote:

Doesn't a conversion to

#`(id . ,(existing-function))

suffice? Otherwise just follow Carl's suggestion.

Hi Urs, Almost, but you have to add a lambda wrapper to pass along the implicit grob argument, and then there are other more challenging complications if the user has supplied a lambda expression or a variable that may be a string or a procedure. So most of the possibilities are non-trivial to impossible to handle well. See below.

Cheers,
-Paul


\version "2.19.42"

#(define procA (lambda (grob) (display "a ") "myid"))

#(define (procB grob) (display "b ") "myid")

procC = #(lambda (grob) (display "c ") "myid")

procE = "myid"

{
  % ORIGINALS

  \override NoteHead.id = #procA
  c1
  \override NoteHead.id = #procB
  c1
  \override NoteHead.id = \procC
  c1
  \override NoteHead.id = #(lambda (grob) (display "d ") "myid")
  c1
  \override NoteHead.id = \procE
  c1

  % RE-WRITES

  % these are fine (as long as the variable is a procedure):
  \override NoteHead.id = #(lambda (grob) `(id . ,(procA grob)))
  c1
  \override NoteHead.id = #(lambda (grob) `(id . ,(procB grob)))
  c1
  \override NoteHead.id = #(lambda (grob) `(id . ,(procC grob)))
  c1

  % to regex a lambda expression, I think you'd have to count matching
  % parens to arbitrary depth.  Not sure that is possible with regex...
  \override NoteHead.id =
  #(lambda (grob) `(id . ,((lambda (grob) (display "d ") "myid") grob)))
  c1

  % is \procE a string or a procedure?  No way to tell in convert-ly
  % and calling a string as if it were a procedure doesn't work
  % \override NoteHead.id = #(lambda (grob `(id . ,(procE grob))))
  c1
}



_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to