From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: General comments on completion
Date: Thu, 8 Jul 1999 11:04:54 +0200 (MET DST) [thread overview]
Message-ID: <199907080904.LAA11932@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Andrej Borsenkow"'s message of Sat, 3 Jul 1999 16:41:29 +0400
Andrej Borsenkow wrote:
> Is it possible to insert prefix but still do not exit the current completion
> "session"? So, that the list that was generated first is used also for possible
> menu completion? I tried _oldlist - but it does not seem to work (this is with
> modified _match that always inserts prefix):
This adds the assoc array _lastcomp which is used by _main_complete to
store information about the last completion.
Then I enhanced _oldlist a bit: the oldlist_list key may be set to the
name of a completer function and if we encounter an old list generated
by that completer, oldlist makes this list be used independent of the
widget currently used. Maybe we should use a different config key for
this -- if you are using _oldlist and find some strange behavior, tell
me.
With that one can set match_insert=unambig and oldlist_list=_match to
get the behavior described by Andrej -- a list generated by _match
will be re-used.
Since I'm planning to give incremental-complete-word some more support
in the future, I wanted to add some code to make information about the
last completion globally available anyway and it may also become
useful in other places, I think.
Bye
Sven
diff -u -r oc/Core/_main_complete Completion/Core/_main_complete
--- oc/Core/_main_complete Wed Jul 7 08:50:57 1999
+++ Completion/Core/_main_complete Thu Jul 8 09:52:42 1999
@@ -33,7 +33,7 @@
# state than the global one for which you are completing.
-local comp
+local comp ret=1
setopt localoptions nullglob rcexpandparam
unsetopt markdirs globsubst shwordsplit nounset ksharrays
@@ -54,5 +54,19 @@
# And now just call the completer functions defined.
for comp; do
- "$comp" && return
+ if "$comp"; then
+ ret=0
+ break;
+ fi
done
+
+_lastcomp=( "${(@kv)compstate}" )
+_lastcomp[completer]="$comp"
+_lastcomp[prefix]="$PREFIX"
+_lastcomp[suffix]="$SUFFIX"
+_lastcomp[iprefix]="$IPREFIX"
+_lastcomp[isuffix]="$ISUFFIX"
+_lastcomp[qiprefix]="$QIPREFIX"
+_lastcomp[qisuffix]="$QISUFFIX"
+
+return ret
diff -u -r oc/Core/_match Completion/Core/_match
--- oc/Core/_match Wed Jul 7 08:50:57 1999
+++ Completion/Core/_match Thu Jul 8 08:58:03 1999
@@ -60,7 +60,7 @@
compstate[pattern_match]="$opm"
compstate[matcher]="$compstate[total_matchers]"
-[[ ret -eq 0 && "$compconfig[match_insert]" = unambig* &&
+[[ ret -eq 1 && "$compconfig[match_insert]" = unambig* &&
$#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] &&
compstate[pattern_insert]=unambiguous
diff -u -r oc/Core/_oldlist Completion/Core/_oldlist
--- oc/Core/_oldlist Wed Jul 7 08:50:57 1999
+++ Completion/Core/_oldlist Thu Jul 8 09:02:18 1999
@@ -4,10 +4,13 @@
# and either the compconfig key oldlist_list is `always', or it is not `never'
# and the list is not already shown, then use the existing list for listing
# (even if it was generated by another widget).
+# Do this also if there is an old list and it was generated by the
+# completer named by the oldlist_list key.
if [[ -n $compstate[old_list] && $compconfig[oldlist_list] != never &&
- $WIDGET = *list* &&
- ( $compconfig[oldlist_list] = always || $compstate[old_list] != shown ) ]]
-then
+ ( ( $WIDGET = *list* &&
+ ( $compconfig[oldlist_list] = always ||
+ $compstate[old_list] != shown ) ) ||
+ $compconfig[oldlist_list] = *${_lastcomp[completer]}* ) ]]; then
compstate[old_list]=keep
return 0
fi
diff -u -r oc/Core/compinit Completion/Core/compinit
--- oc/Core/compinit Wed Jul 7 08:50:58 1999
+++ Completion/Core/compinit Thu Jul 8 08:59:32 1999
@@ -73,6 +73,11 @@
typeset -gA _comps
_patcomps=()
+# The associative array use to report information about the last
+# cmpletion to the outside.
+
+typeset -gA _lastcomp
+
# This is the associative array used for configuration.
typeset -gA compconfig
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-07-08 9:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-08 9:04 Sven Wischnowsky [this message]
1999-07-08 13:20 ` Andrej Borsenkow
1999-07-08 14:20 Sven Wischnowsky
1999-07-08 15:53 ` Andrej Borsenkow
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=199907080904.LAA11932@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).