zsh-users
 help / color / mirror / code / Atom feed
* Completion in the first character position
@ 2000-07-25 13:14 Oliver Kiddle
  2000-07-25 13:39 ` Sven Wischnowsky
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2000-07-25 13:14 UTC (permalink / raw)
  To: Zsh users

I am writing a shell script where I'm prompting the user to enter
various information. I'm using vared to read what is entered into a
variable after using compctl -C to setup completions (and a setopt
autolist). I could have used the new style completions but it is a
fairly simple case and I use 3.0.8 where the script will run.

The problem is that when I press tab to complete in the first character
position, a tab is inserted and the completions are not listed. This is
handy at the normal zsh prompt because listing all the commands can be
time consuming but in my script, it is annoying.

Is there an option or something to turn this off? I've looked through
the manual but can't see one. As a feature, it is probably less useful
with the new completion system because the same can be achieved with a
style anyway.

Thanks

Oliver Kiddle


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

* Re: Completion in the first character position
@ 2000-07-25 13:39 ` Sven Wischnowsky
  2000-07-25 15:39   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2000-07-25 13:39 UTC (permalink / raw)
  To: zsh-users


Oliver Kiddle wrote:

> I am writing a shell script where I'm prompting the user to enter
> various information. I'm using vared to read what is entered into a
> variable after using compctl -C to setup completions (and a setopt
> autolist). I could have used the new style completions but it is a
> fairly simple case and I use 3.0.8 where the script will run.
> 
> The problem is that when I press tab to complete in the first character
> position, a tab is inserted and the completions are not listed. This is
> handy at the normal zsh prompt because listing all the commands can be
> time consuming but in my script, it is annoying.
> 
> Is there an option or something to turn this off? I've looked through
> the manual but can't see one. As a feature, it is probably less useful
> with the new completion system because the same can be achieved with a
> style anyway.

Yes, since this is possible in the new completion system (even the
default there, inside vared), I guess we won't add an option for it.

You can use a trick. The tab is only inserted if the last character in 
the key binding used to call the completion code was a tab. So:

  bindkey -s '\t' '\ec'  # or something better than \ec
  bindkey '\ec' complete-word

Ok?

And now you wish for vared-local keymaps, of course ;-)


Bye
 Sven


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


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

* Re: Completion in the first character position
  2000-07-25 13:39 ` Sven Wischnowsky
@ 2000-07-25 15:39   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-07-25 15:39 UTC (permalink / raw)
  To: Zsh users

On Jul 25,  2:14pm, Oliver Kiddle wrote:
} Subject: Completion in the first character position
}
} I am writing a shell script where I'm prompting the user to enter
} various information. I'm using vared to read what is entered into a
} variable after using compctl -C to setup completions (and a setopt
} autolist). I could have used the new style completions but it is a
} fairly simple case and I use 3.0.8 where the script will run.

I have a similar script and a similar situation, but I used

  compctl -Tx 'p[1,-1]' -f - 'W[0,*]' -k l ${${ZSH_VERSION##3.0*}:+-tn}

where `l' holds the list of words to be completed.  Hmm, I guess I'm
also using a `select' loop to read what is entered, as ZLE is enabled
at the PS3 prompt.

} The problem is that when I press tab to complete in the first character
} position, a tab is inserted and the completions are not listed.

Even sillier is that ^D in this same position _does_ produce a list,
rather than exiting from `select'.  That doesn't appear to be the case
any longer with the new completion system.

I suppose that might even be worthy of a patch for 3.0.8 ...

} Is there an option or something to turn this off? I've looked through
} the manual but can't see one. As a feature, it is probably less useful
} with the new completion system because the same can be achieved with a
} style anyway.

On Jul 25,  3:39pm, Sven Wischnowsky replied:
} Subject: Re: Completion in the first character position
}
} Yes, since this is possible in the new completion system (even the
} default there, inside vared), I guess we won't add an option for it.

My aforementioned script does

    local curcontext=${0}:::
    zstyle ":completion:${0}:*" completer _null
    zstyle ":completion:${0}:*" insert-tab no
    _null() { compcall -T -D }

to bypass new completion after the compctl -Tx has been installed and
stop tabs being inserted at the beginnings of lines.

Which reminds me:  `zed' should do something similar.  As should vared
when editing an element of the functions assoc -- is there a way to be
that specific about the vared context?

}   bindkey -s '\t' '\ec'  # or something better than \ec
}   bindkey '\ec' complete-word

Cute.

} And now you wish for vared-local keymaps, of course ;-)

The trick used by zed to set and restore bindings should be sufficient.

-- 
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] 3+ messages in thread

end of thread, other threads:[~2000-07-25 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-25 13:14 Completion in the first character position Oliver Kiddle
2000-07-25 13:39 ` Sven Wischnowsky
2000-07-25 15:39   ` Bart Schaefer

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