Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: completion tests
- X-seq: zsh-workers 9952
- From: Tanaka Akira <akr@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: completion tests
- Date: 01 Mar 2000 22:11:43 +0900
- In-reply-to: Sven Wischnowsky's message of "Wed, 1 Mar 2000 12:44:17 +0100 (MET)"
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <200003011144.MAA25867@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
In article <200003011144.MAA25867@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> writes:
> > Also, I couldn't extract display strings specified by compadd -d. Is
> > there a simple way to extract?
>
> I'm not completely sure what you mean: a way to make those strings be
> distinguishable in the output? I can't think of much either, maybe
> something with list-colors, with a pattern like `* *', in the hope
> that display strings normally contain a space while other matches
> don't?
Spaces are not problem. Actually comptest can handle filenames
containing spaces.
Z(2):akr@is27e1u11% touch 'A B' 'A C'
Z(2):akr@is27e1u11% Src/zsh -f Test/comptest -D -z Src/zsh $'ls A\\ \t'
line: {ls A\ }{}
DESCRIPTION:{file}
FI:{A\ \ C}
FI:{A\ B}
Z(2):akr@is27e1u11% bin2ascii /tmp/comptest.debug
l\bls A\\ <WIDGET><expand-or-complete>\r
<LBUFFER>ls A\\ </LBUFFER>\r
<RBUFFER></RBUFFER>\r
\x1B[H\x1B[2J\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>ls A\\\x1B[K\x1B[1C\r\r
<DESCRIPTION>file</DESCRIPTION>\x1B[K\r
\x1B[K\r
\x1B[J<LC><FI><RC>A\\ \\ C<EC>\r
<LC><TC><RC> <EC>\r
<LC><SP><RC> <EC>\r
<LC><FI><RC>A\\ B<EC>\r
<LC><TC><RC> <EC>\r
<LC><SP><RC> <EC>\r
\r
\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>ls A\\\x1B[K\x1B[1C<WIDGET><finish>\r
\EOF
It's because zsh delimits listed filenames by <LC><FI><RC> and <EC>.
Of course, this will be problem with filenames containing <EC> etc.
But it's not big problem because we can choose arbitrary long
delimiters.
The problem I wanted to mention in 9936 is that zsh doesn't delimit
display strings properly as:
Z(2):akr@is27e1u11% Src/zsh -f Test/comptest -D -z Src/zsh $'flex -\t'
line: {flex -}{}
DESCRIPTION:{option}
NO:{-+ -- generate C++ scanner class}
NO:{--version}
Z(2):akr@is27e1u11% bin2ascii /tmp/comptest.debug|head
f\bflex -<WIDGET><expand-or-complete>\r
<LBUFFER>flex -</LBUFFER>\r
<RBUFFER></RBUFFER>\r
\x1B[H\x1B[2J\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>flex -\x1B[K\r\r
<DESCRIPTION>option</DESCRIPTION>\x1B[K\r
\x1B[K\r
<LC><NO><RC>-+ -- generate C++ scanner class\x1B[K<EC>\r
\r
-7 -- generate 7-bit scanner\x1B[K<EC>\r
\r
Z(2):akr@is27e1u11%
If `-7 -- generate 7-bit scanner' is delimited by <LC><NO><RC> and
<EC>, we can extract the string. But there is no <LC><NO><RC> before
the string and `\e[K' is inserted before <EC>.
Following patch fixes comptest.
* It didn't work on NetBSD.
(pty/tty buffer size problem?)
* Backslashes were unquoted by print.
* Debug option didn't work.
Index: Test/comptest
===================================================================
RCS file: /projects/zsh/zsh/Test/comptest,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 comptest
--- Test/comptest 2000/02/29 15:51:21 1.1.1.1
+++ Test/comptest 2000/03/01 13:00:21
@@ -20,14 +20,16 @@
input="$*"
-init=\
-'stty columns 80 rows 24
+tmp=/tmp/comptest.$$
+
+cat <<End >$tmp
+stty columns 80 rows 24
LISTMAX=10000000
-'"ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
+ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
bindkey -e
autoload -U compinit
compinit $dump
-"'zstyle ":completion:*" group-name ""
+zstyle ":completion:*" group-name ""
zstyle ":completion*:messages" format "<MESSAGE>%d</MESSAGE>
"
zstyle ":completion*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
@@ -39,7 +41,7 @@
expand-or-complete-with-report () {
print -lr "<WIDGET><expand-or-complete>"
zle expand-or-complete
- print -lr - "<LBUFFER>$LBUFFER</LBUFFER>" "<RBUFFER>$RBUFFER</RBUFFER>"
+ print -lr - "<LBUFFER>\$LBUFFER</LBUFFER>" "<RBUFFER>\$RBUFFER</RBUFFER>"
zle clear-screen
zle -R
}
@@ -59,19 +61,25 @@
bindkey "^I" expand-or-complete-with-report
bindkey "^D" list-choices-with-report
bindkey "^Z" finish
-'"$code"
+$code
+End
export PS1="<PROMPT>"
zpty zsh "$zsh" -f
zpty -r zsh log "*<PROMPT>*"
-zpty -w zsh "eval ${init:q}"
+zpty -w zsh ". $tmp"
zpty -r zsh log "*<PROMPT>*"
+rm $tmp
zpty -w zsh "$input"$'\C-Z'
zpty -r zsh log "*<WIDGET><finish>*"
+if [[ -n "$debug" ]]; then
+ print -lr - "$log" > /tmp/comptest.debug
+fi
+
logs=(${(s:<WIDGET>:)log})
shift logs
@@ -83,12 +91,12 @@
log="${log[$mend[1]+1,-1]}"
if (( 0 <= $mbegin[2] )); then
if [[ $match[2] != TC && $match[3] != \ # ]]; then
- print "$match[2]:{$match[3]}"
+ print -lr "$match[2]:{$match[3]}"
fi
elif (( 0 <= $mbegin[4] )); then
- print "DESCRIPTION:{$match[4]}"
+ print -lr "DESCRIPTION:{$match[4]}"
elif (( 0 <= $mbegin[5] )); then
- print "MESSAGE:{$match[5]}"
+ print -lr "MESSAGE:{$match[5]}"
fi
done
done
--
Tanaka Akira
Messages sorted by:
Reverse Date,
Date,
Thread,
Author