zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Re: zsh completion for umount
       [not found]     ` <161031004732.ZM18486@torch.brasslantern.com>
@ 2016-10-31 15:06       ` Bart Schaefer
  2016-10-31 15:33         ` Fourhundred Thecat
  2016-10-31 19:32         ` Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 2016-10-31 15:06 UTC (permalink / raw)
  To: zsh-workers; +Cc: Fourhundred Thecat

On Oct 31, 12:47am, Bart Schaefer wrote:
}
} "_canonical_paths_add_path $PREFIX" is called which, if prefix is not
} empty, tries calling zstat to see if it is a real file.  Of course
} this fails because it's not a file, it's only a prefix of a filename

OK, this is a lot better:

diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
index 9bccc7f..dde41f3 100644
--- a/Completion/Unix/Type/_canonical_paths
+++ b/Completion/Unix/Type/_canonical_paths
@@ -69,7 +69,10 @@ _canonical_paths_add_paths () {
   expref=${~origpref} 2>/dev/null
   [[ $origpref == (|*/). ]] && rltrim=.
   curpref=${${expref%$rltrim}:-./}
-  if zstat $curpref >&/dev/null; then
+  if [[ $expref:h == (.|..) ]]; then
+    _canonical_paths_pwd $expref:h
+    canpref=$REPLY/$expref:t
+  elif zstat $curpref >&/dev/null; then
     _canonical_paths_get_canonical_path $curpref
     canpref=$REPLY
   else


The remaining problem is that _canonical_paths_pwd screws up "cd -" and
friends by frobbing the directory stack with pushd/popd.  I may go back
to that in another thread.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Re: zsh completion for umount
  2016-10-31 15:06       ` [PATCH] Re: zsh completion for umount Bart Schaefer
@ 2016-10-31 15:33         ` Fourhundred Thecat
  2016-10-31 19:32         ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Fourhundred Thecat @ 2016-10-31 15:33 UTC (permalink / raw)
  To: zsh-workers

> On Oct 31, 12:47am, Bart Schaefer wrote:
> OK, this is a lot better:
> 
> diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
> index 9bccc7f..dde41f3 100644
> --- a/Completion/Unix/Type/_canonical_paths
> +++ b/Completion/Unix/Type/_canonical_paths
> @@ -69,7 +69,10 @@ _canonical_paths_add_paths () {
>    expref=${~origpref} 2>/dev/null
>    [[ $origpref == (|*/). ]] && rltrim=.
>    curpref=${${expref%$rltrim}:-./}
> -  if zstat $curpref >&/dev/null; then
> +  if [[ $expref:h == (.|..) ]]; then
> +    _canonical_paths_pwd $expref:h
> +    canpref=$REPLY/$expref:t
> +  elif zstat $curpref >&/dev/null; then
>      _canonical_paths_get_canonical_path $curpref
>      canpref=$REPLY
>    else
> 

works great !

thanks for the quick fix

Cheers,


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Re: zsh completion for umount
  2016-10-31 15:06       ` [PATCH] Re: zsh completion for umount Bart Schaefer
  2016-10-31 15:33         ` Fourhundred Thecat
@ 2016-10-31 19:32         ` Bart Schaefer
  2016-10-31 23:17           ` Daniel Shahaf
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2016-10-31 19:32 UTC (permalink / raw)
  To: zsh-workers; +Cc: Fourhundred Thecat

On Oct 31,  8:06am, Bart Schaefer wrote:
}
} The remaining problem is that _canonical_paths_pwd screws up "cd -"

Patch below attempts to fix that.

This whole file relies on native zsh mode, but never declares that anywhere
I guess that's OK as long as always called from completion.


diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
index 6482602..4b6b0c0 100644
--- a/Completion/Unix/Type/_canonical_paths
+++ b/Completion/Unix/Type/_canonical_paths
@@ -16,11 +16,13 @@
 _canonical_paths_pwd() {
   # Get the canonical directory name by changing to it.
   integer chaselinks
+  local oldpwd=$OLDPWD
   [[ -o chaselinks ]] && (( chaselinks = 1 ))
-  setopt localoptions nopushdignoredups chaselinks
+  setopt localoptions nopushdignoredups chaselinks noautopushd
   if builtin pushd -q -- $1 2>/dev/null; then
     REPLY=$PWD
     (( chaselinks )) || unsetopt chaselinks
+    [[ -n $oldpwd && -d $oldpwd ]] && builtin cd -q $oldpwd	# For "cd -"
     builtin popd -q
   else
     REPLY=$1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Re: zsh completion for umount
  2016-10-31 19:32         ` Bart Schaefer
@ 2016-10-31 23:17           ` Daniel Shahaf
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2016-10-31 23:17 UTC (permalink / raw)
  To: zsh-workers; +Cc: Fourhundred Thecat

Bart Schaefer wrote on Mon, Oct 31, 2016 at 12:32:52 -0700:
> On Oct 31,  8:06am, Bart Schaefer wrote:
> }
> } The remaining problem is that _canonical_paths_pwd screws up "cd -"
> 
> Patch below attempts to fix that.
> 
> diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
> index 6482602..4b6b0c0 100644
> --- a/Completion/Unix/Type/_canonical_paths
> +++ b/Completion/Unix/Type/_canonical_paths
> @@ -16,11 +16,13 @@
>  _canonical_paths_pwd() {
>    # Get the canonical directory name by changing to it.
>    integer chaselinks
> +  local oldpwd=$OLDPWD
>    [[ -o chaselinks ]] && (( chaselinks = 1 ))
> -  setopt localoptions nopushdignoredups chaselinks
> +  setopt localoptions nopushdignoredups chaselinks noautopushd
>    if builtin pushd -q -- $1 2>/dev/null; then
>      REPLY=$PWD
>      (( chaselinks )) || unsetopt chaselinks
> +    [[ -n $oldpwd && -d $oldpwd ]] && builtin cd -q $oldpwd	# For "cd -"
>      builtin popd -q

Couldn't we avoid calling pushd/cd entirely?  I.e., something along the
lines of

    if [[ -o chaselinks ]]; then REPLY=$1:A; else REPLY=$1:P; fi

?

>    else
>      REPLY=$1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-31 23:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5815DDAB.8070307__40712.3355348178$1477828401$gmane$org@gmx.ch>
     [not found] ` <20161030153537.GB12137@fujitsu.shahaf.local2>
     [not found]   ` <58164C21.9090505@gmx.ch>
     [not found]     ` <161031004732.ZM18486@torch.brasslantern.com>
2016-10-31 15:06       ` [PATCH] Re: zsh completion for umount Bart Schaefer
2016-10-31 15:33         ` Fourhundred Thecat
2016-10-31 19:32         ` Bart Schaefer
2016-10-31 23:17           ` Daniel Shahaf

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).