From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH (?) Re: [zsh 4.0.1 bug] filename completion
Date: Thu, 28 Jun 2001 09:32:25 +0200 (MET DST) [thread overview]
Message-ID: <200106280732.JAA31314@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <1010627162054.ZM6208@candle.brasslantern.com>
Bart Schaefer wrote:
> ...
>
> } But this isn't a really good solution, because with that and directories
> } `~soft/foo' and `software/foo' completion after `cd soft/f<TAB>' lists
> } the `foo's, not the ambiguous prefix
>
> Hrm. That's a pretty minor problem by comparison. Particularly since it
> will (appear to) do the right thing if there are at least two directories
> starting with `f' that don't share a whole name in common.
Yes.
> } Because of that I'm not going to commit that part of the patch
>
> I think you should commit it. Anybody else have an opinion?
Thinking again yesterday evening, I came to the conclusion that's it's
at least better than what we have now and to commit it.
In another mail:
> One complication of this is:
>
> schaefer<509> cd soft/<TAB>
> Completing directories after cdablevar
> software/ src/ sparc-solaris/ share/ scripts/
> Completing local directories
> subdir/
>
> The "local directory" listed above is really ./software/subdir/. Cycling
> through the menu completions inserts it properly -- it's just the display
> that is wrong.
Yes, that's what I meant. A result of calling _path_files twice with
different prefixes.
May main problem is probably that I fail to see the `larger problem
behind this' so that I could try to tackle that. Modifying _path_files
just to improve this one case doesn't look like the right thing.
Bye
Sven
Index: Completion/Zsh/Command/_cd
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_cd,v
retrieving revision 1.2
diff -u -r1.2 _cd
--- Completion/Zsh/Command/_cd 2001/06/21 09:33:16 1.2
+++ Completion/Zsh/Command/_cd 2001/06/28 07:34:03
@@ -5,7 +5,7 @@
# and the string doesn't begin with ~, /, ./ or ../.
# - In the second argument to cd for the form `cd old new', completes
# possible `new' strings by examining `old' and $PWD.
-# - After - or +, completes numbers, but the listing
+# - After - or +, _directory_stack completes numbers, but the listing
# gives you the list of directories to complete. This turns on
# menu-completion and lists the possibilities automatically, otherwise
# it's not a lot of use. If you don't type the + or - it will
@@ -24,31 +24,55 @@
rep=(${${rep#${PWD%%$words[2]*}}%${PWD#*$words[2]}})
(( $#rep )) && _wanted -C replacement strings expl replacement compadd -a rep
else
- [[ CURRENT -gt 1 ]] && _directory_stack && ret=0
-
- if [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then
- local tdir tdir2
+ # Complete directory stack entries with ~ or when not in command position
+ # (the rest of this test is optimization for the _tilde call below)
+ if [[ "$PREFIX" == (#b)(\~|)[^/]# &&
+ ( -n "$match[1]" || ( CURRENT -gt 1 && ! -o cdablevars ) ) ]]; then
+ _directory_stack && ret=0
+ fi
- # With cdablevars, we can convert foo/bar/... to ~foo/bar/... if
- # there is no directory foo. In that case we could also complete
- # variable names, but it hardly seems worth it.
- # Note we need a tilde because cdablevars also allows user home
- # directories, hence we also need nonomatch to suppress error messages.
- if [[ -o cdablevars && -n "$PREFIX" && ! -d ${tdir::=${PREFIX%%/*}} &&
- -d ${~tdir2::="~$tdir"} ]]; then
- PREFIX="~$PREFIX"
- _wanted directories expl directory _path_files -/ && ret=0
- else
- local tmpcdpath
-
- tmpcdpath=(${${(@)cdpath:#.}:#$PWD})
- _alternative \
- 'local-directories:local directories:_path_files -/' \
+ if [[ $PREFIX != (\~|/|./|../)* ]]; then
+ local tmpcdpath
+ tmpcdpath=(${${(@)cdpath:#.}:#$PWD})
+
+ # With cdablevars, we can complete foo as if ~foo/
+ if [[ -o cdablevars && -n "$PREFIX" ]]; then
+ if [[ "$PREFIX" != */* ]]; then
+ _tilde && ret=0
+ else
+ local oipre="$IPREFIX" opre="$PREFIX" dirpre dir
+
+ # Note we need a tilde because cdablevars also allows user home
+ # directories, hence nonomatch (above) to suppress error messages.
+
+ dirpre="${PREFIX%%/*}/"
+ IPREFIX="$IPREFIX$dirpre"
+ eval "dir=( ~$dirpre )"
+ PREFIX="${PREFIX#*/}"
+
+ [[ $#dir -eq 1 && "$dir[1]" != "~$dirpre" ]] &&
+ _wanted named-directories expl 'directories after cdablevar' \
+ _path_files -W dir -/ && ret=0
+
+ PREFIX="$opre"
+ IPREFIX="$oipre"
+ fi
+ fi
+ if [[ $#tmpcdpath -ne 0 ]]; then
+ # Don't complete local directories in command position, that's
+ # already handled by _command_names (see _autocd)
+ if [[ CURRENT -eq 1 ]]; then
+ _wanted path-directories expl 'directories in cdpath' \
+ _path_files -W tmpcdpath -/ && ret=0
+ else
+ _alternative \
+ 'local-directories:local directories:_path_files -/' \
"path-directories:directories in cdpath:_path_files -W tmpcdpath -/" && ret=0
+ fi
+ return ret
fi
- else
- _wanted directories expl directory _path_files -/ && ret=0
fi
+ _wanted directories expl directory _path_files -/ && ret=0
return ret
fi
Index: Completion/Zsh/Context/_tilde
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_tilde,v
retrieving revision 1.1
diff -u -r1.1 _tilde
--- Completion/Zsh/Context/_tilde 2001/04/02 11:24:49 1.1
+++ Completion/Zsh/Context/_tilde 2001/06/28 07:34:03
@@ -6,7 +6,7 @@
[[ -n "$compstate[quote]" ]] && return 1
-local expl suf dirs list lines revlines i ret disp nm="$compstate[nmatches]"
+local expl suf ret
if [[ "$SUFFIX" = */* ]]; then
ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next prev parent reply other threads:[~2001-06-28 7:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1010626051501.ZM24562@candle.brasslantern.com>
2001-06-26 8:02 ` Sven Wischnowsky
2001-06-27 6:26 ` PATCH (?) " Bart Schaefer
2001-06-27 13:11 ` Sven Wischnowsky
2001-06-27 16:20 ` Bart Schaefer
2001-06-28 7:32 ` Sven Wischnowsky [this message]
2001-06-27 18:35 ` 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=200106280732.JAA31314@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.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).