From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7534 invoked from network); 21 Sep 2000 15:00:31 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Sep 2000 15:00:31 -0000 Received: (qmail 26898 invoked by alias); 21 Sep 2000 14:59:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12856 Received: (qmail 26891 invoked from network); 21 Sep 2000 14:59:51 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "Bart Schaefer" , Subject: RE: PATCH: _expand, _expand_word, and their doc Date: Thu, 21 Sep 2000 18:59:46 +0400 Message-ID: <000401c023dc$94e86790$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 In-Reply-To: <1000921143740.ZM7186@candle.brasslantern.com> > > On Sep 21, 10:33am, Andrej Borsenkow wrote: > } Subject: RE: PATCH: _expand, _expand_word, and their doc > } > } > +inserted into the command line. This style is most useful when set > } > +only for very specific completion contexts. > } > } I continue to ask myself just how useful it is. > > I suspect it's intended to be used in the :completion:expand-word:expand:: > context, though I didn't realize the context never gets any more specific > than that. That way the user can decide whether to invoke it. > > If it would work to set compstate[insert]=all inside _expand_word, before > calling _main_complete, then we could do that instead and remove the > handling for that style from _expand. I don't have time today to try > this. > It does work happily (look at my example _insert_all_matches in 12849). Actually, it needs to be set after _main_complete (what counts, is the value on return from completion widget). It needs some clean up, but it seems to work in almost all contexts I tried (but see the list of problems there). I send the patch against current CVS so you could look at it. -andrej Index: Completion/Commands/.distfiles =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Commands/.distfiles,v retrieving revision 1.4 diff -u -r1.4 .distfiles --- Completion/Commands/.distfiles 2000/06/19 09:16:17 1.4 +++ Completion/Commands/.distfiles 2000/09/21 14:57:28 @@ -2,5 +2,5 @@ .distfiles _bash_completions _complete_debug _correct_filename _correct_word _expand_word _history_complete_word _read_comp _most_recent_file - _complete_help _next_tags _complete_tag _generic + _complete_help _next_tags _complete_tag _generic _insert_all_matches ' Index: Completion/Commands/_insert_all_matches =================================================================== RCS file: _insert_all_matches diff -N _insert_all_matches --- /dev/null Tue May 5 13:32:27 1998 +++ _insert_all_matches Thu Sep 21 07:57:28 2000 @@ -0,0 +1,35 @@ +#compdef -K _insert_all_matches complete-word \C-xi + +setopt localoptions nullglob rcexpandparam extendedglob noshglob +unsetopt markdirs globsubst shwordsplit nounset ksharrays + +local oldcurcontext="$curcontext" list ret + +if [[ -z "$oldcurcontext" ]]; then + curcontext="insert-all-matches:::" +else + curcontext="insert-all-matches:${oldcurcontext#*:}" +fi + +zstyle -s ":completion:${curcontext}:" old-list list + +# If there is already an old list, +# and either the style :insert-all-matches:old-list is `always', +# or it is not `never', then insert the existing list +# (even if it was generated by another widget). +# Else just call completion and insert whatever matches it generated +# TODO: does not work in menu selection + + +if [[ -n $compstate[old_list] && $list != never && + $LASTWIDGET != _complete_help && $WIDGET != _complete_help ]]; then + compstate[old_list]=keep + compstate[insert]=all + return 0 +else + curcontext="$oldcurcontext" + _main_complete + ret=$? + compstate[insert]=all + return $ret +fi Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.96 diff -u -r1.96 compsys.yo --- Doc/Zsh/compsys.yo 2000/09/21 05:16:22 1.96 +++ Doc/Zsh/compsys.yo 2000/09/21 14:57:34 @@ -1614,7 +1614,10 @@ ) kindex(old-list, completion style) item(tt(old-list))( -This is used by the tt(_oldlist) completer. If it is set to `tt(always)', +This is used by the tt(_oldlist) completer and tt(_insert_all_matches) +bindable command. + +For tt(_oldlist) if it is set to `tt(always)', then standard widgets which perform listing will retain the current list of matches, however they were generated; this can be turned off explicitly with the value `tt(never)', giving the behaviour without the tt(_oldlist) @@ -1626,6 +1629,11 @@ old list will be used even if it was generated by a widget which does not do listing. +For tt(_insert_all_matches) if it set to `tt(never)', tt(_insert_all_matches) +will always generate new list. If this style is unset or with any other +value it will reuse existing list if available. It has the same caveats +as in case of tt(_oldlist). + For example, suppose you type tt(^Xc) to use the tt(_correct_word) widget, which generates a list of corrections for the word under the cursor. Usually, typing tt(^D) would generate a standard list of @@ -2511,6 +2519,18 @@ item(tt(_history_complete_word) (\e/))( Complete words from the shell's command history. This uses the tt(list), tt(remove-all-dups), tt(sort), and tt(stop) styles. +) +findex(_insert_all_matches) (^Xi)) +item(tt(_insert_all_matches) (^Xi))( +Insert all generated matches into command line. If used after any +completion widget, it normally will reuse old list even if menu completion +was already started (this is controlled by old-list style), else it will +call normal completion to generate matches. +This uses the tt(old-list) style. It sets var(function) field +to tt(insert-all-matches) when looking up the style and resets this +field to its original value before calling completion. + +Note, that it currently does not work in menu selection. ) findex(_most_recent_file (^Xm)) item(tt(_most_recent_file (^Xm)))(