2014-03-04 10:46 GMT+01:00 David Kastrup <d...@gnu.org>: > Thomas Morley <thomasmorle...@gmail.com> writes:
>> Not sure, if the list picking is really save. > > It should likely test that this is indeed a \line markup rather than > just dissecting anything. While separating out \line seems a bit > one-sided, \line _is_ special in that \markup { a b c } implicitly > engages \line anyway. So it seems like a defensible choice. I think apart from some border-cases, fromproperty-markup needs to be special-cased, because it's argument is a symbol which is looked up in the property settings. Below the revised code, several comments and questions inline. Comments, hints, tests are highly apreciated. \version "2.19.1" #(define-markup-list-command (line-parts layout props args)(markup-list?) (let* ((fromproperty-markup? (lambda (m) (if (procedure? m) (eq? 'fromproperty-markup (procedure-name m)) #f))) (line-markup? (lambda (m) (if (procedure? m) (eq? 'line-markup (procedure-name m)) #f))) (arg (if (not (null? args)) (car args)))) (cond ;; deal with an empty markup-list: ((null? args) (list empty-stencil)) ;; what to do, if (car arg) is not fromproperty/line-markup: ((and (not (null? arg)) ;; hmm, can arg ever be null? (not (fromproperty-markup? (car arg))) (not (line-markup? (car arg)))) (interpret-markup-list layout props args)) ;; fromproperty-markup needs to be special-cased, because it's argument ;; is not a line-markup, but a symbol, looked up in props. ;; ;; hmm, do I need to do: ;; (cons ;; (list (cons symbol `(,property-recursive-markup ,symbol))) ;; props) ;; again? (it's already done in fromproperty-def) ((and (not (null? arg)) ;; hmm, can arg ever be null? (fromproperty-markup? (car arg)) ;; hmm, is the next line superfluous? (not (null? (chain-assoc-get (last arg) props)))) (interpret-markup-list layout props (last (chain-assoc-get (last arg) props)))) ;; what to do with a line-markup: ((and (not (null? arg)) (line-markup? (car arg))) (interpret-markup-list layout props (last arg))) ;; in any other case return empty-stencil. ;; hmm, are other cases thinkable at all? (else (list empty-stencil))))) %%%%%%%%%%%% %% TESTS %%%%%%%%%%%% \paper { bookTitleMarkup = \markup \box \column { \fill-line { \bold \fontsize #4 \fromproperty #'header:dedication } \vspace #2 \fontsize #5 \fill-line { \line-parts { \fromproperty #'header:title } } \fill-line { \abs-fontsize #12 \center-column { \line-parts { \fromproperty #'header:meter } } \null } } oddHeaderMarkup = \markup \column { \abs-fontsize #12 \fill-line { \rounded-box \center-column { \bold \fontsize #4 "page-header-test" \line-parts { \fromproperty #'header:title } \fromproperty #'header:meter } } } } \header { dedication = "TESTING BOOKTITLE" title = \markup { "Aaa" "Bbb" "Ccc" } meter = \markup { \line { \with-color #red \rotate #3 "Crazy" } \line { \rotate #-3 "Whatever" } } } \markup \column { \vspace #2 \box \bold \fontsize #4 "testing toplevel markups:" } testOne = \markup { \fontsize #4 "X|X" \italic "YyyyY" \column { a b } } %% The following two markups should return the same output: \markup \box { \line { \line-parts { \fontsize #4 "X|X" \italic "YyyyY" \column { a b } } } } \markup \box { \line { \line-parts { \testOne } } } %% Testing some use-cases: \markup \box { \fill-line { \line-parts { \testOne } } } \markup \box { \center-column { \line-parts { \testOne } } } %% Should not give an error: \markup \line { \line-parts { } } Cheers, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user