On Feb 13, 6:24 pm, Christopher Barker <[email protected]> wrote:

My apologies for the delay in replying.  Somehow I thought that this
group was unavailable yesterday.

Before I start with detailed responses, I'd like to ask that further
discussion happen on the leo-editor group.  That way all of Leo's
users will get the benefits of our discussion.  They often have ideas
and techniques that never occurred to me.

> ...I couldn't find "swap_mac_keys".

I just checked that this works in the tk gui.  My guess is that you
did a word-only search, or a search that did not include headlines.

Here is the typical search sequence:

1. [Optional, when using wrap-around search] Select the tree at which
you want to commence your search.  This would have been the @settings
node.

2. Ctrl-f brings up the find panel.  Look at the settings.  The Alt-
Ctrl bindings correspond to the accelerators (underlines) on the
panel:

Alt-Ctrl-w toggles the whole word setting
Alt-Ctrl-S toggle the wrap around setting, etc.

3. Type the search string in the minibuffer, and hit <return> to start
the search or Shift-Ctrl-R to enter a replacement string, then
<return>

In particular, you want to be sure to search headlines, because
settings are specified in headlines.

> it's nice to know that Mac support is probably
> only as far away as a Mac user willing to help a bit.

Exactly.

> well, at least good indenting

Indenting python has been good for a long time.  More below.

> Also assorted shortcuts, I write LaTeX a fair

Leo gives you complete control of shortcuts.  Indeed, you can use vim-
like bindings if you like.  And you can bind any shortcut to any of
*your own* commands using @button or @command nodes.

For example, try this:

@button Print Hi @key = Alt-6 (the headline)
print 'hi' (the body pane)

You can click the script-button button (or do alt-x
script<tab><return>) to create the script button.  (This will be done
automatically for you the next time you load the .leo file)  The
@button nodes creates a command called print-hi.  So alt-x print-hi
will execute the code.

> a way to run the code, or built it or whatever.

I discussed @command and @button in detail above because they show how
you can create your own special-purpose mechanisms to do *anything you
want*.  These scripts can be in one place or scattered over
several .leo files, and they can have whatever key bindings you like.

Ctrl-b runs the Python code in any node.  There are many ways to run
code in other processes.  If you like, we can start a discussion of
this on the leo-editor site.  It should be possible to write a 10-line
Python script that runs just about anything, and putting that script
in a common @command node in myLeoSettings.leo make that script (and
its key binding)
available everywhere.

> Almost no editors get [indenting] right.

Yesterday I fixed a bad bug which apparently disabled auto-indenting
when hard tabs are used.  That's now been fixed.

> > Here's what I mean by "right"

> > * The <tab> key means "indent this line as it should be"
> >   - if you are at the beginning of a blank the line,
> >     it puts the cursor at the right indent level.

I added this feature yesterday.  In practice, this case almost never
happens, because Leo auto-indents python properly, increasing the
indentation when a line ends in a colon.

> > if you are in the middle of the line, it indents that line to where
it should be.

I would hate this feature, and with the present indenting scheme it
never seems necessary. I want tabs to produce indentation everywhere.

However, this feature could be supported as a user option.  We would
then need (say) an insert-tab command (with binding, of course) to
override the auto-indentation of the entire line.

> > * if the <backspace> key is pressed in the indentation space, it means:
reduce the indentation level by one.

That's what Leo does.

There are several Leo settings that control indentation.  A case could
be made for Leo *directives* that control fine details of
indentation.  Certainly, this is not needed for Python.

> > Whether an indentation level is a tab or n spaces should be set-able
depending on the type of file and/or personal preference.

It is is settable on a file-by-file basis using @tabwidth.  See below.

> >     @tabwidth 8  # hard tabs, 8 characters wide.
> >     @tabwidth -4 # tab with 4 spaces.

> that looks to be leo-wide.

No.  These are Leo *directives* that go in body text (or headlines).
It's good style to put them in the root @file or @thin or @auto or
@shadow node that corresponds to the external file.

Yesterday I added the @int tab_width = -4 *setting*.  Nobody noticed
its lack, I think, but there is no harm in adding it.

> what if you want different setting for different kinds of files?

You specify @tabwidth for each file.  There is no default for file
extensions.  I suppose there could be, but it hardly matters.

> idea of major-modes and minor modes. Major modes, in particular make it
> easy to have the editor behave quite differently depending on what kind
> of file you are editing.

Leo's directives allow you to do this in a natural way.

> > There doesn't seem to be a setting that sets default tab width.  It
> > appears hard-code at -4.

Now there is:

@int tab_width = 8 # Use tabs for spacing (shown as 8 spaces)
@int tab_width = -4 # Use four spaces for spacing.

> So what does @tabwidth set?

The tabbing kind of the node and all it's descendants, unless over-
ridden by another @tabwidth in a descendant node.

This doesn't appear to be clearly explained in the introductory
material.  I'll fix this soon.

> In the editing window, it's line 21
> when I run it from leo, the error is reported as being at line 24
> when I run it from the command line, it's reported as line 19

This is a consequence of sentinels.  But it doesn't really matter what
the actual value is.  Do alt-g <Leo's line number> return to go to the
proper line.

> I opened a python file, edited it, saved it, and now I have no idea how
> to get the edited version! It saved a workbook.leo file, but didn't
> touch the python file.

If you created, say, an @auto or @file node, you will save the file on
the file system.  Otherwise, your work is in notebook.leo.

> It seems you can't quite use leo as "just a text editor" out of the box.

The new ctrl-O capability just puts a *copy* of the file in a node.
Maybe there should be a command that writes the nodes contents back to
the file from which it came.

We might need a new directive, say @open-path.  Ctrl-O would insert
this directive, write-node-to-file would use this directive to write
the file back.  But I'm uneasy about this.  It's more of a hack than a
feature, and it could cause nasty surprises when moving the .leo file
to another machine.

In short, for quick editing a more typical editor might be more
suitable.  I often use scite in such cases.

But Kent's suggestion is really best.  For files that you want to edit
more than once (and isn't that really *every* file?), using @auto does
the job more easily than emacs.  You can organize your @auto nodes to
make them easily accessible.  You could even write a script to create
an @auto node from the node created by Ctrl-O.  Etc.

> Still on the fence here.....

You'll be happier once the initial confusions get resolved.

Again, I hope we'll continue this discussion on leo-editor.  It
continues to be fruitful and enjoyable.

Edward

Reply via email to