YES. Exactly like that! Thank you.
That solves point 1/ & 2/, and with some minor tweaks, I can hack a
solution for point 3.
%% BEGIN workcase
#(define header-alist
(let* ((defaultheader-entries (ly:module->alist $defaultheader))
(defaults
'("title-default"
"instrument-default"
"tagline-default"
"Copyright unknown"
;; to be continued
))
;; if you want a subset use below
;; otherwise probably (map car defaultheader-entries)
(entries
'(title
instrument
tagline
copyright
;; to be continued
)))
(map
(lambda (e d)
(cons (symbol->string e)
(if (assoc-get e defaultheader-entries)
(markup->string (assoc-get e defaultheader-entries))
d)))
entries
defaults)))
#(define use-alist '(
( "Public Domain" . "Free to duplicate, distribute,
modify, and perform." )
( "Copyright" . "All rights reserved." )
)
)
#(define copyright (assoc-get "copyright" header-alist))
#(if (assoc copyright use-alist)
(define copyrightUse
(cdr (assoc copyright use-alist))
)
(define copyrightUse "Copyright status not defined. Some or all rights
might be reserved.")
)
\header {
title="My own title" % Comment out to see the magic ;)
copyright = "Public Domain" % Comment out or change to "Copyright" to see
the magic ;)
}
\markup \with-color #red #(assoc-get "title" header-alist)
\markup \with-color #red #(assoc-get "copyright" header-alist)
\markup \with-color #red #copyrightUse
\header {
title = #(assoc-get "title" header-alist)
copyright = #(markup (#:concat (copyright "—" copyrightUse)))
}
%% END workcase
GREAT! It works!
A couple of follow-up questions:
Is there a cleaner approach to my second hack (for the copyright notice)?
Is there a Scheme way to set the header variables?
Oh, and one last thing...
Is this code you wrote snippet worthy?
I obviously find it most useful, but I'm personally convinced it could be
of interest to others as well.
On 17 February 2016 at 12:19, Thomas Morley <[email protected]>
wrote:
> #(define license-alist
> (let* ((defaultheader-entries (ly:module->alist $defaultheader))
> (defaults
> '("title-default"
> "instrument-default"
> "tagline-default"
> "copyright-default"
> ;; to be continued
> ))
> ;; if you want a subset use below
> ;; otherwise probably (map car defaultheader-entries)
> (entries
> '(title
> instrument
> tagline
> copyright
> ;; to be continued
> )))
> (map
> (lambda (e d)
> (cons (symbol->string e)
> (if (assoc-get e defaultheader-entries)
> (markup->string (assoc-get e defaultheader-entries))
> d)))
> entries
> defaults)))
>
> %#(display-scheme-music license-alist)
>
> \markup \with-color #red #(assoc-get "title" license-alist)
>
--
We are (...) star stuff contemplating the stars (...) We are one species.
We are star stuff harvesting star light.
-- Carl Sagan
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user