Hi Michael, On Sun, Apr 16, 2023 at 5:00 AM Michael Dietz <[email protected]> wrote:
> Hi Lilypond users, > > I had an issue with a file which repeatedly crashed my computer. It took > all memory. The error is clearly on the user’s side: I had this line in > a file (let’s say) choir.ly: > > \include choir.ly > > So LilyPond recursively included this file over and over again until the > RAM was full. > > That leads me to my question: Could lilypond catch this user error and > (a) know that it included it already and skip over the \include command > the second time or (b) warn the user and stop compiling the file (or any > other reasonable approach) to help the user? Found a bit in the LSR a while back that addresses this. In a brief test it seems to do the trick. >From http://lsr.di.unimi.it/LSR/Item?id=894 % includeOnce: include a file only if it hasn't already been included. % Usage: \includeOnce "my_file.ily" % By Marnen Laibow-Koser <[email protected]> % Based on http://lsr.di.unimi.it/LSR/Snippet?id=657 % and % http://lilypond.1069038.n5.nabble.com/conditional-include-td140471.html includeOnce = #(define-void-function (filename) (string?) (if (not (defined? (string->symbol filename))) (begin (ly:parser-include-string (string-concatenate (list "\\include \"" filename "\""))) (primitive-eval (list 'define (string->symbol filename) #t))))) Hopefully that'll help out. Michael
