zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Zsh Hackers' List" <zsh-workers@sunsite.dk>
Subject: Re: Regression in braces completion
Date: Mon, 13 Oct 2008 08:43:28 -0700	[thread overview]
Message-ID: <081013084328.ZM28630@torch.brasslantern.com> (raw)
In-Reply-To: <20081013100417.36870ba5@news01>

On Oct 13, 10:04am, Peter Stephenson wrote:
} Subject: Re: Regression in braces completion
}
} It's certainly possible that the code that takes account of braces in
} the case of compadd -U isn't present because it's never been tested
} before, but that would be bug: the C code takes pains to hide the
} existence of the braces from the rest of the system

The direct effect of -U (if the doc is remotely descriptive of the code)
is to cause matching of the returned words against the command line to
be skipped, so perhaps the code that handles braces is embedded in the
compresult code that performs matching.

The usual indirect effect of -U is that the the word on the command
line is thrown away and replaced entirely with the result from compadd,
which does look like what's happening here.  Maybe all that's been lost
is the position at which to re-insert the brace, but I'm betting that
this comment above cline_str() is significant:

/* This builds the unambiguous string. If ins is one, it is immediately
 * inserted into the line. Otherwise csp is used to return the relative
 * cursor position in the string returned and posl contains all 
 * positions with missing or ambiguous characters. If ins is two, csp
 * and posl contain real command line positions (including braces). */

Comparing walkthroughs of cline_str() when ins==1 for the correct case
(-U removed from compadd) and the incorrect case, the difference is at
line 240, where in the correct case li==3 and in the incorrect li==0.
The value for li comes from l->prefix->llen, which must be the result
of the call to cut_cline() on line 175.

I've run out of time to spend on this, but I suspect that the effect of
the -U option is to cause cut_cline() to decide that nothing that was
already on the line is worth keeping, when really in this case we want
to keep the first three characters up to the brace.

However, I'm not sure the C code is actually wrong here.  Postulate a
completer that given "abcd" as the thing to match, returns "zyxw" and
uses compadd -U to say "accept this as a completion even though it does
not look like what you started with."  Now call that completer for a
line with "abc{d".  Is the right answer really "zyx{w" ?

} so there's no way you can treat this as a special case anywhere else

I wasn't suggesting treating this as a special case, I was suggesting
that _path_files treat a spelling correction in the path prefix as a
special case.  That's the stated reason why _path_files is using -U.

In fact _path_files probably ought to bail out in the case where it has 
corrected the path prefix and make the user confirm that the correction
is, well, correct, before it goes on to guessing about stuff further
along in the path.  The trouble most likely is that we're trying to do
too many things in one go.

Of course if we change that, someone will complain that what used to
need only one tab now needs two, but this may be a case of lesser of
evils.  Or there may be an entirely other way of solving this, such as
adding the entire paths including the correction as separate matches
so that the point of ambiguity is much farther to the left.  In any
case if you agree that the C code behavior for -U is correct, then the
right fix is something that eliminates the -U from _path_files by using
another approach for the original auto-correction problem.


  reply	other threads:[~2008-10-13 15:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-12  2:32 Vin Shelton
2008-10-12  4:32 ` Bart Schaefer
2008-10-12  7:10   ` Bart Schaefer
2008-10-12 19:42     ` Peter Stephenson
2008-10-12 22:47       ` Bart Schaefer
2008-10-13  9:04         ` Peter Stephenson
2008-10-13 15:43           ` Bart Schaefer [this message]
2008-10-13 16:27             ` Peter Stephenson
2008-10-13 16:56               ` Bart Schaefer
2008-10-14  4:37               ` PATCH (?) " Bart Schaefer
2008-10-14  8:45                 ` Peter Stephenson
2008-10-15  1:34                   ` Vin Shelton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=081013084328.ZM28630@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).