zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Directory completion acts as if CHASE_LINKS is set
Date: Tue, 10 Sep 2013 07:26:13 -0700	[thread overview]
Message-ID: <130910072613.ZM9580@torch.brasslantern.com> (raw)
In-Reply-To: <130908142628.ZM27141@torch.brasslantern.com>

On Sep 8,  2:26pm, Bart Schaefer wrote:
}
} Ah, I see.  Yes, that does work, and furthermore gave me the clue that I
} needed to get the commmand line handling right.

Discovered I needed a reference to $tmpWpath in one more place.  Here is
the final diff ... unless we find out I messed up about IPREFIX.


diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd
index 476947f..a5d328f 100644
--- a/Completion/Zsh/Command/_cd
+++ b/Completion/Zsh/Command/_cd
@@ -51,6 +51,18 @@ else
     _directory_stack && ret=0
   fi
 
+  local -a tmpWpath
+  if [[ $PREFIX = (|*/)../* ]]; then
+    local tmpprefix
+    # Use cd in a subshell to properly [not] resolve symlinks
+    tmpprefix=$(cd ${PREFIX%/*} >&/dev/null && print $PWD)
+    if [[ -n $tmpprefix ]]; then
+      tmpWpath=(-W $tmpprefix)
+      IPREFIX=${IPREFIX}${PREFIX%/*}/
+      PREFIX=${PREFIX##*/}
+    fi
+  fi
+
   if [[ $PREFIX != (\~|/|./|../)* ]]; then
     local tmpcdpath alt
 
@@ -88,7 +100,7 @@ else
     # already handled by _command_names (see _autocd)
 
     [[ CURRENT -ne 1 || ( -z "$path[(r).]" && $PREFIX != */* ) ]] &&
-        alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files -/" "$alt[@]" )
+        alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files $tmpWpath -/" "$alt[@]" )
 
     if [[ CURRENT -eq argstart && noopts -eq 0 && $PREFIX = -* ]] &&
       zstyle -t ":completion:${curcontext}:options" complete-options; then
@@ -100,7 +112,7 @@ else
     return ret
   fi
   [[ CURRENT -ne 1 ]] && _wanted directories expl directory \
-      _path_files -/ && ret=0
+      _path_files $tmpWpath -/ && ret=0
 
   return ret
 fi


  parent reply	other threads:[~2013-09-10 14:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05  1:23 Jan Larres
2013-09-05  2:15 ` Jan Larres
2013-09-05 15:31 ` Bart Schaefer
2013-09-06  1:42   ` Jan Larres
2013-09-06  6:13     ` Bart Schaefer
2013-09-06  6:46       ` Jan Larres
2013-09-06 20:09   ` Peter Stephenson
2013-09-07  5:03     ` Bart Schaefer
2013-09-08 17:51       ` Peter Stephenson
2013-09-08 21:26         ` Bart Schaefer
2013-09-09  9:59           ` Peter Stephenson
2013-09-10 14:26           ` Bart Schaefer [this message]
2013-09-10 22:34             ` Jan Larres

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=130910072613.ZM9580@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /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).