Note: It's important to remember that a good speech interface selects or operates on a region. Most people are familiar with commands that operate on a region. What's not common is commands that select a region. For example a command "select last sentence" turns last sentence into a region. Emacs has the simplest version of this which is things like select word, line, sentence, paragraph etc. While having commands that identify and select regions are clearly essential for speech interface, I believe that similar commands for keyboards would also be a huge win over the current navigate by character/line commands.
why are doc strings preferred to@doc/@code pairing?
Back when I used cweb, I really like the ability produce a document that was also executable. Leo, doesn't really do that.
it's not really literate programming.
The process of getting started with writing scripts/plug-ins is, to me quite overwhelming because there is a huge surface area and I think the api documentation could be better conveyed by inverting the way it is expressed.
Also, some redundancy would be helpful. For example, if you read the writing plug-in section, you find the statement Plugins do not have automatic access to c, g and p. And even though I have been reading the documentation and I knew about c, g, and p, in that moment I had no idea what they meant or where to find them.
I went back and reread the first section looking for clues and found Writing plugins is like writing any other Leo script. See Scripting Leo with Python. In particular: and that is where I found: Three predefined symbols, c, g and p give Leo scripts easy access to all the data in the outline. These symbols also allow Leo scripts to execute any code in Leo’s own code base which told me enough to keep reading the plug-ins document but not enough to do anything with it. Putting that short description in the plug-ins document would've allowed for uninterrupted reading.
Coming back to what I meant by inverting the way it is expressed, don't tell the developer what they can do, start from their perspective and help them find what they need to do to solve their problem. Guide them in terms of what are the common models of accessing information within a Leo environment.
From my trying to learn Leo, the impression I have is that command/operations are either restricted in scope to a single node or deal with a hierarchy of information from a given node. When do you choose? Are there more models for accessing information within Leo? I don't need to know the details (just yet). I need to know the terrain, the higher level map before I can orient myself enough to understand and make sense of the detail.
Day-to-day, I use maybe a half a dozen commands in Leo.
Mostly it's to navigate and create nodes within the hierarchy. To be honest, it took me a while before I figured out where the command to indent/out dent code was located.
Think about the number of times you click on a top menu bar item then he hit a submenu which is another submenu which brings up a dialog box with tabs. That's a deep interface and also one is really difficult to discover.
If you think it would be a benefit, I would take the time to write down the kind of commands I need day-to-day for programming
Example of a command I need for speech interface is the Emacs mark and point.
But with speech, I can say "leave Mark" and then move the mouse to someplace else and speak a command that operates on a region.
Note: It's important to remember that a good speech interface selects or operates on a region. Most people are familiar with commands that operate on a region. What's not common is commands that select a region. For example a command "select last sentence" turns last sentence into a region. Emacs has the simplest version of this which is things like select word, line, sentence, paragraph etc.
If I was to try and implement a mark and point method of selecting a region, I would have no idea where to begin
and the amount of what I need to understand in order to implement this would be discouraging enough that I probably wouldn't try and would eventually migrate back to Emacs.
In general however for programmers of any physical ability, I think would be really helpful to have a "best practices" guide for writing code in Leo.
When I import Python code from another developer it looks like you have a rough form of a best practices encoded in the importer code but it did some things that I didn't expect but they make sense so I'm going back over my code to see what I can change to match what your import did.
When I try to find out what any command does, there is so much shorthand that it takes a long time for me to figure out what I need to know.
My preference would be something like the Emacs M-x some-command interface because it's easier to work with in my speech toolkit than keyboard shortcuts.
That last point is really important one for people with working hands to understand. For most of us with a programming triggered hand injury, we have to be very careful where we use our hands because it's a limited resource.
I could say more but the important thing to take away is how design decisions you make, not just in Leo but in any software, runs the risk of isolating someone that doesn't have full physical abilities.
My impression is that literate programming in the sense of mixing docs.
and code has really fallen out of favor for things like software, but
is very popular for analysis exercises, as in R-markdown with knitr
and also Jupyter notebooks. In these cases it's not just
docs / code / docs / code / docs ... but
docs / code / table / docs / code / plot / ...
I'm actually fiddling with this project:
https://github.com/tbnorth/pypanart which tries to get a Python only (no R) pipeline
On Wed, May 24, 2017 at 9:25 AM, Eric S. Johansson <ynotla...@gmail.com> wrote:why are doc strings preferred to@doc/@code pairing?Because docstrings are preferred to comments in python.Back when I used cweb, I really like the ability produce a document that was also executable. Leo, doesn't really do that.That's news to me :-)
it's not really literate programming.I agree. Imo, Leo redefines LP. As I write in the history of Leo, "Late in 1997 I wrote a Print command to typeset an outline. Printing (Weaving) is supposedly a key feature of literate programming. Imagine my surprise when I realized that such a “beautiful” program listing was almost unintelligible; all the structure inherent in the outline was lost! I saw clearly that typesetting, no matter how well done, is no substitute for explicit structure."
Also, some redundancy would be helpful. For example, if you read the writing plug-in section, you find the statement Plugins do not have automatic access to c, g and p. And even though I have been reading the documentation and I knew about c, g, and p, in that moment I had no idea what they meant or where to find them.It's hopeless to redefine c, g and p everywhere. You are just going to have to learn what they mean.
I went back and reread the first section looking for clues and found Writing plugins is like writing any other Leo script. See Scripting Leo with Python. In particular: and that is where I found: Three predefined symbols, c, g and p give Leo scripts easy access to all the data in the outline. These symbols also allow Leo scripts to execute any code in Leo’s own code base which told me enough to keep reading the plug-ins document but not enough to do anything with it. Putting that short description in the plug-ins document would've allowed for uninterrupted reading.Except that the definitions interrupt the reading.
Coming back to what I meant by inverting the way it is expressed, don't tell the developer what they can do, start from their perspective and help them find what they need to do to solve their problem. Guide them in terms of what are the common models of accessing information within a Leo environment.General complaints are much less helpful than specific suggestions. Lewis Neal has done a great job of small but incredibly useful improvements. Perhaps you two could work together.
From my trying to learn Leo, the impression I have is that command/operations are either restricted in scope to a single node or deal with a hierarchy of information from a given node. When do you choose? Are there more models for accessing information within Leo? I don't need to know the details (just yet). I need to know the terrain, the higher level map before I can orient myself enough to understand and make sense of the detail.The map doesn't exist. Commands do what they do, based on what they are trying to do. Some commands toggle settings. Others print messages. Others alter the tree. Others traverse the tree.
Day-to-day, I use maybe a half a dozen commands in Leo.Good idea. Don't try to learn everything. Neither Terry nor myself knows all the details.
Mostly it's to navigate and create nodes within the hierarchy. To be honest, it took me a while before I figured out where the command to indent/out dent code was located.Select the lines, then do Tab or Shift-Tab.
If you think it would be a benefit, I would take the time to write down the kind of commands I need day-to-day for programmingPlease do that. They all belong in Leo's cheat sheet.
Example of a command I need for speech interface is the Emacs mark and point.You can do this with shift arrow keys, but that may not be easy for you. I use Ctrl-Home and Ctrl-End all the time. They greatly reduce my use of the mouse.But with speech, I can say "leave Mark" and then move the mouse to someplace else and speak a command that operates on a region.Please file an enhancement request. Leo already has an exchange-point-mark command, but it's probably only part of the solution.
Note: It's important to remember that a good speech interface selects or operates on a region. Most people are familiar with commands that operate on a region. What's not common is commands that select a region. For example a command "select last sentence" turns last sentence into a region. Emacs has the simplest version of this which is things like select word, line, sentence, paragraph etc.Leo has similar commands.If I was to try and implement a mark and point method of selecting a region, I would have no idea where to beginBegin by studying LeoPy.leo:
Code-->Command classes-->
@file ../commands/editCommands.py-->
class EditCommandsClass-->move cursor... (leoEditCommands)
and the amount of what I need to understand in order to implement this would be discouraging enough that I probably wouldn't try and would eventually migrate back to Emacs.Just file an enhancement request. I can write and test the code in an hour.
In general however for programmers of any physical ability, I think would be really helpful to have a "best practices" guide for writing code in Leo.Imo, nobody gets much out of documentation. Instead, it's much easier to study code in Leo outlines.
I can say this after spending a month wrestling with the npyscreen code. I imported the code in to Leo, and after that I just read the code. The cff command is an amazing tool for comprehension. Use it, and stop worrying about docs.When I import Python code from another developer it looks like you have a rough form of a best practices encoded in the importer code but it did some things that I didn't expect but they make sense so I'm going back over my code to see what I can change to match what your import did.I wouldn't be so quick to do that. leoPy.leo, not imported code, contains my version of best practices. They are easily stated: use separate nodes for classes, functions and methods.
Importers don't always follow my preferred style because of technical issues. In particular, I always use sections for lengthy lists of python import statements, but importers don't do that.Important: In my early days of Leo, I broke lengthy code into sections, using section references instead of functions. Today, I despise that style. Using sections for programming is a truly bad idea. Never do that in new code. The exception is for languages like html and markdown that have no functions or classes.
When I try to find out what any command does, there is so much shorthand that it takes a long time for me to figure out what I need to know.Start with the basics. Write a script that uses c, g and p. After that, you just have to read, read, read what's already there. Start with the cheat sheet, then the various tutorials. Expect to read everything 2 to 10 times. Don't assume complex things can be made easy. You have to do the work. Many have. Many haven't.
I'm glad you wrote this long letter. Surely I do have some blind spots regarding commands and key combinations. Any suggestions you have will help us both.
On Wed, May 24, 2017 at 2:53 PM, Eric S. Johansson <ynotla...@gmail.com> wrote:
> There are two types of structure. One is the structure of code in hierarchy and organization of entities, another is the hierarchy expressed in Leo. But in writing there is the structure of the narrative, the plot line of characters.
Therehave been lengthy, ongoing discussions about thedifficulties of using, say, the rst3 command, to document code.Neither clones nor bookmarks suffice to "access" code, comments or any other "narrative item"embeddeda Leo outline.
The general solution is a custom script that "picksout" the desired data,creating either an @rst tree or, say, an @auto-md tree. Whatgets "pickedout" from an outline requires some kind of additional markup that you (your script) supplies.
def request(self, Ajax_URL, Ajax_mode ="GET", arg_dict=None):
> What I'm looking for is [links to definitions].
Yes, that would be useful, in specific places.
> For me the the way I would want information about Leo plug-ins is this:
> How do I access the contents of the node?
> How do I change the contents of a node?
> How do I store context dependent information for later use?
These are all basic operations on p. p.h is the headline, p.b is the body text. p.u is the user attributes (uA).
> How do I invoke my code on an event such as doing something before or after saving?
Define event handlers, as describedhere, in thewriting plugins chapter.
> How do I tell Leo to save the results of my code interpreting the contents of the node rather than the contents of a node
I don't understand this question.
uA["color"]="red"
uA["car"]="ford"
uA["wheel"]="round"
On my $color $car, I have $wheel wheels
On my red car, I have round wheels
>> Select the lines, then do Tab or Shift-Tab.
> I hope you understand why that's not really a good solution for speech recognition. :-) ...
Actually, I don't understand.
> Leave Mark
> jump to end of block
> indent region
> Or, a better form would be:
> Indent block
> I'll explain what I mean by block in a different note.
Leo already can do almost all of this. For specific tweaks you could define @commands.
> But with speech, I can say "leave Mark" and then move the mouse to someplace else and speak a command that operates on a region.
You can probably do this in Leo.
> I also added a second enhancement request for having a series of commands "<jump|push> to <beginning | start | finish | end> of line".
How do you think Leo implements Ctrl-Home and Ctrl-End? These bindings aren't built into Leo! Instead, there are commands that are bound to Ctrl-Home, Ctrl-End and many other sequences.
Here's how to find them. Do a regex search for ctrl.home in leoSettings.leo You will find:
beginning-of-buffer = Ctrl-Home
This is in a node called (not very helpfully) Changes. The parent is
@keys EKR bindings. Look inthese nodes:
@shortcuts Arrow keys and the <return> key
@shortcuts Changes
@shortcuts Cursor Moves
You will see that Leo already hasall the standard Emacs commands related to cursor movement, with the possible exception of the Emacs mark command. But don't be so sure about that. Leo knows the about selections, and the direction of selections (point and mark).
> If the guideline is a page or two long, it helps a lot. Voluminous documentation just doesn't work.
Leo has several summaries. Start with the cheat sheet.> Are you familiar with the learning technique of explaining what you learned to a novice?
I explain things to Rebecca :-)
> I apologize for it being so long because I really didn't have time to write a short one.Lack of time is a feeble excuse.