Nicolas Sceaux wrote:
Indeed that would be great if \with could be used inside a existing
context:
  \context Staff {
    BLI
    \with { Stem \set #'thickness = #4 }
      { BLA }
    BLU
  }

I'm not convinced! Since the curly braces are used for so many different purposes, I think it's much harder to detect the '}' that ends a certain set of property settings than to find the \revert command. If you think the setting and reverting involves too much typing, just declare some identifiers to use as short-cuts.



> It would be possible to add a hack that translates


 >      \context Staff \with { Stem \set #'thickness = #4 }
 >          { BLA }

> to

 >      \context Staff {
 >         \property Staff.Stem \override #'thickness = #4
 >                   BLA
 >         \property Staff.Stem \revert #'thickness
 >      }

> for existing Staff contexts.

[digression, don't have to be read]

That behaviour reminds me lisp macros.
Ie a special kind of "function" that can take a body of code as
argument, without evaluating it, in order to compute more elaborated
code. Ah, if only lilypond syntax were more lispy... adding such a
feature would be so trivial (in approximative guile scheme):

(defmacro* with-properties (context properties #:rest body)
(let ((prop-vals (group properties 2)))
`(sequential
,@(map (lambda (prop-val)
`(context-property-override ,context ,(car prop-val)
,(cadr prop-val)))
prop-vals)
,@body
,@(map (lambda (prop-val)
`(context-property-revert ,context ,prop-val))
(map car prop-vals)))))


then:

(context Staff
  BLI
  (with-properties Staff (stem-thickness 4
                          slur-transparent #t)
    BLA)
  BLU)

== macro expansion of with-properties ==>

(context Staff
  BLI
  (sequential
    (context-property-override Staff stem-thickness 4)
    (context-property-override Staff slur-transparent #t)
    BLA
    (context-property-revert Staff stem-thickness)
    (context-property-revert Staff slur-transparent))
  BLU)

Again, I think you are biased since you are used to LISP. I'm afraid this would scare most people and here we have the same problem with the ending parenthesis used for many different purposes.

/Mats



_______________________________________________
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user

Reply via email to