zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: _expand, _expand_word, and their doc
@ 2000-10-09 11:49 Sven Wischnowsky
  0 siblings, 0 replies; 14+ messages in thread
From: Sven Wischnowsky @ 2000-10-09 11:49 UTC (permalink / raw)
  To: zsh-workers


As I said, I didn't find much time at the weekend, but I've been
playing and thinking a bit.

Bart Schaefer wrote:

> ...
> 
> Hm.  I don't have any overwhelming disagreement with that; the issue is
> not so much that _expand_word should handle it, as that _expand should
> not -- Andrej is clearly correct that _match is what actually does the
> most-correct thing in terms of generating the possible completions, so
> the question is how to get them all (offered to be) inserted at once.

As you said below, it isn't really _match either. It's any completer
that generates completions. And after re-thinking, I'm not so sure
about adding all completions as a single match anymore either. What
Andrej suggested (using an old list) really seems most useful for me
currently (getting a list, looking at it and then deciding to insert
them all -- less keystrokes than menuing to the all-completions entry).

(And the reason is not only that, trying a simple implementation, I
had some small problems getting it to work -- problems with the
prefix/suffic handling and when completing inside braces. That could
probably be solved.)

And the fact that _expand can offer both doesn't worry me very much
either, since there we are expanding a pattern the shell would expand
there anyway. It only looks slightly weird if one only things about
the combination of _match and inserting all completions.

> ...
> 
> I'd say we should use a new completer which has to appear very late in
> the completer list, and which modifies the handling of the completions
> that are generated before it is called.  As you suggest here:

I agree that this ordering looks sensible, but only unless one wants
it to re-use an old list. Then it should be at the very beginning,
which is almost an argument in favour of code like the one in
_expand. Or to put the whole thing into it's own completer that can
use an old list or builds a new one, calling the other completers
directly.

Hm, that would also be the easiest solution and could already be
implemented without having to change the C-code.


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: PATCH: _expand, _expand_word, and their doc
@ 2000-10-06  8:14 Sven Wischnowsky
  2000-10-06 12:34 ` Andrej Borsenkow
  0 siblings, 1 reply; 14+ messages in thread
From: Sven Wischnowsky @ 2000-10-06  8:14 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Oct 5,  7:34pm, Andrej Borsenkow wrote:
> }
> } > What would you (or anyone else) think of removing insert-all-completions
> } > from _expand entirely (thus eliminating the -c option) and instead put
> } > compstate[insert]=all at the end of _expand_word (after _main_complete)?
> } 
> } What has inserting all *completions* to do with *expansions* (and thus
> } _expand_word)?
> 
> You're starting from an initial pattern and expanding it into a set of
> strings, aren't you?  What difference does it make whether the way you
> got those strings was by globbing, parameter substitution, history, or
> by invoking the completion system, or anything else?

Right. I have to admit, though, that I put it there mainly because we
were at that time using the word `expanding' for this multiple-matches
insertion.

Anyway. The reason why I don't really like the completions style to be 
handled there is that -- as Andrej mentioned once -- the matches are
generated different than the expansions. Not even by _expand itself
(which just looked like a clever trick at that time).

So, I would mainly vote for changing the way the completions are
generated, using the way we do it in _prefix and _ignore, only the
other way round. I.e. we look up the completer style in the new
context and use the global list if it isn't set there. From that list
we remove the `uninteresting' completers as Bart did in _e_w (_prefix
and _ignore should probably do the same). That way the whole thing
would be self-contained again.

Then we leave it either in _expand or put it into a separate
completer, depending on how strongly people feel that this is
different from what _expand does: the fact that we can offer
expansions in different ways -- in one string or separately -- should
be taken into account there, unless we make that possible for
completions, too. And I think it would be possible, probably by adding 
a new option to compadd which makes it add a string with all matches
generated so far (and then remove the `all' special value for
compstate[insert]). I'm not exactly sure about the implications (inter 
alia because I see two different ways to implement it), but I would be 
willing to give it a try. With that, it would almost make sense to add 
that feature to _complete itself, making it look (feature-wise) more
like _expand.

I don't, however, like to put it only into a bindable command, because 
then people can't configure it to get all completions with, say, a
numeric prefix and TAB. And just adding a bindable command that makes
all completions be inserted when we have a completer for it is simple
(or just documenting the trick with _generic).

So, does that thing with allowing completions added separately to be
offered together with a string with all completions sound too esoteric 
or do you really like it. And should we then put it into _complete? (I 
mean, the weekend is coming up, so I should have the time to try to
implement it... ;-)

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: PATCH: _expand, _expand_word, and their doc
@ 2000-10-05  8:13 Sven Wischnowsky
  2000-10-05 15:21 ` Bart Schaefer
  0 siblings, 1 reply; 14+ messages in thread
From: Sven Wischnowsky @ 2000-10-05  8:13 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> Then, there was a completely inaccurate remark about the expansions and
> all-expansions tags in the doc:  They're *not* available when using the
> completions style with _expand.  If that's a bug in _expand rather than
> in the doc, I can't immediately see how to fix it ... so I changed the
> doc, and maybe Sven will do something to _expand when he returns.

I stumbled over this, too, when reading the manual while I was away.

I don't see a way to implement such a behaviour (i.e. I'm pretty sure
it isn't possible currently). So, Bart's changes, both in the docs and 
in _expand(|_word) are fine.

But of course I may start to think if this could be implemented -- if
I find a not-too-complicated way for changing the C-code...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 14+ messages in thread
* PATCH: _expand, _expand_word, and their doc
@ 2000-09-20 17:57 Bart Schaefer
  2000-09-21  5:07 ` Bart Schaefer
  2000-09-21  6:33 ` Andrej Borsenkow
  0 siblings, 2 replies; 14+ messages in thread
From: Bart Schaefer @ 2000-09-20 17:57 UTC (permalink / raw)
  To: zsh-workers

Way back in 11244, Sven wrote:

} However, there was a problem I didn't realise before. With completions 
} set _expand just returned with a value of one to make the following
} completers be called. But with _expand_word there aren't any following 
} completers... So the patch makes _expand call _complete when called
} from _expand_word.

This has the undesirable side-effect of failing to call any of the usual
other completers such as _match (see zsh-users/3444 and its thread).  So
I've deleted that line from _expand, and instead caused _expand_word to
fetch the `completer' style and modify the result so that _expand is the
first completer in the list.  This is imperfect, as it discards the entire
list if you haven't included the _expand completer at all, but I couldn't
think of any better way to assure that unwanted completers such as _list
and _menu are excluded.

Then, there was a completely inaccurate remark about the expansions and
all-expansions tags in the doc:  They're *not* available when using the
completions style with _expand.  If that's a bug in _expand rather than
in the doc, I can't immediately see how to fix it ... so I changed the
doc, and maybe Sven will do something to _expand when he returns.

Index: Completion/Commands/_expand_word
===================================================================
@@ -6,6 +6,7 @@
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 local curcontext="$curcontext"
+local -ah completers
 
 if [[ -z "$curcontext" ]]; then
   curcontext="expand-word:::"
@@ -13,4 +14,8 @@
   curcontext="expand-word:${curcontext#*:}"
 fi
 
-_main_complete _expand
+zstyle -a ":completion:${curcontext}:" completer completers
+completers[1,(i)_expand]=_expand
+(( $#completers == 1 )) && completers=(_expand _complete)
+
+_main_complete $completers
Index: Completion/Core/_expand
===================================================================
@@ -23,7 +23,6 @@
 if [[ "$force" = *c* ]] ||
    zstyle -t ":completion:${curcontext}:" completions; then
   compstate[insert]=all
-  [[ "$curcontext" = expand-word:* ]] && _complete && return 0
   return 1
 fi
 
Index: Doc/Zsh/compsys.yo
===================================================================
@@ -971,7 +971,8 @@
 This style is used by the tt(_expand) completer function. If it is set 
 to `true', the completer will not generate expansions, but instead the
 completions will be generated as normal and all of them will be
-inserted into the command line.
+inserted into the command line.  This style is most useful when set
+only for very specific completion contexts.
 )
 kindex(condition, completion style)
 item(tt(condition))(
@@ -2302,10 +2303,9 @@
 Which kind of expansion is tried is controlled by the tt(substitute),
 tt(glob) and tt(subst-globs-only) styles.
 
-There is another style, tt(completions), which allows tt(_expand) to
-display or insert all em(completions) generated for the string.  The use of
-this is that the tags tt(expansions) and tt(all-expansions) are available,
-unlike with tt(_complete).
+There is another style, tt(completions), which causes tt(_expand) to
+unconditionally insert all em(completions) generated for the current
+word (even if the word is empty).
 
 When tt(_expand) is called as a function, the different modes may be
 selected with options.  The tt(-c) corresponds to the tt(completions)
@@ -2485,7 +2485,11 @@
 item(tt(_expand_word (^Xe)))(
 Performs expansion on the current word:  equivalent to the standard
 tt(expand-word) command, but using the tt(_expand) completer.  Before
-calling it, the var(function) field is set to `tt(expand-word)'.
+calling it, the var(function) field is set to `tt(expand-word)', and the
+list of functions from the tt(completer) style in the resuting context is
+shifted to remove all those to the left of tt(_expand).  If tt(_expand)
+does not appear in the style, then only the two completers tt(_expand) and
+tt(_complete) are used (in that order).
 )
 findex(_generic)
 item(tt(_generic))(

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2000-10-09 11:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-09 11:49 PATCH: _expand, _expand_word, and their doc Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-10-06  8:14 Sven Wischnowsky
2000-10-06 12:34 ` Andrej Borsenkow
2000-10-06 13:00   ` Sven Wischnowsky
2000-10-08 19:35     ` Bart Schaefer
2000-10-05  8:13 Sven Wischnowsky
2000-10-05 15:21 ` Bart Schaefer
2000-10-05 15:34   ` Andrej Borsenkow
2000-10-05 17:11     ` Bart Schaefer
2000-09-20 17:57 Bart Schaefer
2000-09-21  5:07 ` Bart Schaefer
2000-09-21  6:33 ` Andrej Borsenkow
2000-09-21 14:37   ` Bart Schaefer
2000-09-21 14:59     ` Andrej Borsenkow

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).