* PATCH: Re: General comments on completion
@ 1999-07-08 9:04 Sven Wischnowsky
1999-07-08 13:20 ` Andrej Borsenkow
0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 1999-07-08 9:04 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: PATCH: Re: General comments on completion
1999-07-08 9:04 PATCH: Re: General comments on completion Sven Wischnowsky
@ 1999-07-08 13:20 ` Andrej Borsenkow
0 siblings, 0 replies; 4+ messages in thread
From: Andrej Borsenkow @ 1999-07-08 13:20 UTC (permalink / raw)
To: Sven Wischnowsky, zsh-workers
Maybe we should use a different config key for
> this -- if you are using _oldlist and find some strange behavior, tell
> me.
>
The following happens with _oldlist and the completion keys:
bor@itsrm2:~/test/match%> compconf -L
compconf correct_accept='2n'
compconf match_original='yes'
compconf completer='_oldlist:_complete:_match'
compconf dumpfile='/home/bor/.zcompdump'
compconf oldlist_list='_match'
compconf path_cursor='yes'
compconf match_insert='unambig'
compconf correct_prompt='correct to:'
bor@itsrm2:~/test/match%> ls /h/b/t/m/a?a/<12->TAB
bor@itsrm2:~/test/match%> ls /home/bor/test/match/a/\<12-\>
axa/ aya/ ^ cursor here; after TAB
bor@itsrm2:~/test/match%> l /home/bor/test/match/axa/\<12-\>CURSOR HERE
axa/ aya/ ^
It happens if _oldlist is used *and* cursor is initially at the end of word. If
I move cursor inside of word, it works as expected:
bor@itsrm2:~/test/match%> ls /h/b/t/m/a?a/<12->TAB
^ cursor here
bor@itsrm2:~/test/match%> ls /home/bor/test/match/a/\<12-\>
axa/ aya/ ^ cursor here
bor@itsrm2:~/test/match%> ls /home/bor/test/match/axa/\<12-\>
axa/ aya/ ^ cursor here
I have only setopt nolistambiguous explicitly set. It remains from old zshrc.
/andrej
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: PATCH: Re: General comments on completion
@ 1999-07-08 14:20 Sven Wischnowsky
1999-07-08 15:53 ` Andrej Borsenkow
0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 1999-07-08 14:20 UTC (permalink / raw)
To: zsh-workers
Andrej Borsenkow wrote:
> bor@itsrm2:~/test/match%> ls /h/b/t/m/a?a/<12->TAB
> bor@itsrm2:~/test/match%> ls /home/bor/test/match/a/\<12-\>
> axa/ aya/ ^ cursor here; after TAB
> bor@itsrm2:~/test/match%> l /home/bor/test/match/axa/\<12-\>CURSOR HERE
> axa/ aya/ ^
This makes _oldlist try to retain the cursor-positioning in cases like
these (when re-using a list from a certain completer).
Bye
Sven
diff -u oc/Core/_oldlist Completion/Core/_oldlist
--- oc/Core/_oldlist Thu Jul 8 11:11:49 1999
+++ Completion/Core/_oldlist Thu Jul 8 16:18:04 1999
@@ -6,13 +6,17 @@
# (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 ) ) ||
- $compconfig[oldlist_list] = *${_lastcomp[completer]}* ) ]]; then
- compstate[old_list]=keep
- return 0
+if [[ -n $compstate[old_list] && $compconfig[oldlist_list] != never ]]; then
+ if [[ $WIDGET = *list* &&
+ ( $compconfig[oldlist_list] = always ||
+ $compstate[old_list] != shown ) ]]; then
+ compstate[old_list]=keep
+ return 0
+ elif [[ $compconfig[oldlist_list] = *${_lastcomp[completer]}* ]]; then
+ [[ "$_lastcomp[insert]" = unambig* ]] && compstate[to_end]=single
+ compstate[old_list]=keep
+ return 0
+ fi
fi
# If this is a completion widget, and we have a completion inserted already,
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: PATCH: Re: General comments on completion
1999-07-08 14:20 Sven Wischnowsky
@ 1999-07-08 15:53 ` Andrej Borsenkow
0 siblings, 0 replies; 4+ messages in thread
From: Andrej Borsenkow @ 1999-07-08 15:53 UTC (permalink / raw)
To: Sven Wischnowsky, zsh-workers
>
> This makes _oldlist try to retain the cursor-positioning in cases like
> these (when re-using a list from a certain completer).
>
Fabulous (is it correct for fabelhaft? :-) It even preserves glob patterns after
the first ambiguous component ... sometimes I ask myself, is there anything that
cannot be done with Zsh?
/andrej
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-07-08 15:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-08 9:04 PATCH: Re: General comments on completion Sven Wischnowsky
1999-07-08 13:20 ` Andrej Borsenkow
1999-07-08 14:20 Sven Wischnowsky
1999-07-08 15:53 ` Andrej Borsenkow
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).