Terry's questions yesterday are important. They deserve a more complete 
answer. This is a Engineering Notebook post.  It will be of interest only 
to Leo's devs. This post will be pre-writing for a closing comment in #589 
<https://github.com/leo-editor/leo-editor/issues/589>.

This post contains only an overview. Later posts (replies) will discuss the 
problems that arose, the choices I made and what I considered and 
rejected.  The code shows only what I did :-) Otoh, the code must stand on 
its own.

*Terminology*: "c" means either the Commands class or an instance of that 
class, depending on context.

*tl:dr:* To the first approximation, this branch merely removes some 
*little-used* names from c's namespace. Names such as c.save can be used 
*exactly 
*as before. Details are encapsulated so they don't matter.

*Background*

Previously, the *@g.command* and *g.new_cmd_decorator* decorators defined 
all (most?) commands.

Various classes define their own *@cmd* decorators. @cmd decorators just 
call g.new_cmd_decorator.

Previously, the @cmd decorator (defined in leoCommands.py) defined all 
commands in the Commands class.

*Overview*

The whole point of this project is that Leo's core and Leo scripts *must* 
be able to access methods such as c.save *exactly *as before.

To the first approximation, the cmds branch does the following, and 
*nothing* else:

1. Defines most (but not all) commander commands *outside of* 
leoCommands.py. The new *@g.commander_command* decorator injects its 
decorated routine into c.

For example, the save *function* in commanderFileCommands.py defines the 
'save-file' command. The decorator injects the save function so that it 
becomes the c.save *method.* Neither Leo's core nor Leo scripts knows that 
c.save is defined outside of c.

2. Removes some of c's old helper methods from c's namespace. In general, 
that's a good thing. It will be easy to restore a helper to c's namespace 
should that be necessary.

3. Generalizes how c.doCommand and c.k.callAltXFunction dispatch commands. 
The rest of Leo is completely unaware of this change.

That's enough for now. Many more details later.

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.

Reply via email to