From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.auc.dk
Subject: PATCH: Re: (forw) --help able programs and completion]
Date: Tue, 27 Jun 2000 17:02:55 +0200 (MET DST) [thread overview]
Message-ID: <200006271502.RAA30019@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 27 Jun 2000 14:36:29 +0000
Bart Schaefer wrote:
> ...
>
> What I was expecting, for some reason, was that menu selection would start
> immediately if there were more than N matches, not wait for the second TAB
> that triggers automenu. I.e., I want automenu (two TAB) behavior if there
> are fewer than N matches, and menu-select (one TAB) behavior for N or more.
>
> I don't know how I got the idea in my head that select=N by itself works
> that way. Is there a configuration that does work that way?
Ah. No, but that's easy to add.
I used the same form as for `select', i.e. one can say `yes=3' to turn
on menu completion when there are at least three matches.
Does anybody now want support for `no=3'?
Bye
Sven
Index: Completion/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v
retrieving revision 1.30
diff -u -r1.30 _main_complete
--- Completion/Core/_main_complete 2000/06/22 08:42:36 1.30
+++ Completion/Core/_main_complete 2000/06/27 14:58:56
@@ -23,7 +23,7 @@
# Failed returns from this code are not real errors
setopt localtraps noerrexit ; trap - ZERR
-local func funcs ret=1 tmp _compskip format nm call match \
+local func funcs ret=1 tmp _compskip format nm call match min i num\
_completers _completer _completer_num curtag _comp_force_list \
_matchers _matcher _matcher_num _comp_tags _comp_mesg \
context state line opt_args val_args curcontext="$curcontext" \
@@ -175,24 +175,33 @@
elif [[ "$compstate[insert]" = "$_saved_insert" ]]; then
if [[ -n "$_menu_style[(r)select=long]" && tmp -gt LINES ]]; then
compstate[insert]=menu
- elif [[ -n "$_menu_style[(r)(yes|true|1|on)]" ||
- ( -n "$_menu_style[(r)auto*]" &&
- "$compstate[insert]" = automenu ) ]]; then
- compstate[insert]=menu
- elif [[ -n "$_menu_style[(r)auto*]" &&
- "$compstate[insert]" != automenu ]]; then
- compstate[insert]=automenu-unambiguous
- elif [[ -n "$_menu_style[(r)(no|false|0|off)]" ]]; then
- compstate[insert]=unambiguous
- elif [[ -n "$_def_menu_style[(r)(yes|true|1|on)]" ||
- ( -n "$_def_menu_style[(r)auto*]" &&
- "$compstate[insert]" = automenu ) ]]; then
- compstate[insert]=menu
- elif [[ -n "$_def_menu_style[(r)auto*]" &&
- "$compstate[insert]" != automenu ]]; then
- compstate[insert]=automenu-unambiguous
- elif [[ -n "$_def_menu_style[(r)(no|false|0|off)]" ]]; then
- compstate[insert]=unambiguous
+ else
+ sel=( "${(@M)_menu_style:#(yes|true|1|on)*}" )
+
+ if (( $#sel )); then
+ min=9999999
+ for i in "$sel[@]"; do
+ if [[ "$i" = *\=* ]]; then
+ num="${i#*\=}"
+ [[ num -lt 0 ]] && num=0
+ else
+ num=0
+ fi
+ [[ num -lt min ]] && min="$num"
+
+ (( min )) || break
+ done
+ fi
+ if [[ ( -n "$min" && nm -ge min ) ||
+ ( -n "$_menu_style[(r)auto*]" &&
+ "$compstate[insert]" = automenu ) ]]; then
+ compstate[insert]=menu
+ elif [[ -n "$_menu_style[(r)auto*]" &&
+ "$compstate[insert]" != automenu ]]; then
+ compstate[insert]=automenu-unambiguous
+ elif [[ -n "$_menu_style[(r)(no|false|0|off)]" ]]; then
+ compstate[insert]=unambiguous
+ fi
fi
fi
@@ -209,8 +218,7 @@
sel=( "${(@M)_menu_style:#select*}" )
if (( $#sel )); then
- local min=9999999 i num
-
+ min=9999999
for i in "$sel[@]"; do
if [[ "$i" = *\=* ]]; then
num="${i#*\=}"
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.74
diff -u -r1.74 compsys.yo
--- Doc/Zsh/compsys.yo 2000/06/27 13:22:54 1.74
+++ Doc/Zsh/compsys.yo 2000/06/27 14:58:58
@@ -1593,6 +1593,10 @@
completion will be turned off even if it would otherwise be active (for
example, with the tt(MENU_COMPLETE) option).
+Using the form `tt(yes=)var(num)', where `tt(yes)' may be any of the
+true values (`tt(yes)', `tt(true)', `tt(on)' and `tt(1)') turns on
+menu completion if there at least var(num) matches.
+
In addition to (or instead of) the above possibilities, the value may
contain the string `tt(select)', optionally followed by an equal sign and a
number. In this case menu-selection (as defined by the tt(zsh/complist)
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~2000-06-27 15:03 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=200006271502.RAA30019@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-users@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).