Re: how to share @command functionality between nodes?

2016-02-17 Thread Edward K. Ream
On Tue, Feb 16, 2016 at 3:07 PM, jkn  wrote:

For some reason your posting above made a lot more sense after looking at
> leo/scripts/scripts.leo
>
> There are aspects I don't get grok about this but I have enough to play
> with...
>

​It's important to understand that Leo composes external files (@clean,
@file, etc.) the very same way as it composes @button and @command nodes.
So LeoPyRef.leo and LeoPluginsRef.leo are also examples.​


​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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-16 Thread jkn
Thanks Edward

On Monday, February 15, 2016 at 3:55:26 PM UTC, Edward K. Ream wrote:
>
> On Fri, Feb 5, 2016 at 3:20 PM, jkn  
> wrote:
>
>>
>> does the whole body of an @command script have to live within a single 
>> node?
>>
>
> ​Not at all.  @button and @command nodes can use sections and @others.
>
> Indeed, for complex scripts my pattern is:
>
> << imports >>
> @others
> x = Controller().run(p)​
>
> Where child nodes and descendants define the << imports >> section and the 
> Controller class. This class can also be split into pieces using @others.
>
> It's very important to understand that @button and @command nodes may be 
> composed exactly as Leo's own code is. 
>
> Edward
>

For some reason your posting above made a lot more sense after looking at 
leo/scripts/scripts.leo

There are aspects I don't get grok about this but I have enough to play 
with...

Thanks
Jon N
 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-15 Thread Edward K. Ream
On Fri, Feb 5, 2016 at 3:20 PM, jkn  wrote:

>
> does the whole body of an @command script have to live within a single
> node?
>

​Not at all.  @button and @command nodes can use sections and @others.

Indeed, for complex scripts my pattern is:

<< imports >>
@others
x = Controller().run(p)​

Where child nodes and descendants define the << imports >> section and the
Controller class. This class can also be split into pieces using @others.

It's very important to understand that @button and @command nodes may be
composed exactly as Leo's own code is.

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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-09 Thread jkn


On Tuesday, February 9, 2016 at 11:55:40 AM UTC, john lunzer wrote:
>
> Thanks for clearing/summing everything up Terry. It wasn't 70 nodes on the 
> first level, it was 70 children and subchildren. I set up several 
> subclasses of QFrame and handle a whole host of QShortcut key sequences. 
> Like I said, at that level of complexity I should have implemented a 
> plugin, which I still plan to do.
>
> One more thing, Jon, if you do implement a plugin then you would be able 
> to share code in all the usual Python ways, ie, functions, classes, and 
> modules.  
>

Yes, thanks Terry, that was useful as a summary of that approach, even if 
it's not what I will do (yet)...

Also thanks to John for the plugin summary. I have some functionality that 
I may do as a plugin, but this work is very specific to one .leo file which 
is why I want it to live as an @command node(s)

Oh (Jacob/Edward) ... I assume your use of '@common' is a convention within 
your code, ie. '@common' has no code-based meaning within Leo otherwise? I 
see reference to it here:

http://leoeditor.com/unitTesting.html#using-mark-for-unit-tests

but nowhere else.

Regards
Jon N
 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-09 Thread john lunzer
Thanks for clearing/summing everything up Terry. It wasn't 70 nodes on the 
first level, it was 70 children and subchildren. I set up several 
subclasses of QFrame and handle a whole host of QShortcut key sequences. 
Like I said, at that level of complexity I should have implemented a 
plugin, which I still plan to do.

On Monday, February 8, 2016 at 9:29:09 PM UTC-5, Terry Brown wrote:
>
> On Mon, 8 Feb 2016 06:07:33 -0800 (PST) 
> john lunzer  wrote: 
>
> > I'm a little confused by your request and perhaps Jacob answered it 
> > but I feel like I heard a much simpler question. 
> > 
> > You can use the @others directive in the body of you @command node. 
> > This is the same as what you would do in an @ node. 
>
> I think there are two different ideas here: 
>
> @command("command_a") 
>command_a preamble 
>@others 
>first part of command_a 
>second part of command_a 
>first subpart of second part of command_a 
>second subpart of second part of command_a 
>
> so a single command, with structure organized in a tree, vs. 
>
> common_setup 
> some common code 
> @command("command_b") 
> eval(g.findTestScript(c,'common_setup')) 
> command_b stuff 
> @command("command_c") 
> eval(g.findTestScript(c,'common_setup')) 
> command_c stuff 
>
> i.e. two commands sharing code. 
>
> that said, can't imagine how a single command could have 70 child 
> nodes, so maybe I'm not understanding what you were up to John. 
>
> Cheers -Terry terry_...@yahoo.com  
>
> > I have abused this horribly to my own ends to write a complex 
> > refactoring plugin as an @command that has over 70 child nodes. I did 
> > this before I fully understood plugins. 
> > 
> > On Friday, February 5, 2016 at 4:20:23 PM UTC-5, jkn wrote: 
> > > 
> > > I'm getting around to writing some useful @command scripts today, 
> > > and I wondered about what is probably a faq: 
> > > 
> > > does the whole body of an @command script have to live within a 
> > > single node? I have several commands which have common 
> > > functionality, and I want to be able to do the equivalent of 
> > > 'import '. 
> > > 
> > > The Scripting tutorial page tantalises with: "*you can create 
> > > complex scripts from a node and its descendants*", but I think this 
> > > is referring to scripts written to external files. 
> > > 
> > > Apologies if there is (as I suspect) a simple explanation of this 
> > > somewhere. 
> > > 
> > > Thanks 
> > > Jon N 
> > > 
> > 
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-08 Thread 'Terry Brown' via leo-editor
On Mon, 8 Feb 2016 06:07:33 -0800 (PST)
john lunzer  wrote:

> I'm a little confused by your request and perhaps Jacob answered it
> but I feel like I heard a much simpler question.
> 
> You can use the @others directive in the body of you @command node.
> This is the same as what you would do in an @ node.

I think there are two different ideas here:

@command("command_a")
   command_a preamble
   @others
   first part of command_a
   second part of command_a
   first subpart of second part of command_a
   second subpart of second part of command_a

so a single command, with structure organized in a tree, vs.

common_setup
some common code
@command("command_b")
eval(g.findTestScript(c,'common_setup'))
command_b stuff
@command("command_c")
eval(g.findTestScript(c,'common_setup'))
command_c stuff

i.e. two commands sharing code.

that said, can't imagine how a single command could have 70 child
nodes, so maybe I'm not understanding what you were up to John.

Cheers -Terry terry_n_br...@yahoo.com

> I have abused this horribly to my own ends to write a complex
> refactoring plugin as an @command that has over 70 child nodes. I did
> this before I fully understood plugins. 
> 
> On Friday, February 5, 2016 at 4:20:23 PM UTC-5, jkn wrote:
> >
> > I'm getting around to writing some useful @command scripts today,
> > and I wondered about what is probably a faq:
> >
> > does the whole body of an @command script have to live within a
> > single node? I have several commands which have common
> > functionality, and I want to be able to do the equivalent of
> > 'import '.
> >
> > The Scripting tutorial page tantalises with: "*you can create
> > complex scripts from a node and its descendants*", but I think this
> > is referring to scripts written to external files.
> >
> > Apologies if there is (as I suspect) a simple explanation of this 
> > somewhere.
> >
> > Thanks
> > Jon N
> >
> 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-08 Thread john lunzer
I'm a little confused by your request and perhaps Jacob answered it but I 
feel like I heard a much simpler question.

You can use the @others directive in the body of you @command node. This is 
the same as what you would do in an @ node.

I have abused this horribly to my own ends to write a complex refactoring 
plugin as an @command that has over 70 child nodes. I did this before I 
fully understood plugins. 

On Friday, February 5, 2016 at 4:20:23 PM UTC-5, jkn wrote:
>
> I'm getting around to writing some useful @command scripts today, and I 
> wondered about what is probably a faq:
>
> does the whole body of an @command script have to live within a single 
> node? I have several commands which have common functionality,
> and I want to be able to do the equivalent of 'import '.
>
> The Scripting tutorial page tantalises with: "*you can create complex 
> scripts from a node and its descendants*", but I think this
> is referring to scripts written to external files.
>
> Apologies if there is (as I suspect) a simple explanation of this 
> somewhere.
>
> Thanks
> Jon N
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-08 Thread john lunzer
You are correct, the @others is just a node body directive and doesn't 
dictate where or how a file will be stored, only the structure of the file. 

If you're just personal commands which you don't intend on sharing then 
you'll likely just want to keep them in your myLeoSettings.leo file and 
that command will be available with every .leo you ope. Or if they're very 
specific commands directly related to a project you're working on then you 
can put them in a specific .leo file and the command will only be available 
to that .leo file. 

Unless you have a very specific need to keep these files externally I 
wouldn't force the issue.

If you do have a need to access the files externally then it's a probably a 
good idea to write you commands in a plugin and register them as commands 
using the @g.command decorator. It's not a complicated as it sounds. The 
leoPluginsRef.py file has a good smattering of plugins of different 
complexities. 

I believe you just need a very basic init function:

def init ():

   '''Return True if the plugin has loaded successfully.'''

   g.plugin_signon(__name__)
   return True

And then you can create a function with the @g.command decorator preceding 
it and that will register the command for use. Hopefully I'm not missing 
anything.

On Monday, February 8, 2016 at 3:04:57 PM UTC-5, jkn wrote:
>
> Hi John
>
> On Monday, February 8, 2016 at 2:07:33 PM UTC, john lunzer wrote:
>>
>> I'm a little confused by your request and perhaps Jacob answered it but I 
>> feel like I heard a much simpler question.
>>
>> You can use the @others directive in the body of you @command node. This 
>> is the same as what you would do in an @ node.
>>
>> I have abused this horribly to my own ends to write a complex refactoring 
>> plugin as an @command that has over 70 child nodes. I did this before I 
>> fully understood plugins. 
>>
>> On Friday, February 5, 2016 at 4:20:23 PM UTC-5, jkn wrote:
>>>
>>> I'm getting around to writing some useful @command scripts today, and I 
>>> wondered about what is probably a faq:
>>>
>>> does the whole body of an @command script have to live within a single 
>>> node? I have several commands which have common functionality,
>>> and I want to be able to do the equivalent of 'import '.
>>>
>>> The Scripting tutorial page tantalises with: "*you can create complex 
>>> scripts from a node and its descendants*", but I think this
>>> is referring to scripts written to external files.
>>>
>>> Apologies if there is (as I suspect) a simple explanation of this 
>>> somewhere.
>>>
>>> Thanks
>>> Jon N
>>>
>>
> But doesn't @others work (with @file) to create a separate (python) file 
> from the .leo  file that I am working with? That's what I meant when I said 
> "...referring to scripts written to external files". I want to avoid that - 
> I think...
>
> I confess I have done basically nothing with external files in leo, 
> amusing when I originally got here via 'literate programming', tangle/weave 
> etc., which I think is also where Edward started off.
>
> Apologies if my assumptions don't match what you are describing [thinks 
> ... really must try to use @file sometime, in any case].
>
>
> Regards
> Jon
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-08 Thread jkn
Hi John

On Monday, February 8, 2016 at 2:07:33 PM UTC, john lunzer wrote:
>
> I'm a little confused by your request and perhaps Jacob answered it but I 
> feel like I heard a much simpler question.
>
> You can use the @others directive in the body of you @command node. This 
> is the same as what you would do in an @ node.
>
> I have abused this horribly to my own ends to write a complex refactoring 
> plugin as an @command that has over 70 child nodes. I did this before I 
> fully understood plugins. 
>
> On Friday, February 5, 2016 at 4:20:23 PM UTC-5, jkn wrote:
>>
>> I'm getting around to writing some useful @command scripts today, and I 
>> wondered about what is probably a faq:
>>
>> does the whole body of an @command script have to live within a single 
>> node? I have several commands which have common functionality,
>> and I want to be able to do the equivalent of 'import '.
>>
>> The Scripting tutorial page tantalises with: "*you can create complex 
>> scripts from a node and its descendants*", but I think this
>> is referring to scripts written to external files.
>>
>> Apologies if there is (as I suspect) a simple explanation of this 
>> somewhere.
>>
>> Thanks
>> Jon N
>>
>
But doesn't @others work (with @file) to create a separate (python) file 
from the .leo  file that I am working with? That's what I meant when I said 
"...referring to scripts written to external files". I want to avoid that - 
I think...

I confess I have done basically nothing with external files in leo, amusing 
when I originally got here via 'literate programming', tangle/weave etc., 
which I think is also where Edward started off.

Apologies if my assumptions don't match what you are describing [thinks ... 
really must try to use @file sometime, in any case].


Regards
Jon

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: how to share @command functionality between nodes?

2016-02-05 Thread Jacob Peck

At the top of your @command node, you can do something like:


eval(g.findTestScript(c,'@common code'))


Where '@common code' is the name of a node somewhere in your outline.

(Thanks to Edward for that one, 3 years ago now!  Wow, hard to believe 
I've been using Leo that long...)


-->Jake

On 2/5/2016 4:20 PM, jkn wrote:
I'm getting around to writing some useful @command scripts today, and 
I wondered about what is probably a faq:


does the whole body of an @command script have to live within a single 
node? I have several commands which have common functionality,

and I want to be able to do the equivalent of 'import '.

The Scripting tutorial page tantalises with: "*you can create complex 
scripts from a node and its descendants*", but I think this

is referring to scripts written to external files.

Apologies if there is (as I suspect) a simple explanation of this 
somewhere.


Thanks
Jon N
--
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+unsubscr...@googlegroups.com 
.
To post to this group, send email to leo-editor@googlegroups.com 
.

Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


--
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.