How to execute my script when save outline.leo

55 views
Skip to first unread message

翅膀

unread,
Nov 12, 2023, 8:55:36 PM11/12/23
to leo-editor
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
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. 

Edward K. Ream

unread,
Nov 22, 2023, 11:47:58 AM11/22/23
to leo-e...@googlegroups.com
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
Good question. I've waited until now so I could give a proper answer.

Recent revs document two new 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

Ray wang

unread,
Dec 1, 2023, 9:33:03 AM12/1/23
to leo-editor
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
thanks for your help.  i ' ll try it  later.  
Reply all
Reply to author
Forward
0 new messages