Re: Differentiate between including and direct compiling a file

2021-11-08 Thread Fr. Samuel Springuel


> On Aug 7, 2021, at 3:54 PM, Aaron Hill  wrote:
> 
> Perhaps something like this:
> 
> 
> \version "2.22.0"
> 
> ifCompiledDirectly =
> #(define-scheme-function (scm) (scheme?)
>  (let ((file (car (ly:input-file-line-char-column (*location*)
>   (if (member file (command-line)) scm)))
> 
> \ifCompiledDirectly \markup "Compiled directly..."
> \ifCompiledDirectly \score { { b'4 4 2 } }
> 
> 
> The logic is simple: check to see if the command-line arguments contain the 
> name of the file being processed.

Is there a way to apply this to variable definitions?  I.e. have a variable be 
defined only if the file is being compiled directly?

Alternatively, is there a way to force LilyPond to stop reading a file at a 
certain point (i.e. some equivalent to TeX’s `\endinput`) that could be used in 
combination with the negative of this so that the example occurs after this 
command?

✝✝
Fr. Samuel, OSB
(R. Padraic Springuel)
St. Anselm’s Abbey
4501 South Dakota Ave, NE
Washington, DC, 20017
202-269-2300
(c) 202-853-7036

PAX ☧ ΧΡΙΣΤΟΣ




Re: Differentiate between including and direct compiling a file

2021-08-07 Thread Aaron Hill

On 2021-08-07 11:52 am, R. Padraic Springuel wrote:

Is there a way for Lilypond to differentiate between a file which is
being compiled directly and it being included in the compilation of
another file?  Something equivalent to `if __name__ == “__main__”`
from python?  I’d like to add simple examples to my various tools that
I can use to test it (both during original development and after an
update which breaks something) and remind me of what the tool does
when I haven’t used it in a while. Ideally, I’d hide these examples
inside a construction like this so that the example output is only
produced when the tool file is compiled directly.


Perhaps something like this:


\version "2.22.0"

ifCompiledDirectly =
#(define-scheme-function (scm) (scheme?)
  (let ((file (car (ly:input-file-line-char-column (*location*)
   (if (member file (command-line)) scm)))

\ifCompiledDirectly \markup "Compiled directly..."
\ifCompiledDirectly \score { { b'4 4 2 } }


The logic is simple: check to see if the command-line arguments contain 
the name of the file being processed.



-- Aaron Hill



Differentiate between including and direct compiling a file

2021-08-07 Thread R. Padraic Springuel
Is there a way for Lilypond to differentiate between a file which is being 
compiled directly and it being included in the compilation of another file?  
Something equivalent to `if __name__ == “__main__”` from python?  I’d like to 
add simple examples to my various tools that I can use to test it (both during 
original development and after an update which breaks something) and remind me 
of what the tool does when I haven’t used it in a while. Ideally, I’d hide 
these examples inside a construction like this so that the example output is 
only produced when the tool file is compiled directly. 

✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️✝️
Fr. Samuel, OSB
(R. Padraic Springuel)
St. Anselm’s Abbey 
4501 South Dakota Ave, NE
Washington, DC, 20017
202-269-2300
(c) 202-853-7036

PAX ☧ ΧΡΙΣΤΟΣ