On Monday, August 18, 2014 5:54:01 AM UTC-5, Edward K. Ream wrote:

> At present, when entering command names (but *not* file names) in the 
minibuffer, hitting tab repeatedly cycles through the list of names shown.

> I would like to eliminate this "Easter Egg": it's clearly not needed and 
it greatly complicates truly important code, namely k.getArg.

Terry quite rightly complained that this notice happened way too early in 
the morning :-)

Happily, yesterday's work with k.getArg clarified the code enough that 
there is real hope that tab cycling can be restored better than ever.

The ga.do_tab method shows the way forward.  As mentioned in another 
thread, yesterday's work allows something spectacular--intermixing command 
completion and filename completion on the same command line.  For example::

    <alt-x>:ta<tab><tab><return>

The first tab expands the :ta to :tabnew.

The second tab adds the path to the cwd to the minibuffer.  On my machine 
the minibuffer will look like::

    Enter File Name: c:\leo-repo\leo-editor

ga.do_tab has a special case (hack) to handle the second tab. Details in 
the P.S.

Happily, the special case suggests a way to do tab cycling cleanly.

The special case tests whether there is exactly one completion remaining.  
If so, no tab cycling is possible.

If there are several possible completions, then we aren't going to switch 
to filename completions ;-)

But if there are several possible completion, why not use the *ordered* 
list of completions as a guide?  It may be possible to cycle through the 
various completions using *localized* and *stateless* code. The idea is to 
compare the contents of the minibuffer (ga.get_label) with the list of 
completions. If there is a match, we set the label to the *next* completion 
(modulo the number of completions).

I'll do this if and *only* if a) it can be done cleanly in one place and b) 
it fixes the problems with previous tab cycling.

So yesterday's work has paid off in another way.  This approach would not 
have been visible to me in the old code base.

Edward

P.S. (Engineering Notebook):

Here are the details of the tab hack in ga.do_tab and (mostly) in its 
helper, ga.do_colon_command.

After command completions have been computed, if the command starts with a 
colon and there is exactly one remaining completion, ga.do_colon_command 
calls k.getFileName (yet another state handler!) with a callback.  When 
k.getFileName returns, it calls the callback, which then calls the colon 
command with an event that contains a "get_arg_value" field containing the 
file path.  The vim code for the ":tabnew" command uses this file path if 
it exists, otherwise it calls k.getArg to get it.  Whew.

P.P.S.  (Engineering Notebook):

This morning I cleaned up all calls to k.setLabelBlue and k.getArg as 
follows:

1. k.setLabelBlue now *always* protects its arguments.  There are a few 
cases where a command wants to have part of the minibuffer be protected, 
and part not.  In that case, the code uses k.extendLabel to add the 
unprotected part.  For example::

    k.setLabelBlue('Delete File: ')
    k.extendLabel(os.getcwd() + os.sep)

2. This makes the prefix argument to k.getArg redundant.  (Trust me).  No 
call to k.getArg now use the prefix argument.  For example, the code above 
is now followed by::

     k.getArg(event,'delete_file',1,self.deleteFile) ### ,prefix=prefix)

These cleanups allow me to deprecate the prefix argument.  This is *sooooo* 
important because it simplifies some of the trickiest parts of ga.get_arg.

EKR

-- 
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 http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to