From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Tar file and Re: Bad interaction between -iprefix and -string
Date: Fri, 12 Feb 1999 10:54:11 +0100 (MET) [thread overview]
Message-ID: <199902120954.KAA08624@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Thu, 11 Feb 1999 18:08:34 +0100
Peter Stephenson wrote:
> 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.
Neither have I, but sounds good.
The patch below at least puts that key-completion stuff in a separate
function (`defkeycomp') and makes it be used.
It also fixes `__main_key_complete' to work with the widget-name-is-
function-name style and it fixes `__find'.
Bye
Sven
diff -u om/Completion/__find Misc/Completion/__find
--- om/Completion/__find Fri Feb 12 10:23:45 1999
+++ Misc/Completion/__find Fri Feb 12 10:46:21 1999
@@ -6,9 +6,9 @@
compsub
elif [[ -iprefix - ]]; then
complist -s 'daystart {max,min,}depth follow noleaf version xdev \
-a,c,}newer {a,c,m}{min,time} empty false {fs,x,}type gid inum links \
-i,}{l,}name {no,}{user,group} path perm regex size true uid used \
-xec {f,}print{f,0,} ok prune ls'
+{a,c,}newer {a,c,m}{min,time} empty false {fs,x,}type gid inum links \
+{i,}{l,}name {no,}{user,group} path perm regex size true uid used \
+exec {f,}print{f,0,} ok prune ls'
compreset
elif [[ -position 1 ]]; then
complist -g '. ..'
diff -u om/Completion/__main_key_complete Misc/Completion/__main_key_complete
--- om/Completion/__main_key_complete Fri Feb 12 10:23:46 1999
+++ Misc/Completion/__main_key_complete Fri Feb 12 10:39:01 1999
@@ -3,4 +3,4 @@
# The widget name looks like `__complete_key_<num>' where <num> can be
# used as an index into the `keycomps' array to get at the definition.
-callcomplete keycomps "$WIDGET[16,-1]" "$@"
+callcomplete keycomps "$WIDGET" "$@"
diff -u om/Completion/init Misc/Completion/init
--- om/Completion/init Fri Feb 12 10:23:47 1999
+++ Misc/Completion/init Fri Feb 12 10:44:11 1999
@@ -56,10 +56,11 @@
# 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 assoc array
+# Completion definitions bound directly to keys are stored in an assoc array
# named `keycomps'.
typeset -A comps
+typeset -A keycomps
# This may be used to define completion handlers. The first argument is the
@@ -106,6 +107,30 @@
}
+# This is used to define completion handlers directly bound to keys. The
+# first argument is as for `defcomp', giving the handler. The second argument
+# is a key-sequence usable fo `bindkey'. The third argument is the name of one
+# of the built-in completion widgets. Typing the given key sequence will
+# complete the word the cursor is on according to the completion definition
+# given and will behave as if the built-in completion widget was used.
+
+defkeycomp() {
+ local name
+
+ if [[ "$1" = -a ]]; then
+ shift
+ autoload "$1"
+ name="$1"
+ elif [[ "${1[1]}" = ' ' ]]; then
+ name="${1:t}"
+ else
+ name="$1"
+ fi
+ zle -C "$name" "$3" __main_key_complete
+ bindkey "$2" "$name"
+ keycomps[$name]="$1"
+}
+
# These can be used to easily save and restore the state of the special
# variables used by the completion code.
@@ -192,16 +217,9 @@
elif [[ $line[1] = '#pattern-array' ]]; then
defcomp " $file" "$line[2]"
elif [[ $line[1] = '#key-function' ]]; then
- (( ${+keycomps} )) || typeset -A keycomps
- zle -C ${file:t} $line[3] __main_key_complete
- bindkey "$line[2]" ${file:t}
- autoload ${file:t}
- keycomps[${file:t}]=${file:t}
+ defkeycomp -a "${file:t}" "$line[2]" "$line[3]"
elif [[ $line[1] = '#key-array' ]]; then
- (( ${+keycomps} )) || typeset -A keycomps
- zle -C ${file:t} $line[3] __main_key_complete
- bindkey "$line[2]" ${file:t}
- keycomps[${file:t}]=" $file"
+ defkeycomp " $file" "$line[2]" "$line[3]"
elif [[ $line[1] = '#helper' ]]; then
autoload ${file:t}
fi
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-02-12 9:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-12 9:54 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-02-12 8:53 Sven Wischnowsky
1999-02-11 15:27 Sven Wischnowsky
1999-02-11 17:08 ` Peter Stephenson
1999-02-11 18:39 ` Bart Schaefer
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=199902120954.KAA08624@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).