Re: Adding a new accidental style

2019-04-14 Thread Thomas Morley
Am So., 14. Apr. 2019 um 17:22 Uhr schrieb Edward Lilley :
>
> Dear all,
>
> I am trying extend Lilypond in Scheme to add a new accidental
> style. What I am currently stuck on is how to add a new item to the
> "accidental-styles" alist in such a way that it is visible to the
> \accidentalStyle command.
>
> I have a file called "hist-accidentals.scm" that contains the following:
>
> > (define-public (hist-accidental-rule context pitch barnum measurepos)
> >   "An accidental rule that only typesets sharps and flats, indicating
> >   relative alteration compared to the key signature."
> >   (let* ((keysig (ly:context-property context 'localAlterations))
> >   (entry (find-pitch-entry keysig pitch #t #t)))
> >   (if (not entry)
> >   (cons #f #f)
> >   (let* ((global-entry (find-pitch-entry keysig pitch #f #f))
> >   (key-acc (key-entry-alteration global-entry))
> >   (acc (ly:pitch-alteration pitch))
> >   (entrymp (key-entry-measure-position entry))
> >   (entrybn (key-entry-bar-number entry)))
> >   (cons #f (not (or (equal? acc key-acc)
> >   (and (equal? entrybn barnum) (equal?
> >   entrymp measurepos)
> >
> > (set! accidental-styles
> > (cons hist #f
> > (Staff ,(make-accidental-rule 'same-octave 0))
> > (Staff ,(make-accidental-rule 'same-octave 1)
> > hist-accidental-rule)))
> > accidental-styles))
>
> (currently the contents of "hist-accidental-rule" is just a copy of the
> "teaching" accidental style)
>
> At the top of the relevant lilypond file, I load the scheme file with
>
> > #(load "hist-accidentals.scm")
>
> But when I come to write
>
> > \accidentalStyle hist
>
> later on, lilypond complains with "warning: unknown accidental style:
> hist". How do I modify variables defined using "define-public"? Or, what
> should I be doing instead?
>
> Thanks,
> Edward

Hi,

please attach the file in future: From here it looks like the syntax
is messed up for brackets/semiquotes and unquotes.
It's not unheard some email-client done such things, though ...

Anyway, below should do:

(set! accidental-styles
  (cons
`(hist #f
   (Staff ,(make-accidental-rule 'same-octave 0))
   (Staff ,(make-accidental-rule 'same-octave 1)
  ,hist-accidental-rule))
accidental-styles))

Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Adding a new accidental style

2019-04-14 Thread Edward Lilley
Dear all,

I am trying extend Lilypond in Scheme to add a new accidental
style. What I am currently stuck on is how to add a new item to the
"accidental-styles" alist in such a way that it is visible to the
\accidentalStyle command.

I have a file called "hist-accidentals.scm" that contains the following:

> (define-public (hist-accidental-rule context pitch barnum measurepos)
>   "An accidental rule that only typesets sharps and flats, indicating
>   relative alteration compared to the key signature."
>   (let* ((keysig (ly:context-property context 'localAlterations))
>   (entry (find-pitch-entry keysig pitch #t #t)))
>   (if (not entry)
>   (cons #f #f)
>   (let* ((global-entry (find-pitch-entry keysig pitch #f #f))
>   (key-acc (key-entry-alteration global-entry))
>   (acc (ly:pitch-alteration pitch))
>   (entrymp (key-entry-measure-position entry))
>   (entrybn (key-entry-bar-number entry)))
>   (cons #f (not (or (equal? acc key-acc)
>   (and (equal? entrybn barnum) (equal?
>   entrymp measurepos)
> 
> (set! accidental-styles
> (cons hist #f
> (Staff ,(make-accidental-rule 'same-octave 0))
> (Staff ,(make-accidental-rule 'same-octave 1)
> hist-accidental-rule)))
> accidental-styles))

(currently the contents of "hist-accidental-rule" is just a copy of the
"teaching" accidental style)

At the top of the relevant lilypond file, I load the scheme file with

> #(load "hist-accidentals.scm")

But when I come to write

> \accidentalStyle hist

later on, lilypond complains with "warning: unknown accidental style:
hist". How do I modify variables defined using "define-public"? Or, what
should I be doing instead?

Thanks,
Edward



-- 

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user