zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: Expand only completions, complete only uncompleted completions
Date: Mon, 8 May 2000 10:42:59 +0200 (MET DST)	[thread overview]
Message-ID: <200005080842.KAA12390@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Fri, 5 May 2000 14:46:44 +0000


Bart Schaefer wrote:

> This is after applying patches up to 11195 (but not 11194, yet).
> 
> zagzig[116] cvs add _l*<TAB>
> zagzig[116] cvs add _lzop
> Completing file
> _lzop   _look 
> 
> 
> Hmm, what I wanted was for `_l*' to expand to exactly `_lzop _look'.  But
> then I remember that I don't have the `completions' style set.  So I try
> again, just to see if I can make it do what I wanted:
> 
> zagzig[116] cvs add _l*<C-xe>
> zagzig[116] cvs add _look _lp _lynx _lzop
> Completing all expansions
> _look _lp _lynx _lzop 
> Completing expansions
> _look   _lp     _lynx   _lzop 
> Completing original
> _l* 
> 
> Is this the expected behavior?  Shouldn't _expand_word use the completion
> context to eliminate _lp and _lynx?

Not unless you set the completions style. Without that it just works
like expansion always worked (in terms of generating words).

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.

> On a slightly different topic:
> 
> zagzig[117] cvs add _lzop _l<TAB>
> Completing file
> _lzop   _look 
> 
> No, I don't need _lzop any more, it's already there.

I've seen Akira's reply, fixing this for _cvs.

But... this is a much more general problem and has been annoying me
for ages. Only now that I thought about it again had I the idea that
with the mechanism behind ignored-patterns in place, we can easily
solve this.

So, the patch also adds the ignore-line style (there may be better
names) which is tested for tags used for generating matches. If it is
true, then the words from the line will be ignored. Note the comment
in the manual about setting it for very non-specific contexts.

Very handy for things like diff, mv, etc.

Bye
 Sven

Index: Completion/Builtins/_zstyle
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_zstyle,v
retrieving revision 1.10
diff -u -r1.10 _zstyle
--- Completion/Builtins/_zstyle	2000/05/08 08:16:32	1.10
+++ Completion/Builtins/_zstyle	2000/05/08 08:41:48
@@ -36,6 +36,7 @@
   hosts			 c:_hosts
   hosts-ports		 c:host-port
   users-hosts-ports	 c:user-host-port
+  ignore-line            c:bool
   ignore-parents         c:ignorepar
   ignored-patterns	 c:
   insert-ids             c:insert-ids
Index: Completion/Core/_description
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_description,v
retrieving revision 1.3
diff -u -r1.3 _description
--- Completion/Core/_description	2000/04/17 08:04:42	1.3
+++ Completion/Core/_description	2000/05/08 08:41:48
@@ -29,9 +29,16 @@
     opts=($opts -M "${(q)match}")
 [[ -n "$_matcher" ]] && opts=($opts -M "${(q)_matcher}")
 
-if [[ -z "$_comp_no_ignore" ]] &&
-   zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
-  opts=( $opts -F _comp_ignore )
+if [[ -z "$_comp_no_ignore" ]]; then
+  if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
+    opts=( $opts -F _comp_ignore )
+    zstyle -t ":completion:${curcontext}:$1" ignore-line &&
+        _comp_ignore=( "$_comp_ignore[@]" "$words[@]}" )
+  elif zstyle -t ":completion:${curcontext}:$1" ignore-line; then
+    _comp_ignore=( "$words[@]}]" )
+  else
+    _comp_ignore=()
+  fi
 else
   _comp_ignore=()
 fi
Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.9
diff -u -r1.9 _expand
--- Completion/Core/_expand	2000/05/08 08:16:32	1.9
+++ Completion/Core/_expand	2000/05/08 08:41:48
@@ -30,6 +30,7 @@
    { zstyle -s ":completion:${curcontext}:" completions expr &&
      [[ "${(e):-\$[$expr]}" -eq 1 ]] }; then
   compstate[insert]=all
+  [[ "$curcontext" = expand-word:* ]] && _complete && return 0
   return 1
 fi
 
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.36
diff -u -r1.36 compsys.yo
--- Doc/Zsh/compsys.yo	2000/05/08 08:16:33	1.36
+++ Doc/Zsh/compsys.yo	2000/05/08 08:41:50
@@ -1175,6 +1175,17 @@
 example, the hostname is already typed, only those ports will be
 completed for which pairs with the hostname from the line exist.
 )
+kindex(ignore-line, completion style)
+item(tt(ignore-line))(
+This style is tested for the tags used when generating matches. If it
+is set to `true', then none of the words that are already on the line
+will be considered possible completions.
+
+Note that you almost certainly don't want to set this for a general
+context such as `tt(:completion:*)'. This because it would disallow
+completion of, for example, options multiple times even if the command
+in question accepts the option more than once.
+)
 kindex(ignore-parents, completion style)
 item(tt(ignore-parents))(
 The style is tested for the tt(files) tag to determine whether to ignore

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


                 reply	other threads:[~2000-05-08  8:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200005080842.KAA12390@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.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).