By coincidence, I have just been working on a script to run an external 
file (@file, @clean, etc) using an arbitrary program.  My script launches 
the executing program against the saved external file.  I'll look at your 
code later today.  I found three main things to work out:

1. How to specify the external programs.  Python is built into the script.  
Otherwise processors are specified in an .ini file in the same directory as 
the program to be run.  This seems to work well.  It also lets you overrule 
Python with a different version.  I also put any command line arguments in 
the .ini file.  This approach let me avoid having to create new directives, 
specially formatted comments, or special headlines to specify processors 
and arguments.

2. Passing command line arguments in Windows if they need to be quoted 
(because of spaces) *and* the processor's path also has spaces.  The 
problem is there whether you use POpen(), subprocess.run(), or 
os.system().  That is, the problem occurs for me because I want stdout to 
go to a new console window instead of Leo's launching console. That takes 
care of the case when Leo is launched without a console window (so there 
would be nowhere visible for stdout to go).  You have to run a command 
something like this:

start cmd.exe /k "c:\Program Files\julia.exe" "arg one"  "arg two"

This fails with a message that c:\Program can't be run.  The remedy is to 
double the first quote character:

start cmd.exe /k ""c:\Program Files\ruby.exe" "arg one"  "arg two"

This is very obscure!  It took me a long time to get it sorted out. It 
turns out that quotation mark processing with cmd is not what you would 
think.  The first one turns off the usual special  processing for quote 
characters;  the double quote prevents this.

The reason for writing *start* com.exe is only to get a console window.  If 
you don't include start, then the cmd.exe will run in your current Leo 
launching console (if there is one), stdout will appear there, and when 
your program finishes, you will have to type *exit* to get back to Leo's 
launcher.  If you omit both start and cmd.exe, your output will also appear 
in Leo's launcher.

3. In Linux, launching a new console in such a way that stdout output can 
be seen turns out to be tricky, and there is no general solution because 
there are many different systems that use different terminal emulators, 
each of which uses a different set of command line parameters.  And if you 
try something like *x-terminal-emulator*, that can be linked to different 
programs and you don't a priori know how it will behave.
On Tuesday, June 1, 2021 at 6:07:05 AM UTC-4 Edward K. Ream wrote:

> On Tuesday, June 1, 2021 at 5:05:10 AM UTC-5 Edward K. Ream wrote:
>
> > At present, there are settings only for python and rust.
>
> Please feel free to suggest settings for languages such as  go, 
> typescript/js, java, c-sharp, Haskell, etc.
>
> Edward
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/b760e898-9edc-4628-aff0-18932efdfa34n%40googlegroups.com.

Reply via email to