exec python code from myLeoSettings at startup and on reload-settings

50 views
Skip to first unread message

gar

unread,
Nov 30, 2020, 3:52:09 PM11/30/20
to leo-editor
Still working on "myLeoIDE" mode.
The idea with making command files and loading them with import gave my alot of benefits. The code of commands became much cleaner.
I'd love to go further more and load and configure all stuff at startup, so commands could use simple "import"s w/o glue code. But cannot understand how to instruct myLeoSettings to execute code when it is first read. And reload it on "reload-settings".
Give me a clue if this is possible at all.

tbp1...@gmail.com

unread,
Nov 30, 2020, 5:31:01 PM11/30/20
to leo-editor
I think there would need ot be a new type of setting: @execute.  You would probably need to code it yourself :)

gar

unread,
Dec 1, 2020, 12:21:01 AM12/1/20
to leo-e...@googlegroups.com
i was sleepeing and had a dream... maybe pligins can help
afau plugins are loaded exactly at startup, so I can place there whatever I want
but need to investigatу - do they have access to myLeoSettings
outline, do their imports affect python loader which serves leo gui
etc
but plugin can become the simplest solution
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "leo-editor" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/leo-editor/Hxuah9SduKU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> leo-editor+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/leo-editor/af1c1e48-b592-42b0-a324-2b3d9c356470n%40googlegroups.com.
>

Edward K. Ream

unread,
Dec 1, 2020, 5:11:03 AM12/1/20
to leo-editor
On Mon, Nov 30, 2020 at 11:21 PM gar <gar...@gmail.com> wrote:
i was sleepeing and had a dream... maybe plugins can help

afau plugins are loaded exactly at startup, so I can place there whatever I want
but need to investigatу - do they have access to myLeoSettings
outline, do their imports affect python loader which serves leo gui
etc
but plugin can become the simplest solution

Plugins can do anything. Easily. At any time.

Any plugin may register a hook to be run at the desired time. See the events section of Leo's Writing Plugins chapter.

Edward

Edward K. Ream

unread,
Dec 5, 2020, 3:28:32 PM12/5/20
to leo-editor
On Mon, Nov 30, 2020 at 2:52 PM gar <gar...@gmail.com> wrote:

> cannot understand how to instruct myLeoSettings to execute code when it is first read. And reload it on "reload-settings".

This is a big security problem, but it is possible.

See @bool scripting-at-script-nodes = False

True: dynamically executes script in @script nodes when a window is created.  DANGEROUS!

To be clear, this is dangerous because it will execute any @script node.

If you want both flexibility and security, you could create a plugin that executes known scripts at various times. See this page of the Writing Plugins chapter.

Edward

gar

unread,
Dec 6, 2020, 2:52:09 PM12/6/20
to leo-e...@googlegroups.com
Edward, thank you very much for that tip. For at least now dangerous
script execution is enough for my. Developing a plugin is pretty
expensive for my liking. Until I occasionally format my disk c: - I
prefer to play russian roulette for a while.

2020-12-05 23:28 GMT+03:00, Edward K. Ream <edre...@gmail.com>:
> On Mon, Nov 30, 2020 at 2:52 PM gar <gar...@gmail.com> wrote:
>
>> cannot understand how to instruct myLeoSettings to execute code when it
>> is first read. And reload it on "reload-settings".
>
>
> This is a big security problem, but it is possible.
>
> See @bool scripting-at-script-nodes = False
>
> True: dynamically executes script in @script nodes when a window is
> created. DANGEROUS!
>
> To be clear, this is dangerous because it will execute *any* @script node.
>
> If you want both flexibility and security, you could create a plugin that
> executes *known* scripts at various times. See this page
> <http://leoeditor.com/writingPlugins.html#handling-events> of the Writing
> Plugins <http://leoeditor.com/writingPlugins.html> chapter.
>
> 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 leo-editor+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/leo-editor/CAMF8tS2__SkWRsBw1kW0SD4W2AvMP9QCK_L33sByRpQtbVcEGg%40mail.gmail.com.
>

Edward K. Ream

unread,
Dec 6, 2020, 4:45:23 PM12/6/20
to leo-editor
On Sun, Dec 6, 2020 at 1:52 PM gar <gar...@gmail.com> wrote:
Edward, thank you very much for that tip. For at least now dangerous
script execution is enough for my. Developing a plugin is pretty
expensive for my liking. Until I occasionally format my disk c: - I
prefer to play russian roulette for a while.

Fair enough. However, Leo has hooks/events for almost any need. It's just a matter of a few lines of code to write a plugin that handles those events.

Edward
Reply all
Reply to author
Forward
0 new messages