On Sun, 2024-01-21 at 12:58 +0000, Richard Shann wrote: > ps I haven't had a chance to investigate your script yet, I'll try to > get to it as you said there was some undesirably hard coded value in > it. I've done some tinkering with your script for StaffIncipit. There is no obvious way to compute how much space LilyPond will use to typeset the incipit, but I've put in a simple heuristic in this version. And I've taken the notes to be used in the incipit from the selection. A suitable clef etc would need to be (temporarily) inserted to include in the selection. Repeating the command allows you to refine the incipit length and executing it without a selection allows you to delete it.
8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8>< ;;;StaffIncipit (let ((tag "StaffIncipit")(lily "")(incipitLength 15)(indent "20.0") (indentLength 20) (items 0) (lengthInput "15")) (define (accum) (let ((this (d-GetLilyPond))) (set! items (1+ items)) (if this (set! lily (string-append lily this))))) (if (d-IsInSelection) (begin (SingleAndSelectionSwitcher accum) ;;;avoid mis-matched curly braces in lily (let ((open (string-count lily #\{))(close (string-count lily #\}))) (let loop ((count (- open close))) (if (> count 0) (begin (set! lily (string-append lily "}")) (loop (1- count)))))) (set! lengthInput (d-DirectiveGet-voice-data tag)) (if (not lengthInput) (set! lengthInput (number->string (+ 5 (* 3 items))))) ;;;heuristic to guess length (set! lengthInput (d-GetUserInput (_ "Incipit") (_ "Give incipit length for lily staff:") lengthInput)) (if (and (string? indent) (string->number lengthInput)) (set! incipitLength (string->number lengthInput))) (d-DirectivePut-voice-data tag lengthInput) (d-DirectivePut-voice-postfix tag (string-append "\\incipit { " lily " }")) (d-DirectivePut-layout-postfix tag (string-append " incipit-width = " (number->string incipitLength) "\n")) (set! indent (d-DirectiveGet-score-data "ScoreIndent")) (if (and (string? indent) (string->number indent)) (begin (set! indentLength (string->number indent)) (if (> incipitLength indentLength) (d-ScoreIndent (+ incipitLength indentLength)))))) (begin (if (d-Directive-voice? tag) (begin (d-DirectiveDelete-voice tag) (d-WarningDialog (_ "Staff Incipit Deleted"))) (d-WarningDialog (_ "Cursor not in selection")))))) 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8>< If there are no problems with this I could include it in the staff menu. I'm not too sure how to explain what it is for/does - someone just asked on the mailing list whether those special note heads (Petrucci?) etc can be altered ... Richard