From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22839 invoked from network); 15 Oct 1999 09:43:27 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Oct 1999 09:43:27 -0000 Received: (qmail 1902 invoked by alias); 15 Oct 1999 09:43:21 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8272 Received: (qmail 1889 invoked from network); 15 Oct 1999 09:43:16 -0000 Date: Fri, 15 Oct 1999 11:42:44 +0200 (MET DST) Message-Id: <199910150942.LAA18064@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Fri, 15 Oct 1999 08:06:43 +0000 Subject: Re: PATCH: completion helper module Bart Schaefer wrote: > X-Seq: 8269 > > On Oct 12, 11:26am, Sven Wischnowsky wrote: > } Subject: PATCH: completion helper module > } > } Finally, the patch makes the `computil' module be loaded in > } `compinit'. This certainly should be changed some day. We could make > } it autoloaded there or we could make `computil' one of the > } automatically autoloaded modules (and builtin in static shells). > > I vote for that. Having two implementations of everything -- > > } [...] two versions of the functions affected, one > } using the helper builtins and one with the pure shell code [...] > > -- is just asking for a different flavor of the same problems we (you) > are having now keeping compctl and the new system both working. Right, that was what I was worried about, too. Ok, the patch below makes it be automatically autoloaded. Then I finally woke up and realised that `compdescribe -i' doesn't use its first argument and thus shouldn't get it. I also found that `_values' still used `compdisplay' although I thought I changed it together with `_arguments' -- so that is cleaned up, too. And then I added a bit of description about `computil' in the doc (don't expect too much here -- even better, don't expect anything at all). Bye Sven diff -u -r oldsrc/Zle/computil.c Src/Zle/computil.c --- oldsrc/Zle/computil.c Fri Oct 15 10:38:09 1999 +++ Src/Zle/computil.c Fri Oct 15 11:18:36 1999 @@ -291,9 +291,11 @@ } switch (args[0][1]) { case 'i': + cd_parsed = 1; + return cd_init(nam, "", args + 1, 0); case 'I': cd_parsed = 1; - return cd_init(nam, args[1], args + 2, (args[0][1] == 'I')); + return cd_init(nam, args[1], args + 2, 1); case 'g': if (cd_parsed) { int n = arrlen(args); diff -u -r oldsrc/Zle/computil.mdd Src/Zle/computil.mdd --- oldsrc/Zle/computil.mdd Fri Oct 15 10:41:47 1999 +++ Src/Zle/computil.mdd Fri Oct 15 10:42:38 1999 @@ -1,3 +1,5 @@ moddeps="compctl zle" objects="computil.o" + +autobins="compdisplay compdescribe comparguments compvalues" diff -u -r oldsrc/xmods.conf Src/xmods.conf --- oldsrc/xmods.conf Fri Oct 15 10:41:53 1999 +++ Src/xmods.conf Fri Oct 15 10:42:56 1999 @@ -4,3 +4,4 @@ compctl sched complist +computil diff -u olddoc/Zsh/mod_complist.yo Doc/Zsh/mod_complist.yo --- olddoc/Zsh/mod_complist.yo Thu Oct 14 16:26:33 1999 +++ Doc/Zsh/mod_complist.yo Fri Oct 15 10:49:20 1999 @@ -1,4 +1,4 @@ -texinode(The complist Module)(The deltochar Module)(The compctl Module)(Zsh Modules) +texinode(The complist Module)(The computil Module)(The compctl Module)(Zsh Modules) sect(The complist Module) cindex(completion, listing) cindex(completion, coloured listings) diff -u olddoc/Zsh/mod_computil.yo Doc/Zsh/mod_computil.yo --- olddoc/Zsh/mod_computil.yo Fri Oct 15 10:52:49 1999 +++ Doc/Zsh/mod_computil.yo Fri Oct 15 11:31:57 1999 @@ -0,0 +1,51 @@ +texinode(The computil Module)(The deltochar Module)(The complist Module)(Zsh Modules) +sect(The computil Module) +cindex(completion, utility) +The tt(computil) module adds four builtin commands that are used by +some of the completion functions in the shell function based +completions system (see +ifzman(zmanref(zshcompsys))\ +ifnzman(noderef(Completion System)) +). Except for tt(compdisplay) these builtin commands are very +specialised and thus not very interesting when writing your own +completion functions. In short, these builtin commands are: + +startitem() +item(tt(compdisplay) var(name) var(string) var(defs) ...)( +The var(defs) are strings should be of the form +`var(str)tt(:)var(descr)' (the intended use is that the var(descr) +describes the var(str)) and tt(compdisplay) will convert them to +strings in which the colon is replaced by the var(string) given as the +second argument and spaces are inserted before that so that they are +aligned over all strings. These resultings strings are then assigned +to an array with the var(name) given as the first argument. +) +item(tt(compdescribe))( +This is used by the tt(_describe) function to build the displays for +the matches and to get the strings to add as matches with their +options. The first call has to give the tt(-i) or tt(-I) option as the +first argument. In the first case, display strings without the +descriptions will be generated, inthe second case, the string used to +separate the matches from their descriptions has to be given as the +second argument and the descriptions (if any) will be shown. All other +arguments are like the definition arguments to tt(_describe) itself. + +Once tt(compdescribe) has been called with either the tt(-i) or the +tt(-I) option, it can be repeatedly called with the tt(-g) option and +the names of five arrays as its arguments. This will step through the +different sets of matches and store the options in the first array, +the strings with descriptions in the second, the matches for these in +the third, the strings without descriptions in the fourth, and the +matches for them in the fifth array. These are then directly given to +tt(compadd) to register the matches with the completion code. +) +item(tt(comparguments))( +This is used by the tt(_arguments) function to do the argument and +command line parsing. Like tt(compdescribe) it has an option tt(-i) to +do the parsing and initialize some internal state and various options +to access the state information to decide what should be completed. +) +item(tt(compvalues))( +Like tt(comparguments), but for the tt(_values) function. +) +enditem() diff -u olddoc/Zsh/mod_deltochar.yo Doc/Zsh/mod_deltochar.yo --- olddoc/Zsh/mod_deltochar.yo Thu Oct 14 16:26:33 1999 +++ Doc/Zsh/mod_deltochar.yo Fri Oct 15 10:49:08 1999 @@ -1,4 +1,4 @@ -texinode(The deltochar Module)(The example Module)(The complist Module)(Zsh Modules) +texinode(The deltochar Module)(The example Module)(The computil Module)(Zsh Modules) sect(The deltochar Module) The tt(deltochar) module makes available two ZLE functions: diff -u olddoc/Zsh/modules.yo Doc/Zsh/modules.yo --- olddoc/Zsh/modules.yo Thu Oct 14 16:26:34 1999 +++ Doc/Zsh/modules.yo Fri Oct 15 10:47:53 1999 @@ -25,6 +25,10 @@ item(tt(complist))( Completion listing extensions. ) +item(tt(computil))( +A module with utility builtins needed for the shell function based +completion system. +) item(tt(deltochar))( A ZLE function duplicating EMACS' tt(zap-to-char). ) @@ -62,6 +66,7 @@ menu(The comp1 Module) menu(The compctl Module) menu(The complist Module) +menu(The computil Module) menu(The deltochar Module) menu(The example Module) menu(The files Module) @@ -78,6 +83,7 @@ includefile(Zsh/mod_comp1.yo) includefile(Zsh/mod_compctl.yo) includefile(Zsh/mod_complist.yo) +includefile(Zsh/mod_computil.yo) includefile(Zsh/mod_deltochar.yo) includefile(Zsh/mod_example.yo) includefile(Zsh/mod_files.yo) diff -u -r oldcompletion/Base/_describe Completion/Base/_describe --- oldcompletion/Base/_describe Fri Oct 15 08:25:18 1999 +++ Completion/Base/_describe Fri Oct 15 11:18:42 1999 @@ -50,7 +50,7 @@ if [[ -n "$showd" ]]; then compdescribe -I ' -- ' "$@" else - compdescribe -i ' -- ' "$@" + compdescribe -i "$@" fi [[ -n "$isopt" && "$compconfig[option_prefix]" = hide* ]] && hide=yes diff -u -r oldcompletion/Base/_values Completion/Base/_values --- oldcompletion/Base/_values Fri Oct 15 08:25:18 1999 +++ Completion/Base/_values Fri Oct 15 11:11:17 1999 @@ -82,13 +82,8 @@ eval ws\=\( "${action[3,-3]}" \) - if [[ -n "$compconfig[describe_values]" && - "$compconfig[describe_values]" != *\!${cmd}* ]] && - compdisplay tmp ' -- ' "$ws[@]"; then - compadd "$expl[@]" -M 'r:|[_-]=* r:|=*' -ld tmp - "${(@)ws%%:*}" - else - compadd "$expl[@]" - "${(@)ws%%:*}" - fi + _describe "$descr" ws -M 'r:|[_-]=* r:|=*' + elif [[ "$action" = \(*\) ]]; then # Anything inside `(...)' is added directly. diff -u -r oldcompletion/Core/compinit Completion/Core/compinit --- oldcompletion/Core/compinit Fri Oct 15 08:25:25 1999 +++ Completion/Core/compinit Fri Oct 15 11:42:11 1999 @@ -78,10 +78,6 @@ fi done -# Load the helper module. - -zmodload computil - # The associative array containing the definitions for the commands. # Definitions for patterns will be stored in the normal arrays `_patcomps' # and `_postpatcomps'. -- Sven Wischnowsky wischnow@informatik.hu-berlin.de