On Thu, Aug 18, 2016 at 6:44 AM, <[email protected]> wrote: > If I write add a node name "@function say_hi( name)", node content like > "ret > > u > r > n "Hi " + name + " !" ", I can invoke it like below: > > @func > t > ion say_hi("zenkoo"), finally the text is "Hi zenkoo!". If leo has this > feature, that is very cool. >
Thanks for this question. It's interesting. Afaik, there is nothing exactly like this in Leo. First, let me warn you that certain solutions might have serious security consequences. For example, you could define functions in nodes using @script <http://leoeditor.com/scripting-miscellany.html#modifying-plugins-with-script-scripts>. It doesn't seem well documented, but @script is a security concern, and so is disabled by default. Second, scripts may define code that can be used later as follows: exec(g.findTestScript(c,'my_commands')) << code that uses my_commands >> Again, this could be a security concern because this script is executing unknown code (the code in the node whose headline is "my_commands"). In general, however, it is not necessary to do what you are asking, for several reasons: 1. Typically, code of whatever kind (plugins, modules, scripts) can use Python's import command to import common code. 2. For complex Leo scripts, I recommend a top-level that looks something like this: << imports >> @others # defines Controller class in subtree x = Controller(c) x.run() This is a simple, flexible, powerful pattern that can be used to define huge scripts. In short, your question is interesting, but I'm not aware of any real reason to want to do what you are asking. Feel free to ask more 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 post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
