LeoJS - How To Write To File System And Run External Programs

102 views
Skip to first unread message

Thomas Passin

unread,
Jan 3, 2024, 4:56:12 PMJan 3
to leo-editor
Now That leoJS is getting into pretty good shape - and Felix must need a month's vacation! - I am thinking about plugins and scripts that can do things that are easy to do from within Leo. Specifically, scripts that can read and write files from the file system, and files that do the equivalent of subprocess.run() or subprocess.Popen().  In addition (or maybe it's in the same group), scripts that launch a web browser on a specified file.

Is there somewhere we can read up on these things, that is, how a leoJS script can do them in javascript/typescript?

Félix

unread,
Jan 3, 2024, 7:12:26 PMJan 3
to leo-editor
I'm going to take a coding break by doing a tutorial exactly about that!

Thomas Passin

unread,
Jan 3, 2024, 7:18:33 PMJan 3
to leo-editor
Yay!

Félix

unread,
Mar 9, 2024, 9:46:57 PMMar 9
to leo-editor
I'm still working on this! Thanks for your patience :) 
 
(The latest LeoJS 0.2.12 release is the result of trying to capture many features for that video tutorial, and realizing that they needed a bit of polishing!)

Félix

Thomas Passin

unread,
Mar 9, 2024, 10:20:38 PMMar 9
to leo-editor
I don't know if you got around to thinking about it yet (you've got so much else going on!), but the command I wrote to run external files is in LeoPyRef and it's called execute-external-file.  It has some trickiness because it has to run on Linux as well as Windows, and the terminal commands to launch programs differ among the distros. The code has to try some empirical hacks to figure it all out. But it ought to port to TS pretty easily, I would think.

Félix

unread,
Mar 11, 2024, 1:01:43 AMMar 11
to leo-editor
>  execute-external-file


I'll check it out :)

Félix

Félix

unread,
Mar 31, 2024, 4:25:38 PMMar 31
to leo-editor
The video tutorial is now available! :)


I'll address the specific issue about starting sub processes shortly when I do the  'execute-external-file'  function in LeoJS.

Félix

HaveF HaveF

unread,
Apr 1, 2024, 12:38:14 AMApr 1
to leo-e...@googlegroups.com
The video tutorial is now available! :)

Félix, Nice video, I like it! 

Félix

unread,
Apr 1, 2024, 12:58:35 PMApr 1
to leo-editor
Thanks! I just realized that the scripts samples have many use cases but no 'explicit' examples of How To Write To File System And Run External Programs per say. (although some access files to read from them) So I'll add to the script samples repository shortly to remedy this situation.
Reply all
Reply to author
Forward
0 new messages