zsh-users
 help / color / mirror / code / Atom feed
* X=`cat ~/y` completion
@ 2016-06-03  5:31 Daniel Shahaf
  2016-06-03 19:29 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2016-06-03  5:31 UTC (permalink / raw)
  To: zsh-users

Consider the following two cases:

% X=`cat $HOME/t<TAB>
% X=`cat ~/t<TAB>

In 'zsh -f' + compinit, the former works but the latter doesn't.
I expect the latter to behave as the former does.

---

The last related discussion seems to be 35515/35539.

The `functions -t _main_complete` transcripts of the two cases first
diverge at _path_files:255, where «$HOME/t» takes the 'if' branch and
«~/» the 'else' path:

   % nl -ba _path_files
   253	# Now let's have a closer look at the string to complete.
   254	
   255	if [[ "$pre" = [^][*?#^\|\<\>\\]#(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \' ]]; then
   256	
   257	  # If there is a parameter expansion in the word from the line, we try
   258	  # to complete the beast by expanding the prefix and completing anything
   259	  # after the first slash after the parameter expansion.
   ⋮
   276	elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
   277	
   278	  # It begins with `~', so remember anything before the first slash to be able
   279	  # to report it to the completion code. Also get an expanded version of it
   ⋮
   322	else
   323	  # If the string does not start with a `~' we don't remove a prefix from the
   324	  # string.
   ⋮
   353	fi


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

* Re: X=`cat ~/y` completion
  2016-06-03  5:31 X=`cat ~/y` completion Daniel Shahaf
@ 2016-06-03 19:29 ` Bart Schaefer
  2016-06-03 20:46   ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2016-06-03 19:29 UTC (permalink / raw)
  To: zsh-users

[This is more properly a -workers discussion but I'll continue on -users
because we started here.]

On Jun 3,  5:31am, Daniel Shahaf wrote:
} Subject: X=`cat ~/y` completion
}
} Consider the following two cases:
} 
} % X=`cat $HOME/t<TAB>
} % X=`cat ~/t<TAB>
} 
} In 'zsh -f' + compinit, the former works but the latter doesn't.
} I expect the latter to behave as the former does.
} 
} ---
} 
} The last related discussion seems to be 35515/35539.

I don't think those are related, completing after ~/ works elsewhere.
The real difficulty seems to follow from testing $compstate[quote] on
line 276:

}    276	elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
}    277	
}    278	  # It begins with `~', so [...]

The word on line does begin with tilde, but that's ignored because it is
inside the backticks.

The test could be either != [\'\"] or = (|\`) but I went with the latter
because the former confuses vim syntax highlighting.


diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index c64ebf5..14c4cc7 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -273,7 +273,7 @@ if [[ "$pre" = [^][*?#^\|\<\>\\]#(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \'
   orig="${orig[1,(in:i:)/][1,-2]}"
   donepath=
   prepaths=( '' )
-elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
+elif [[ "$pre[1]" = \~ && "$compstate[quote]" = (|\`) ]]; then
 
   # It begins with `~', so remember anything before the first slash to be able
   # to report it to the completion code. Also get an expanded version of it


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

* Re: X=`cat ~/y` completion
  2016-06-03 19:29 ` Bart Schaefer
@ 2016-06-03 20:46   ` Daniel Shahaf
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2016-06-03 20:46 UTC (permalink / raw)
  To: zsh-users

Bart Schaefer wrote on Fri, Jun 03, 2016 at 12:29:05 -0700:
> [This is more properly a -workers discussion but I'll continue on -users
> because we started here.]

I meant to send this to -workers.

Thanks for the fix, I confirm the patch works for me.

Cheers,

Daniel


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

end of thread, other threads:[~2016-06-03 20:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03  5:31 X=`cat ~/y` completion Daniel Shahaf
2016-06-03 19:29 ` Bart Schaefer
2016-06-03 20:46   ` 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).