Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Re: _netscape
- X-seq: zsh-workers 11539
- From: Oliver Kiddle <opk@xxxxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxxxxxxxxx>
- Subject: Re: PATCH: Re: _netscape
- Date: Tue, 23 May 2000 17:07:47 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <200005220837.KAA09906@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sven Wischnowsky wrote:
>
> > compadd seems
> > to only use the first -S option it is passed but this isn't documented
> > so I didn't want to rely on it.
>
> It *is* documented, in the compadd entry, below the options.
> _approximate always relied on it.
That's useful. The patch below makes use of this for url completion. It
doesn't seem to work in _path_files though.
> > Note that _files can no longer complete subdirectories if you give it a
> > -S option which is something other than a slash. _files should only add
> > the suffix after a file (and possible after an empty directory).
> Sometimes you want it, sometimes not...
When might you not want it (the slash)? If you don't want to decend
directories, it would be easier to use compadd * than _files. I'd have
thought that in the vast majority of cases, the passed suffix would be
wanted only after a file or empty directory.
> You may also want to have a look at $compstate[to_end]...
Thanks, that handles some situations but more control would be nice (at
least moving to the end of the match plus suffix).
> The way suffixes are handled has mostly historical reasons and, yes,
> it is a bit simple minded. If someone wants to help to improve it, I'd
> like to have a short and comprehensive list of things one might want
> to do, so that we can discuss it easliy and find the (hopefully few)
> basic things we need for that. With that we could then think about
> changing the code. Ok? (I don't think I'll have much time to think
> about this...)
I'll try to come up with such a list but it may be a little while before
I have time. Does anyone know of any parts of the completion system
where there is an interesting sitation or currently not very good
handling of suffixes: it might be useful if I investigate a few
different instances first.
Oliver
Index: Completion/User/_netscape
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_netscape,v
retrieving revision 1.6
diff -u -r1.6 _netscape
--- Completion/User/_netscape 2000/05/19 18:44:22 1.6
+++ Completion/User/_netscape 2000/05/23 15:44:11
@@ -77,10 +77,10 @@
else
_tags prefixes
while _tags; do
- while _next_label prefixes expl 'URL prefix'; do
- _urls "$@" && ret=0
+ while _next_label prefixes expl 'URL prefix' "$@"; do
+ _urls "$expl[@]" && ret=0
compset -S '[^:]*'
- compadd "$expl[@]" -S '' about: mocha: javascript: && ret=0
+ compadd -S '' "$expl[@]" about: mocha: javascript: && ret=0
done
(( ret )) || return 0
done
Index: Completion/User/_urls
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_urls,v
retrieving revision 1.8
diff -u -r1.8 _urls
--- Completion/User/_urls 2000/05/19 18:44:22 1.8
+++ Completion/User/_urls 2000/05/23 15:44:11
@@ -57,10 +57,11 @@
if ! compset -P '(#b)([-+.a-z0-9]#):'; then
_tags -C argument prefixes
while _tags; do
- while _next_label prefixes expl 'URL prefix'; do
+ while _next_label prefixes expl 'URL prefix' -S '' "$@"; do
+ compset -S '[^:/]*' && compstate[to_end]=''
[[ -d $urls_path/bookmark ]] &&
- compadd "$expl[@]" -S '' bookmark: && ret=0
- compadd "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0
+ compadd "$expl[@]" bookmark: && ret=0
+ compadd "$expl[@]" file: ftp:// gopher:// http:// && ret=0
done
(( ret )) || return 0
done
@@ -71,7 +72,7 @@
case "$scheme" in
http|ftp|gopher)
if ! compset -P //; then
- _wanted -C "$scheme" prefixes expl 'end of prefix' compadd "$@" -S '' //
+ _wanted -C "$scheme" prefixes expl 'end of prefix' compadd -S '' "$@" //
return
fi
;;
@@ -84,7 +85,7 @@
_path_files "$expl[@]" -S '' -g '*(^/)' && ret=0
_path_files "$expl[@]" -S/ -r '/' -/ && ret=0
elif [[ -z "$PREFIX" ]]; then
- compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0
+ compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0
fi
done
(( ret )) || return 0
@@ -104,7 +105,7 @@
while _next_label files expl 'bookmark'; do
_path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' &&
ret=0
- _path_files -W "$urls_path/$scheme" "$expl[@]" -S/ -r '/' -/ && ret=0
+ _path_files -W "$urls_path/$scheme" -S/ -r '/' "$expl[@]" -/ && ret=0
done
(( ret )) || return 0
done
@@ -119,10 +120,11 @@
_tags hosts
while _tags; do
- while _next_label hosts expl host; do
- (( $#uhosts )) || _hosts -S/ && ret=0
+ while _next_label hosts expl host "$@"; do
+ compset -S '/*' || suf="/"
+ (( $#uhosts )) || _hosts -S "$suf" "$expl[@]" && ret=0
[[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
- compadd "$expl[@]" -S/ - $uhosts && ret=0
+ compadd -S "$suf" "$expl[@]" - $uhosts && ret=0
done
(( ret )) || return 0
done
@@ -137,14 +139,14 @@
if [[ "$localhttp_servername" = "$host" ]]; then
if compset -P \~; then
if ! compset -P '(#b)([^/]#)/'; then
- _users -S/
+ _users -S/ "$@"
return
fi
user="$match[1]"
while _tags; do
while _next_label files expl 'local file'; do
_path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0
- _path_files "$expl[@]" -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0
+ _path_files -S/ -r '/' "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0
done
(( ret )) || return 0
done
@@ -152,7 +154,7 @@
while _tags; do
while _next_label files expl 'local file'; do
_path_files "$expl[@]" "$@" -W $localhttp_documentroot -g '*(^/)' && ret=0
- _path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0
+ _path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0
done
(( ret )) || return 0
done
@@ -161,7 +163,7 @@
while _tags; do
while _next_label files expl 'local file'; do
_path_files "$expl[@]" "$@" -W $urls_path/$scheme/$host -g '*(^/)' && ret=0
- _path_files "$expl[@]" -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0
+ _path_files -S/ -r '/' "$expl[@]" -W $urls_path/$scheme/$host -/ && ret=0
done
(( ret )) || return 0
done
Messages sorted by:
Reverse Date,
Date,
Thread,
Author