On Sun, Nov 12, 2023 at 7:55 PM 翅膀 <[email protected]> wrote:

> i create a @button  node ,  and write some python script.  for example
>
> ```
> n = c.find_h("some_node")[0]
> open("xxx.md","wb").write(c.b.encode("utf-8"))
> ```
>
> now i can click button to execute above script.
>
> But how can i config sth to automatically execute the scripte   when i
> save (ctrl+s)  the leo file.
>

Good question. I've waited until now so I could give a proper answer.

Recent revs document two new event handlers
<https://leo-editor.github.io/leo-editor/writingPlugins.html#summary-of-event-handlers>
:

- *after-reading-external-file*
- *before-writing-external-file*

A plugin or script could register these handlers.

You could also use two other event handlers:

- *save1*  (before saving a .leo file)
- *save 2* (after)

Finally, you might find these handlers useful:

- *command1* (before executing any Leo command)
- *command2* (after)

HTH.  Please feel free to ask other questions.

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/CAMF8tS2jk31KbYT-bNWAJ87aLs%2BQ3AX%2B_7eysj8PS3nqqrmGsw%40mail.gmail.com.

Reply via email to