This example shows how to extend semantics of leo without writing
plugins, or executing discreet scripts with ctrl+b.
Have a "prelude" node (early in the doc tree) with content like this:
@x {
from leo.external.stringlist import shcmd
# some other python commands
@x }
Then, have a headline like this:
@r shcmd('ls /usr/bin')
Now do alt-x vs-update, and observe as the body of @r node gets
populated with output from that command
Now copy aside the node, perhaps edit it a bit, and give it a
different headline:
@= myfiles
(this assigns body to g.vs.myfiles).
Now, in another node, you can grep for interesting stuff in that node:
@r myfiles.grep('zip')
Note how myfiles object has method "grep". That's because node bodies
are by default captured as leo.external.stringlist.SList objects, doc
here:
http://ipython.scipy.org/moin/Cookbook/StringListProcessing
(yeah, that stuff is familiar from IPython).
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.