On 5/13/20, Paul McKay <plm...@gmail.com> wrote: > If I'm writing music in F, then I suggest that I be able to use *bF* as a > pitch instead of *bf*. The *F* would indicate that all subsequent *b*s > would be flattened until one is encountered with a different accidental or > until the end of the current music expression.
Interesting. It’s never been The LilyPond Way® too assume what the user means (much like you wouldn’t expect a simple notepad to fix your spelling for you, although I’m sure Microsoft has thought of it at some point). Something similar to what you’re suggesting could be implemented without modifying the parser, for example with a fairly simple music function or a Scheme engraver: %%%% persistentAccidentals = #(define-music-function (music) (ly:music?) (let ((alt-alist '()) (m (ly:music-deep-copy music))) (music-map (lambda (note) (let ((pitch (ly:music-property note 'pitch)) (force? (ly:music-property note 'force-accidental))) (if (ly:pitch? pitch) (let* ((alt (ly:pitch-alteration pitch)) (n (ly:pitch-notename pitch)) (o (ly:pitch-octave pitch)) (mem-alt (assoc-get n alt-alist))) (if (eq? force? #t) (set! alt-alist (assoc-remove! alt-alist n)) (if (= alt 0) (if mem-alt (ly:music-set-property! note 'pitch (ly:make-pitch o n mem-alt))) (set! alt-alist (assoc-set! alt-alist n alt)))))) note)) m) m)) \persistentAccidentals \relative c' { c des e fis g f e f! e d' g, d } %%%% #(define Persistent_accidentals_translator (lambda (context) (let ((alt-alist '())) (make-engraver (listeners ((note-event engraver event) (let ((note (ly:prob-property event 'music-cause))) (if (ly:music? note) (let ((pitch (ly:music-property note 'pitch)) (force? (ly:music-property note 'force-accidental))) (if (ly:pitch? pitch) (let* ((alt (ly:pitch-alteration pitch)) (n (ly:pitch-notename pitch)) (o (ly:pitch-octave pitch)) (mem-alt (assoc-get n alt-alist))) (if (eq? force? #t) (set! alt-alist (assoc-remove! alt-alist n)) (if (= alt 0) (if mem-alt (ly:music-set-property! note 'pitch (ly:make-pitch o n mem-alt))) (set! alt-alist (assoc-set! alt-alist n alt)))))) note))))))))) \score { \new Staff \relative c' { c des e fis g f e f! e d' g, d } \layout { \context { \Voice \consists #Persistent_accidentals_translator } } } %%%% V.