From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Tar file and Re: Bad interaction between -iprefix and -string
Date: Thu, 11 Feb 1999 18:08:34 +0100 [thread overview]
Message-ID: <9902111708.AA58097@ibmth.df.unipi.it> (raw)
In-Reply-To: "Sven Wischnowsky"'s message of "Thu, 11 Feb 1999 16:27:38 NFT." <199902111527.QAA05726@beta.informatik.hu-berlin.de>
Sven Wischnowsky wrote:
> If Peter sends us his autoloading stuff, maybe we can join all the
> nice ideas both of us had.
You've done a good bit more than I have; most of my time was spent
constructing replacement functions. I found a couple of problems.
One was that autoloaded arrays needed an extra "" around to allow null
elements to be passed through; I found this from complist -H 0 ''
which was dropping the last part. Another was that for some reason
for i in "$patcomps[@]"; do
was being called when patcomps was empty (should it really do that?)
when was calling all sorts of bother, so I added a (( $#patcomps ))
test.
> - I also added support for Peter-like (sorry ;-) special completion
> keys, see the comment in `init'
I think this could be a bit neater: in the patch, the widget defined
now has the same name as the file with the #key-array or #key-function
in it. This was easy, it just needed $keycomps to be an assoc array.
This would be a limitation if you wanted to have widgets of a
different type (e.g. listing instead of completing) associated with
the same function; we could concatenate the names in that case. I
vaguely thought of some extension to allow binding of multiple keys at
once by this, either
#key-array \e/ \M/ history-complete
or perhaps better
#key-array history-complete \e/ \M/
but I haven't done that here.
--- Misc/Completion/init Thu Feb 11 16:16:40 1999
+++ /home/user2/pws/bin/comp/init Thu Feb 11 17:38:02 1999
@@ -56,7 +56,7 @@
# are the names of the command, the values are names of functions or variables
# that are to be used to generate the matches.
# Pattern completions will be stored in an normal array named `patcomps'.
-# Completion definitions bound directly to keys are store in an array
+# Completion definitions bound directly to keys are store in an assoc array
# named `keycomps'.
typeset -A comps
@@ -166,7 +166,7 @@
if [[ ${(P)+def} -eq 1 ]]; then
# It is a parameter name, call complist directly.
- complist ${(@P)def}
+ complist "${(@P)def}"
else
# Otherwise it's a function name, call this function.
@@ -177,9 +177,10 @@
# Now we make the files automatically autoloaded.
-local dir file line key=1
+local dir file line
for dir in $fpath; do
+ [[ $dir = . ]] && continue
for file in $dir/__*~*~(N); do
read -rA line < $file
if [[ $line[1] = '#function' ]]; then
@@ -191,16 +192,16 @@
elif [[ $line[1] = '#pattern-array' ]]; then
defcomp " $file" "$line[2]"
elif [[ $line[1] = '#key-function' ]]; then
- zle -C __complete_key_$key $line[3] __main_key_complete
- bindkey "$line[2]" __complete_key_$key
+ (( ${+keycomps} )) || typeset -A keycomps
+ zle -C ${file:t} $line[3] __main_key_complete
+ bindkey "$line[2]" ${file:t}
autoload ${file:t}
- keycomps[key]=${file:t}
- (( key++ ))
+ keycomps[${file:t}]=${file:t}
elif [[ $line[1] = '#key-array' ]]; then
- zle -C __complete_key_$key $line[3] __main_key_complete
- bindkey "$line[2]" __complete_key_$key
- keycomps[key]=" $file"
- (( key++ ))
+ (( ${+keycomps} )) || typeset -A keycomps
+ zle -C ${file:t} $line[3] __main_key_complete
+ bindkey "$line[2]" ${file:t}
+ keycomps[${file:t}]=" $file"
elif [[ $line[1] = '#helper' ]]; then
autoload ${file:t}
fi
--- Misc/Completion/__normal Thu Feb 11 16:06:29 1999
+++ /home/user2/pws/bin/comp/__normal Thu Feb 11 17:45:47 1999
@@ -23,13 +23,15 @@
# See if there are any matching pattern completions.
-for i in "$patcomps[@]"; do
- pat="${i% *}"
- val="${i#* }"
- if [[ "$cmd1" == $~pat || "$cmd2" == $~pat ]]; then
- callcomplete patcomps "$pat" "$@" || return 1
- fi
-done
+if (( $#patcomps )); then
+ for i in "$patcomps[@]"; do
+ pat="${i% *}"
+ val="${i#* }"
+ if [[ "$cmd1" == $~pat || "$cmd2" == $~pat ]]; then
+ callcomplete patcomps "$pat" "$@" || return 1
+ fi
+ done
+fi
# Now look up the two names in the normal completion array.
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
next prev parent reply other threads:[~1999-02-11 17:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-11 15:27 Sven Wischnowsky
1999-02-11 17:08 ` Peter Stephenson [this message]
1999-02-11 18:39 ` Bart Schaefer
1999-02-12 8:53 Sven Wischnowsky
1999-02-12 9:54 Sven Wischnowsky
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=9902111708.AA58097@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@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).