Hello cord,

note that \fromproperty is a markup command, which is interpreted later with 
the right context. The output-filename does not actually want a markup, so 
you’d need to be careful here.

If you really want to do this you can extract values from the top level header 
or from the header of the current book or bookpart (if present):

#(define (from-header symbol)
   (let* ((book-header
           (if $current-book (ly:book-header $current-book) #f))
          (bookpart-header
           (if $current-bookpart (ly:book-header $current-bookpart) #f))
          (headers (list bookpart-header book-header $defaultheader))
          (headers (filter (lambda (x) x) headers))
          (headers-alist (headers-property-alist-chain headers)))
     (ly:chain-assoc-get (symbol-concatenate 'header: symbol) headers-alist)))

This will do the trick:

\header {
  title = "title"
}

#(display (from-header 'title))
#(newline)

\book {
  \header {
    title = "title2"
  }
  #(display (from-header 'title))
  #(newline)
  \bookpart {
    \header {
      title = "title3"
    }
    #(display (from-header 'title))
    #(newline)
  }
}

But keep in mind that this depends on the order of execution:

\header {
  title = "title"
}

#(display (from-header 'title))

works out,

#(display (from-header 'title))

\header {
  title = "title"
}

does not. So you need to gurantee that this function is always called after 
you define your header!

Cheers,
Valentin

Am Samstag, 4. Mai 2024, 10:58:28 MESZ schrieb corde...@disroot.org:
> Hello everyone,
> 
> Is there a simple way to have the output-filename as a variable (the title
> of the main header)?
> 
> This one doesn’t recognise the property as a string:
> 
> \paper {
>       output-filename = \fromproperty #'header:title
> }
> 
> Thank you all,
> cord

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

Reply via email to