Re: Adding to header using module-define! and alist with markups

2021-12-03 Thread Nate Whetsell
臘‍♂️

That did it, thank you!

> On Dec 3, 2021, at 12:07 PM, Jean Abou Samra  wrote:
> 
> Le 03/12/2021 à 18:04, Nate Whetsell a écrit :
>> Thanks for your help!
>> 
>> Using \justify as
>> 
>> ```
>> \paper {
>>  scoreTitleMarkup = \markup {
>>\column {
>>  \fromproperty #'header:piece
>>  \justify { #'header:instruction }
>>}
>>  }
>> }
>> ```
>> 
>> may be on the right track, but this results in (for all cases):
>> 
>> ```
>> test.ly :7:17: error: not a markup
>>  \justify {
>> #'header:instruction }
>> ```
>> 
>> Hopefully I’m missing something simple.
> 
> \justify { \fromproperty #'header:instruction } ?
> 
> Best,
> Jean
> 




Re: Adding to header using module-define! and alist with markups

2021-12-03 Thread Jean Abou Samra

Le 03/12/2021 à 18:04, Nate Whetsell a écrit :

Thanks for your help!

Using \justify as

```
\paper {
 scoreTitleMarkup = \markup {
   \column {
     \fromproperty #'header:piece
     \justify { #'header:instruction }
   }
 }
}
```

may be on the right track, but this results in (for all cases):

```
test.ly :7:17: error: not a markup
     \justify {
                #'header:instruction }
```

Hopefully I’m missing something simple.


\justify { \fromproperty #'header:instruction } ?

Best,
Jean




Re: Adding to header using module-define! and alist with markups

2021-12-03 Thread Nate Whetsell
Thanks for your help!

Using \justify as

```
\paper {
 scoreTitleMarkup = \markup {
   \column {
 \fromproperty #'header:piece
 \justify { #'header:instruction }
   }
 }
}
```

may be on the right track, but this results in (for all cases):

```
test.ly:7:17: error: not a markup
 \justify { 
#'header:instruction }
```

Hopefully I’m missing something simple.

> On Dec 2, 2021, at 11:35 AM, David Kastrup  wrote:
> 
> Nate Whetsell mailto:nathan.whets...@gmail.com>> 
> writes:
> 
>> Thanks, but unfortunately using a backtick and commas seems to produce the 
>> same output. If it’s helpful, here’s the same example with a backtick and 
>> commas:
>> 
>> ```
>> \version "2.22.0"
>> 
>> \paper {
>> scoreTitleMarkup = \markup {
>>   \column {
>> \fromproperty #'header:piece
>> \justify-field #'header:instruction
>>   }
>> }
>> }
> 
> Well, \justify-field just takes a string, like \justify-string does.
> Maybe it should check for markup lists and pass them through \justify .
> 
> -- 
> David Kastrup



Re: Adding to header using module-define! and alist with markups

2021-12-02 Thread David Kastrup
Nate Whetsell  writes:

> Thanks, but unfortunately using a backtick and commas seems to produce the 
> same output. If it’s helpful, here’s the same example with a backtick and 
> commas:
>
> ```
> \version "2.22.0"
>
> \paper {
>  scoreTitleMarkup = \markup {
>\column {
>  \fromproperty #'header:piece
>  \justify-field #'header:instruction
>}
>  }
> }

Well, \justify-field just takes a string, like \justify-string does.
Maybe it should check for markup lists and pass them through \justify .

-- 
David Kastrup



Re: Adding to header using module-define! and alist with markups

2021-12-02 Thread Nate Whetsell
Thanks, but unfortunately using a backtick and commas seems to produce the same 
output. If it’s helpful, here’s the same example with a backtick and commas:

```
\version "2.22.0"

\paper {
 scoreTitleMarkup = \markup {
   \column {
 \fromproperty #'header:piece
 \justify-field #'header:instruction
   }
 }
}

#(define instructions `(
 ; Using a LilyPond code block does not work.
 (1 . ,#{
   \markup {
 "Does not work"
 \score {
   \new Staff { c'1 }
   \layout { ragged-right = ##t indent = 0 }
 }
   }
 #})
 ; Using the Scheme form of a markup expression does not work.
 (2 . ,(markup #:line (#:simple "Does not work")))
 ; Using a string works.
 (3 . "Works")))

\book {
 #(do ((study-number 1 (1+ study-number)))
 ((> study-number 3))
   (let ((header (make-module)))
 (module-define! header 'piece (number->string study-number))
 (let* (
 (instruction (assoc study-number instructions))
 (score (scorify-music #{ { c'1 } #})))
   (begin
 (if instruction (module-define! header 'instruction (cdr instruction)))
 (ly:score-set-header! score header)
 (add-score score)
}
```

> On Dec 2, 2021, at 11:02 AM, David Kastrup  wrote:
> 
> Nate Whetsell mailto:nathan.whets...@gmail.com>> 
> writes:
> 
>> I’m trying to programmatically add items to score headers from an alist. 
>> This works when an item consists of just a string. I can’t seem to get this 
>> to work when an item is a markup, no matter how the markup is entered. Is 
>> there some way to store markups in an alist, and then use those markups in a 
>> header?
>> 
>> Below is an example illustrating the issue I’m having. Any help would be 
>> greatly appreciated!
>> 
>> Thanks,
>> Nate
>> 
>> ```
>> \version "2.22.0"
>> 
>> \paper {
>>  scoreTitleMarkup = \markup {
>>\column {
>>  \fromproperty #'header:piece
>>  \justify-field #'header:instruction
>>}
>>  }
>> }
>> 
>> #(define instructions '(
>>  ; Using a LilyPond code block does not work.
>>  (1 . #{
>>\markup {
>>  "Does not work"
> 
> ' introduces a non-evaluated constant expression but you need to
> evaluate #{ ... #} to get a markup.  So try
> 
> #(define instructions `( ;; note backtick instead of forward tick
>  (1 . ,#{   ;; note comma to evaluate one part of the
> ;; quasi-quoted list
> 
> -- 
> David Kastrup



Re: Adding to header using module-define! and alist with markups

2021-12-02 Thread David Kastrup
Nate Whetsell  writes:

> I’m trying to programmatically add items to score headers from an alist. This 
> works when an item consists of just a string. I can’t seem to get this to 
> work when an item is a markup, no matter how the markup is entered. Is there 
> some way to store markups in an alist, and then use those markups in a header?
>
> Below is an example illustrating the issue I’m having. Any help would be 
> greatly appreciated!
>
> Thanks,
> Nate
>
> ```
> \version "2.22.0"
>
> \paper {
>   scoreTitleMarkup = \markup {
> \column {
>   \fromproperty #'header:piece
>   \justify-field #'header:instruction
> }
>   }
> }
>
> #(define instructions '(
>   ; Using a LilyPond code block does not work.
>   (1 . #{
> \markup {
>   "Does not work"

' introduces a non-evaluated constant expression but you need to
evaluate #{ ... #} to get a markup.  So try

#(define instructions `( ;; note backtick instead of forward tick
  (1 . ,#{   ;; note comma to evaluate one part of the
 ;; quasi-quoted list

-- 
David Kastrup



Adding to header using module-define! and alist with markups

2021-12-02 Thread Nate Whetsell
I’m trying to programmatically add items to score headers from an alist. This 
works when an item consists of just a string. I can’t seem to get this to work 
when an item is a markup, no matter how the markup is entered. Is there some 
way to store markups in an alist, and then use those markups in a header?

Below is an example illustrating the issue I’m having. Any help would be 
greatly appreciated!

Thanks,
Nate

```
\version "2.22.0"

\paper {
  scoreTitleMarkup = \markup {
\column {
  \fromproperty #'header:piece
  \justify-field #'header:instruction
}
  }
}

#(define instructions '(
  ; Using a LilyPond code block does not work.
  (1 . #{
\markup {
  "Does not work"
  \score {
\new Staff { c'1 }
\layout { ragged-right = ##t indent = 0 }
  }
}
  #})
  ; Using the Scheme form of a markup expression does not work.
  (2 . (markup #:line (#:simple "Does not work")))
  ; Using a string works.
  (3 . "Works")))

\book {
  #(do ((study-number 1 (1+ study-number)))
  ((> study-number 3))
(let ((header (make-module)))
  (module-define! header 'piece (number->string study-number))
  (let* (
  (instruction (assoc study-number instructions))
  (score (scorify-music #{ { c'1 } #})))
(begin
  (if instruction (module-define! header 'instruction (cdr 
instruction)))
  (ly:score-set-header! score header)
  (add-score score)
}
```