@end lilypond
+@item teaching
+
+@funindex teaching
+@cindex teaching accidental style
+@cindex accidental style, teaching
+
+This rule is intended for students, and makes it easy to create
+scale sheets with automagically created cautionary accidentals.
+Accidentals are printed like with @code{modern}, but cautionary
+accidentals are added for all sharp or flat tones specified by the
+key signature, except if the note is immediately repeated.
+
+@lilypond[quote]
+musicA = {
+ <<
+ \relative c' {
+ cis'8 fis, d'4 <a cis>8 f bis4 |
+ cis2. <c, g'>4 |
+ }
+ \\
+ \relative c' {
+ ais'2 cis, |
+ fis8 b a4 cis2 |
+ }
+ >>
+}
+
+musicB = {
+ \clef bass
+ \new Voice {
+ \voiceTwo \relative c' {
+ <fis, a cis>4
+ \change Staff = up
+ cis'
+ \change Staff = down
+ <fis, a>
+ \change Staff = up
+ dis' |
+ \change Staff = down
+ <fis, a cis>4 gis <f a d>2 |
+ }
+ }
+}
+
+\new PianoStaff {
+ <<
+ \context Staff = "up" {
+ \key fis \minor
+ #(set-accidental-style 'teaching)
+ \musicA
+ }
+ \context Staff = "down" {
+ \key fis \minor
+ #(set-accidental-style 'teaching)
+ \musicB
+ }
+ >>
+}
+@end lilypond
+
+
+
@item no-reset
@funindex no-reset
(cons #f (not (or (equal? acc key-acc)
(and (equal? entrybn barnum) (equal? entrymp measurepos)))))))))
+(define-public (teaching-accidental-rule context pitch barnum measurepos)
+ "an accidental rule that typesets a cautionary accidental
+ if it is included in the key signature AND does not directly follow
+ a note on the same staff-line."
+ (let* ((keysig (ly:context-property context 'localKeySignature))
+ (entry (find-pitch-entry keysig pitch #t #t)))
+ (if (equal? #f entry)
+ (cons #f #f)
+ (let* ((global-entry (find-pitch-entry keysig pitch #f #f))
+ (key-acc (if (equal? global-entry #f)
+ 0
+ (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)))))))))
(define-public (set-accidentals-properties extra-natural
auto-accs auto-cauts
,(make-accidental-rule 'any-octave 0)
,(make-accidental-rule 'same-octave 1))
pcontext))
+
+ ;; same as modern, but cautionary accidentals are printed for all sharp or flat
+ ;; tones specified by the key signature.
+ ((equal? style 'teaching)
+ (set-accidentals-properties #f
+ `(Staff ,(make-accidental-rule 'same-octave 0))
+ `(Staff ,(make-accidental-rule 'same-octave 1)
+ ,teaching-accidental-rule)
+ context))
;; do not set localKeySignature when a note alterated differently from
;; localKeySignature is found.