zsh-users
 help / color / mirror / code / Atom feed
* Sundry Completion Questions ($_ $(^^) $(!!:s//)
@ 2014-11-02  0:38 Sonny Michaud
  2014-11-02  2:08 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sonny Michaud @ 2014-11-02  0:38 UTC (permalink / raw)
  To: Zsh Users

Good evening!

I have a few questions regarding some different completion mechanisms in 
zsh.

1) I noticed that $_<TAB> does not expand.  I am wondering if other 
parameter substitutions do expand and, if so, if there is an equivalent 
for $_ that is similarly pithy.  If not, is this something that deserves 
a feature request?

2) Quick history substitution does not expand in subcommands.  For 
instance, the following example does nothing.  I am not sure if this is 
also something that would warrant a feature request.
$ touch foo
$ echo $(^touch^cat)

3) Since the above does not work, I usually use $(!!:s/foo/bar), which 
has bizarre behavior, depending on whether or not a trailing slash is 
provided. This one feels like a bug proper, but it may have something to 
do with what I am attempting in particular.

$ grep -r foo
$ vim $(!!:s/-r/-rl)<TAB> -> vim $(grep -rl) foo

whereas

$ grep -r foo
$ vim $(!!:s/-r/-rl/)<TAB> -> $ vim $(grep -rl foo)

If anyone has any thoughts or suggestions about this, I would really 
appreciate the feedback.  Thanks!

- Sonny


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

* Re: Sundry Completion Questions ($_ $(^^) $(!!:s//)
  2014-11-02  0:38 Sundry Completion Questions ($_ $(^^) $(!!:s//) Sonny Michaud
@ 2014-11-02  2:08 ` Bart Schaefer
  2014-11-02  3:09   ` Sonny Michaud
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2014-11-02  2:08 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On Nov 1, 2014 5:39 PM, "Sonny Michaud" <michaud.sonny@gmail.com> wrote:
>
> 1) I noticed that $_<TAB> does not expand.

It expands for me.  It doesn't expand to anything very useful, because its
value changes during the execution of the completion functions, but it does
expand.

Do you have _expand in your "completer" zstyle?

> 2) Quick history substitution does not expand in subcommands.

Quick history substitution is a command-line construct, not a command
syntax construct.  It only works when the quick-history character appears
as the first character of the input buffer.

> 3) Since the above does not work, I usually use $(!!:s/foo/bar), which
has bizarre behavior, depending on whether or not a trailing slash is
provided.

History syntax doesn't interact with shell command syntax in the way you
are expecting.  *Everything* after the second slash, *including* the
closing paren, is part of the history reference unless you close the
history syntax by adding the third slash.

History substitution is a purely lexical replacement which occurs before
any shell-syntax analysis of the input is performed.

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

* Re: Sundry Completion Questions ($_ $(^^) $(!!:s//)
  2014-11-02  2:08 ` Bart Schaefer
@ 2014-11-02  3:09   ` Sonny Michaud
  0 siblings, 0 replies; 3+ messages in thread
From: Sonny Michaud @ 2014-11-02  3:09 UTC (permalink / raw)
  To: Zsh Users

Thanks for the response, it really clarifies a lot.  I did not have 
_expand in my completer, but I see how it ends up producing gibberish.

On 11/01/2014 10:08 PM, Bart Schaefer wrote:
> On Nov 1, 2014 5:39 PM, "Sonny Michaud" <michaud.sonny@gmail.com> wrote:
>> 1) I noticed that $_<TAB> does not expand.
> It expands for me.  It doesn't expand to anything very useful, because its
> value changes during the execution of the completion functions, but it does
> expand.
>
> Do you have _expand in your "completer" zstyle?
>
>> 2) Quick history substitution does not expand in subcommands.
> Quick history substitution is a command-line construct, not a command
> syntax construct.  It only works when the quick-history character appears
> as the first character of the input buffer.
>
>> 3) Since the above does not work, I usually use $(!!:s/foo/bar), which
> has bizarre behavior, depending on whether or not a trailing slash is
> provided.
>
> History syntax doesn't interact with shell command syntax in the way you
> are expecting.  *Everything* after the second slash, *including* the
> closing paren, is part of the history reference unless you close the
> history syntax by adding the third slash.
>
> History substitution is a purely lexical replacement which occurs before
> any shell-syntax analysis of the input is performed.
>


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

end of thread, other threads:[~2014-11-02  3:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-02  0:38 Sundry Completion Questions ($_ $(^^) $(!!:s//) Sonny Michaud
2014-11-02  2:08 ` Bart Schaefer
2014-11-02  3:09   ` Sonny Michaud

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