Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Still something strange with ambiguous prefix



Andrej Borsenkow wrote:

> 1.
> 
> bor@itsrm2:~%> sudo mkdir -p /foo/{bar,bar1}
> bor@itsrm2:~%> sudo touch /foo/{bar,bar1}/baz
> bor@itsrm2:~%> l /f/b/bTAB
> bor@itsrm2:~%> l /foo/bar/baz
> 
> That is strange. bar1 seems to be never completed. (I noted it as we have
> both /usr/lib and /usr/lib64s with (basically) the same contents). I'd
> expect it to menu complete {bar,bar1}

It was there but the cursor didn't get placed at the right position
(with `unsetopt listambiguous' you would have seen it). Fixed by the
patch below.
And it does menu-completion for me. But it does not do automenu,
because before that the completion gets called a second time and then
the code in `_path_files' sees that `/foo/bar/baz' matches only one
file.

> 2.
> 
> bor@itsrm2:~> l /t/s/z/D/z*iTAB
> bor@itsrm2:~%> l /tools/src/zsh-3.1.5-pws-13/Doc/zsh.info
> zsh.info         zsh.info-5       zshbuiltins.1    zshoptions.1
> zsh.info-1       zsh.info-6       zshbuiltins.yo   zshoptions.yo
> zsh.info-10      zsh.info-7       zshcompwid.1     ztexi.yo
> zsh.info-2       zsh.info-8       zshcompwid.yo
> zsh.info-3       zsh.info-9       zshmisc.1
> zsh.info-4       zsh.texi         zshmisc.yo
> 
> Yesterday it completed just to zsh.texi

(globcomplete turned on, I guess.)

This one again? With completeinword, no `*', and the cursor before the 
`i' it worked. With globcomplete set (as I guess you have) this is
*correct* behavior. Correct in the sense that it always has been like
that. And no, I don't want to change it. Compatibility and all that.

Because of this I have written the `_match' completer:

  bindkey '^I' complete-word
  unsetopt globcomplete        # yes, it's off by default
  source .../compinit ...
  compconf completer=_complete:_match match_original=yes

in your `.zshrc'. Or `only' instead of `yes' if you prefer.

> 3.
> 
> bor@itsrm2:~%> l /t/s/gl/co*TAB
> bor@itsrm2:~%> l /tools/src/glib-1.1.15/co* <= cursor here
> glib-1.1.15/  glib-1.2.0/
> 
> So, menu completion is started for prefix, but cursor is placed at the end
> of word.

Grrrr, I asked if you wanted the cursor placed in the middle of the
word with menu-completion in message 5651 and you answered `Me not' in 
message 5657.

Anyway, I don't know how I should change this easily for now. The
problem is that the path suffix is just an ignored suffix for the
completion code and normally one really wants to have the cursor at
the end of the whole word with menu-completion.
We could add a flag stored with each match and add an option for
`compadd' to turn this on which would make the cursor be left before
that suffix.
But I'd really like to hear at least one comment from someone else
using menucompletion before doing this (hm, although, maybe if we add
another configuration key..., yes maybe I'll produce a patch for this
sometime).

> 4. It seems to be impossible to complete only prefix in /u/i/s/*.h (oh, I
> like this example :-) Reading README, _expand completer has a
> expand_original option, that makes it include original string in a set of
> matches. What about something like it for _match as well (with intention,
> that it should be used by _path_files also)? I understand, that it probably
> needs either another member to compstate - or probably we could add special
> value of pattern_insert? With meaning "menu completion with original
> pattern"?

Have you tried playing with `compconf path_expand=yes'? May I remind
you of 5917 (unsetting GLOB_COMPLETE, which is rather superfluous with
`_match' and using complete-word)?

Such a prefix-expansion has nothing to do with `compstate' -- as soon
as `_path_files' is used all the matching is done there and it also
says exactly what should be inserted and how all the strings for the
matches look like.

Also, I don't understand which connection you want to have between
`_match' and `_path_files'.

> Just a comment - I personally would prefer dots for options names:
> expand.menu, match.original etc. It gives more "multilevel" impression -
> e.g. if we decide to add more precise options to match.original, they could
> be match.original.foo, match.original.bar etc.
> And it is so Tcl'ish ... :-)

;-) I actually had this but then wanted to keep you happy by not
forcing you to have all your `compconf's changed. On the other hand,
the completion code is almost completely underscore-based, if you get my 
meaning. (And *TCL*? Bleah ;-)

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Thu Mar 25 15:31:01 1999
+++ Src/Zle/zle_tricky.c	Thu Mar 25 16:29:38 1999
@@ -3049,6 +3049,8 @@
 	p = o;
 	o = o->next;
     }
+    if (md.len || md.cl)
+	ot->flags |= CLF_MISS;
     if (orest)
 	*orest = NULL;
     if (nrest)

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author