* do not add a space after completion
@ 2009-06-14 7:26 Eric Smith
2009-06-14 16:03 ` Bart Schaefer
2009-06-23 14:26 ` invoking compadd so that completion is for the second argument Eric Smith
0 siblings, 2 replies; 7+ messages in thread
From: Eric Smith @ 2009-06-14 7:26 UTC (permalink / raw)
To: zsh-users
I have a completion function that when executed should supply
no extra space after the option is given (on pressing <tab>).
Ideally it should append an underscore instead.
How would I achieve that (just for this function and not globally)?
thanks.
--
- Eric Smith
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: do not add a space after completion
2009-06-14 7:26 do not add a space after completion Eric Smith
@ 2009-06-14 16:03 ` Bart Schaefer
2009-06-21 10:23 ` Eric Smith
2009-06-23 14:26 ` invoking compadd so that completion is for the second argument Eric Smith
1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2009-06-14 16:03 UTC (permalink / raw)
To: zsh-users
On Jun 14, 9:26am, Eric Smith wrote:
}
} I have a completion function that when executed should supply
} no extra space after the option is given (on pressing <tab>).
}
} Ideally it should append an underscore instead.
When calling compadd, pass the -S option and possibly the -r option.
There is a partial example under the -r option description in the
manual. For your specific case, probably you want:
compadd -S _ -r '_ \t\n' ...
(replacing "..." with other options and potential matches, etc.)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: do not add a space after completion
2009-06-14 16:03 ` Bart Schaefer
@ 2009-06-21 10:23 ` Eric Smith
0 siblings, 0 replies; 7+ messages in thread
From: Eric Smith @ 2009-06-21 10:23 UTC (permalink / raw)
To: zsh-users
Brilliant, thanks a lot Bart
--
- Eric Smith
Bart Schaefer said:
> On Jun 14, 9:26am, Eric Smith wrote:
> }
> } I have a completion function that when executed should supply
> } no extra space after the option is given (on pressing <tab>).
> }
> } Ideally it should append an underscore instead.
>
> When calling compadd, pass the -S option and possibly the -r option.
> There is a partial example under the -r option description in the
> manual. For your specific case, probably you want:
>
> compadd -S _ -r '_ \t\n' ...
>
> (replacing "..." with other options and potential matches, etc.)
^ permalink raw reply [flat|nested] 7+ messages in thread
* invoking compadd so that completion is for the second argument
2009-06-14 7:26 do not add a space after completion Eric Smith
2009-06-14 16:03 ` Bart Schaefer
@ 2009-06-23 14:26 ` Eric Smith
2009-06-23 15:11 ` Bart Schaefer
1 sibling, 1 reply; 7+ messages in thread
From: Eric Smith @ 2009-06-23 14:26 UTC (permalink / raw)
To: zsh-users
I want to set up completion rules for the second argument
and not the first which appears to eb the default.
How would i do this?
Thanks
--
- Eric Smith
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: invoking compadd so that completion is for the second argument
2009-06-23 14:26 ` invoking compadd so that completion is for the second argument Eric Smith
@ 2009-06-23 15:11 ` Bart Schaefer
0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2009-06-23 15:11 UTC (permalink / raw)
To: zsh-users
On Jun 23, 4:26pm, Eric Smith wrote:
}
} I want to set up completion rules for the second argument
} and not the first which appears to eb the default.
}
} How would i do this?
Could you provide an example command line to illustrate what you
intend to have happen?
For example, given a command line such as:
% roger dodger codger
Do you mean:
(1) The completion for "roger" is invoked, but the set of matches for
"codger" is not the same as the set of matches for "dodger"; or
(2) The completion for "dodger" should be invoked (as if "roger" were
not present) in order to generate matches for "codger"; or
(3) Some other thing entirely.
If (1), the best answer may be different if the matches for "codger"
are purely based on its position on the command line, or if they may
depend on what appears as the word in the "dodger" position.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: invoking compadd so that completion is for the second argument
2009-06-23 20:17 Eric Smith
@ 2009-06-24 8:47 ` Peter Stephenson
0 siblings, 0 replies; 7+ messages in thread
From: Peter Stephenson @ 2009-06-24 8:47 UTC (permalink / raw)
To: zsh-users
Eric Smith wrote:
> So the command:
> % prefix_cp sour<tab>
> will just complete as per the default rules, but
>
> % prefix_cp source_file.pdf <tab>
> should give me:
> % prefix_cp source_file.pdf aa_code_reference_00034
> assuming this was the first match in the list
You want something like:
#compdef prefix_cp
if (( CURRENT == 2 )); then
_default
else
local expl
local -a array
array=(special1 special2)
_wanted special expl 'special value' compadd -a array
fi
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: invoking compadd so that completion is for the second argument
@ 2009-06-23 20:17 Eric Smith
2009-06-24 8:47 ` Peter Stephenson
0 siblings, 1 reply; 7+ messages in thread
From: Eric Smith @ 2009-06-23 20:17 UTC (permalink / raw)
To: zsh-users
Thanks Bart
Bart Schaefer said:
> For example, given a command line such as:
>
> % roger dodger codger
>
> Do you mean:
>
> (1) The completion for "roger" is invoked, but the set of matches for
> "codger" is not the same as the set of matches for "dodger"; or
Something like this, indeed.
I create commands that allow me to copy or move existing files to
special named files. The prefix of these special names I want
to look up from a list in a file referenced by compadd.
So the command:
% prefix_cp sour<tab>
will just complete as per the default rules, but
% prefix_cp source_file.pdf <tab>
should give me:
% prefix_cp source_file.pdf aa_code_reference_00034
assuming this was the first match in the list
<parenthesis>
Oh I just had an idea for the first time now writing this.
If I went:
% prefix_cp source_file.pdf aa_code_reference_00034_<tab>
It would be great to have as the completion the first arg viz.
!#1 or `source_file.pdf'
But this is a bonus.
</parenthesis>
Thanks a lot.
Eric
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-06-24 8:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-14 7:26 do not add a space after completion Eric Smith
2009-06-14 16:03 ` Bart Schaefer
2009-06-21 10:23 ` Eric Smith
2009-06-23 14:26 ` invoking compadd so that completion is for the second argument Eric Smith
2009-06-23 15:11 ` Bart Schaefer
2009-06-23 20:17 Eric Smith
2009-06-24 8:47 ` Peter Stephenson
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).