zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: _approximate doesn't work
Date: Tue, 19 Feb 2008 14:22:28 -0800	[thread overview]
Message-ID: <080219142228.ZM20752@torch.brasslantern.com> (raw)
In-Reply-To: <20080219101904.010f8df8@news01>

On Feb 19, 10:19am, Peter Stephenson wrote:
} Subject: Re: _approximate doesn't work
}
} On Tue, 19 Feb 2008 00:29:35 -0800
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > Looking through the output, PREFIX gets set by the replacement
} > compadd created via _approximate -- but that doesn't happen until
} > *inside* the call to _wanted, long after the test in _path_commands.
} 
} [...] this is an extremely general problem.  Very many completion
} functions assume quite reasonably that testing PREFIX tests what the
} completer is trying to match.

I just looked through "grep PREFIX Completion/**/*(.)" and I don't
think there are very many functions that use PREFIX as a pattern in
the way that _path_commands does.  Most of them test another pattern
against $PREFIX, to determine context based on what $PREFIX contains.

The real, more general problem IMO is that we've allowed the lines of
responsibility to become way too blurry.  The original idea (ISTR)
was that the completion functions (as opposed to "completers", or
what the manual calls "control functions") would generate a large
set of possible completions and then compadd would filter them down
to the actual matches, because only compadd knows enough about the
internal state of the shell to do so.

This gets compromised for performance reasons (e.g., if we know an
entire directory path, limit file names to those in that directory)
but the early functions were careful to do this only with the parts
of the command line that were already unambiguous.  That is not, in
general, true of $PREFIX.

The job of a completer is to figure out the context and supply the
corresponding tags.  The job of a completion function is to enumerate
all the possible strings for some subset of tags.  The job of compadd
is to reduce that set of strings to the actual completions.  As soon
as either of the functions starts crossing those boundaries, there's
a potential problem, and it better be happening for a good reason.
 
} Perhaps we need to make approximation/correction more visible by
} introducing parameters that are local to the completion system and
} only contain text in the appropriate case (e.g. APPROX="(#a1)")?

It may be that approximation is worthy of addition to compset/compadd.
The fact that _approximate has to create a dummy compadd function in
order to be implemented, argues in that direction.  However, I still
think _path_commands was wrong to pre-filter on $PREFIX.


      reply	other threads:[~2008-02-19 22:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200802171925.m1HJPbE8009696@pws-pc.ntlworld.com>
     [not found] ` <080218013338.ZM15026@torch.brasslantern.com>
2008-02-19  8:29   ` Bart Schaefer
2008-02-19 10:19     ` Peter Stephenson
2008-02-19 22:22       ` Bart Schaefer [this message]

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=080219142228.ZM20752@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).