lilypond-user
[Top][All Lists]
Advanced

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

## Re: Function operating on header

 From: Aaron Hill Subject: Re: Function operating on header Date: Thu, 12 Mar 2020 19:34:08 -0700 User-agent: Roundcube Webmail/1.4.2

```On 2020-03-12 11:49 am, Noeck wrote:
```
```Thanks Francisco! That's great news!

It also works across separate header blocks and even from within
included files. And it is easier to turn it into a string than for the
\fromproperty mechanism. So this works for me:

\header {
title = "my title"
composer = "will be replaced"
}

% can also be included via \include
\header {
composer = \markup { Composer of \italic
#(string-append "»" (markup->string title) "«") }
% instead of string-append, I can now work with the string
}
% end of include

{ b }
```
```
```
It may be your intention, but markup->string strips out formatting. For markup that is just simple text, you would not notice any loss. But it is best to keep markup as markup in order to preserve formatting. You never know when your simple text today needs to become more complex later.
```
```
Next, why use strings and string-append at all? \markup already supports the ability to concatenate multiple arguments into one. A simple markup list (i.e. #{ \markup { one two three } #}) joins items using word-space to separate them. If no spacing is desired, use \concat. Anything more complex should really be done with custom markup functions, so as to preserve the formatting and flexibility of markup over pure text.
```
```
Finally, \fromproperty is important as it defers the evaluation of the property. Using \title would give you the current value whereas \fromproperty #'header:title can accommodate changes to the property. Consider the following:
```
%%%%
\version "2.20.0"

\header {
title = "Title"
subtitle = \markup { Sub \title }
subsubtitle = \markup { Subsub \fromproperty #'header:title }
}

\header { title = "Title (changed)" }

\markup { Lorem ipsum dolor sit amet }
%%%%

```
In the above, the subtitle does not reflect the change to the title. In general, you should prefer to use \fromproperty so that the order of defining properties does not matter. However, if you can ensure properties are set properly, there should be nothing wrong with using \title directly.
```

-- Aaron Hill

```

reply via email to

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