From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4585 invoked from network); 13 Sep 1999 09:51:46 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Sep 1999 09:51:46 -0000 Received: (qmail 1957 invoked by alias); 13 Sep 1999 09:51:36 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7797 Received: (qmail 1950 invoked from network); 13 Sep 1999 09:51:33 -0000 Date: Mon, 13 Sep 1999 11:51:31 +0200 (MET DST) Message-Id: <199909130951.LAA05605@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk Subject: PATCH: verbose-list command With all these descriptions (omigod, what have I done...), I was wishing for a way to turn them on/off. So this adds the `verbose-list' bindable command which behaves like `delete-char-or-list' but can turn on (and off) option-listing and the `describe_*' keys on consecutive calls. With that, the current list of matches can change, of course, so it would be nice to have a way to make TAB work with the changed list (starting auto-menu), so I also enhanced `_oldlist' to supoort this. Bye Sven diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo --- od/Zsh/compsys.yo Thu Sep 9 16:31:34 1999 +++ Doc/Zsh/compsys.yo Sun Sep 12 20:09:31 1999 @@ -1075,6 +1078,22 @@ existing string instead of reading a new one. To force a new string to be read, call tt(_read_comp) with a numeric argument. ) +item(tt(_verbose_list) (^Xv))( +This widget behaves like the builtin tt(delete-char-or-list) widget +but if called repeatedly with the same command line, it will make the +completion list more and more verbose. The default behavior is to +first show options even if the tt(option_prefix) configuration key is +set and to show option and value descriptions, too, on the next +invocation. Using the tt(verboselist_stages) configuration key it is +possible to change this default behavior, see +ifzman(the section `Completion System Configuration' below)\ +ifnzman(noderef(Completion System Configuration)). Also, the +tt(_oldlist) completer has support for this command, which is +described in the entry for the tt(oldlist_menu) configuration key. + +Since this widget normally behaves like tt(delete-char-or-list) you +may find it convenient to bind it to tt(^D). +) enditem() texinode(Completion System Configuration)()(Bindable Commands)(Completion System) @@ -1339,7 +1358,37 @@ and menu completion is started in one of the usual ways. Usually, typing tt(TAB) at this point would start trying to complete the line as it now appears. With tt(_oldlist), it will instead continue to cycle through the -list of completions. +list of completions. + +With this key, the tt(_oldlist) completer also has additional support +for the tt(_verbose_list) bindable command: when it is set to +tt(verbose), invoking the tt(_oldlist) completer after a different +list has been shown by calling the tt(_verbose_list) command will make +completion re-use this list, so that, for example, menu completion +will be started when the tt(AUTO_LIST) option is set. +) +item(tt(verboselist_stages))( +This key is used by the tt(_verbose_list) bindable command to find out +when options or descriptions should be shown. It is a colon-separated +list of the keywords tt(normal), tt(options) and tt(describe). The +keywords are used in the order in which they appear to describe what +should be listed on the next call to the widget (with an unchanged +command line). The value tt(normal) says that the list should be +generated as defined by the normal settings of the configuration +keys, the value tt(options) says that options should be listed even if +the tt(option_prefix) configuration key is set, and tt(describe) says +that options and values should be described. The last two can be +combined as in tt(describe-options) to make both options being listed +and options and values being described. + +For example, if tt(option_prefix) is set to any non-empty value, +tt(describe_options) is not set and tt(verboselist_stages) is set to +tt(describe:normal) invoking the tt(_verbose_list) widget with a list +being shown will replace this list with a list containing also option +names that are possible matches and will also make these options be +described if possible. Consecutively invoking the tt(_verbose_list) +widget will then toggle between the normal list form and the extra +verbose one. ) item(tt(path_expand))( This is used by the tt(_path_files) function which is used throughout diff -u -r oldcompletion/Commands/_verbose_list Completion/Commands/_verbose_list --- oldcompletion/Commands/_verbose_list Mon Sep 13 10:37:42 1999 +++ Completion/Commands/_verbose_list Sat Sep 11 23:17:31 1999 @@ -0,0 +1,75 @@ +#compdef -k delete-char-or-list \C-xv + +# You probably want to bind this to Control-D. + +local odf="$compconfig[description_format]" +local omf="$compconfig[message_format]" +local ogm="$compconfig[group_matches]" +local oop="$compconfig[option_prefix]" +local odo="$compconfig[describe_options]" +local odv="$compconfig[describe_values]" +local what nm + +(( $# )) || set -- ${(s.:.)compconfig[verboselist_stages]} + +if [[ "$BUFFER" != "$_vl_buffer" || "$*" != "$_vl_config" ]]; then + _vl_buffer="$BUFFER" + _vl_config="$*" + _vl_array=( "$@" ) + _vl_index=1 + if (( ! $#_vl_array )); then + [[ -n "$compconfig[option_prefix]" ]] && _vl_array=(options) + [[ -z "$compconfig[describe_options]" || + -z "$compconfig[describe_options]" ]] && + _vl_array=( "$_vl_array[@]" options-describe ) + + _vl_array=( "$_vl_array[@]" normal ) + fi + if [[ -z "$compstate[old_list]" ]]; then + if (( $_vl_array[(I)normal] )); then + _vl_index="$_vl_array[(I)normal]" + else + _vl_array=( normal "$_vl_array[@]" ) + fi + fi +fi + +# If we had a possibility to say `ignore all matches added up to now', +# we could de-comment these thigs and wouldn't have the problem that +# if the options were already the stage `options' is a somewhat +# irritating no-op. +# Or maybe we make the completion functions report if they added +# options/description one day. + +# while true; do + what="$_vl_array[_vl_index++]" + [[ _vl_index -gt $#_vl_array ]] && _vl_index=1 + + if [[ "$what" != normal ]]; then + [[ -z "$odf" ]] && compconfig[description_format]='---- %d' + [[ -z "$omf" ]] && compconfig[message_format]='---- %d' + [[ -z "$ogm" ]] && compconfig[group_matches]=yes + [[ "$what" = *options* ]] && compconfig[option_prefix]='' + if [[ "$what" = *describe* ]]; then + compconfig[describe_options]=yes + compconfig[describe_values]=yes + fi + fi + + if [[ -n "$compstate[old_list]" ]]; then + nm="$_lastcomp[nmatches]" + else + nm=-1 + fi + + _main_complete + +# [[ "$what" != options || compstate[nmatches] -ne nm ]] && break +# done + +compconfig[description_format]="$odf" +compconfig[message_format]="$omf" +compconfig[group_matches]="$ogm" +compconfig[option_prefix]="$oop" +compconfig[describe_options]="$odo" +compconfig[describe_values]="$odv" diff -u -r oldcompletion/Core/_oldlist Completion/Core/_oldlist --- oldcompletion/Core/_oldlist Mon Sep 13 10:37:51 1999 +++ Completion/Core/_oldlist Sun Sep 12 18:49:26 1999 @@ -27,13 +27,23 @@ # If this is a completion widget, and we have a completion inserted already, # and the compconfig key oldlist_menu is not never, then we cycle through the # existing list (even if it was generated by another widget). -if [[ -n $compstate[old_insert] && $WIDGET = *complete(|-prefix|-word) && - $compconfig[oldlist_menu] != never ]]; then + +if [[ $compconfig[oldlist_menu] = verbose && + $LASTWIDGET = _verbose_list && $WIDGET != _verbose_list && + -z $compstate[old_insert] && + -n $compstate[old_list] ]]; then compstate[old_list]=keep - if [[ $WIDGET = *reverse* ]]; then - compstate[insert]=$(( compstate[old_insert] - 1 )) +elif [[ $WIDGET = *complete(|-prefix|-word) && + $compconfig[oldlist_menu] != (never|verbose) ]]; then + if [[ -n $compstate[old_insert] ]]; then + compstate[old_list]=keep + if [[ $WIDGET = *reverse* ]]; then + compstate[insert]=$(( compstate[old_insert] - 1 )) + else + compstate[insert]=$(( compstate[old_insert] + 1 )) + fi else - compstate[insert]=$(( compstate[old_insert] + 1 )) + return 1 fi return 0 fi -- Sven Wischnowsky wischnow@informatik.hu-berlin.de