* How to add completion: variant of "make" command
@ 2007-04-30 12:19 Kai Grossjohann
2007-04-30 12:56 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Kai Grossjohann @ 2007-04-30 12:19 UTC (permalink / raw)
To: zsh-users
I would like to configure zsh to support completion of make targets,
in the following setup. I have no idea how to go about this: Where to
start reading docs, for instance.
* Our Makefiles depend on the environment because they contain
"include $(FOO)" where FOO comes from the environment.
* I have a shell script, say "xmake", that
- searches for a project root directory amongst the ancestors of the
current directory, then
- changes into that directory (if found),
- then sources a file ENV from that directory (if it exists), and
finally
- invokes regular "make".
(The shell script also prints GNU-style "Entering directory `foo'"
and "Leaving directory `foo'" messages to enable Emacs to parse the
error messages.)
So how do I make a variant of "make" completion that does what the
shell script does before it invokes regular "make" completion?
Thanks,
Kai
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to add completion: variant of "make" command
2007-04-30 12:19 How to add completion: variant of "make" command Kai Grossjohann
@ 2007-04-30 12:56 ` Peter Stephenson
2007-05-02 15:24 ` Kai Grossjohann
0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2007-04-30 12:56 UTC (permalink / raw)
To: zsh-users
Kai Grossjohann wrote:
> So how do I make a variant of "make" completion that does what the
> shell script does before it invokes regular "make" completion?
You need to write your own make replacement and tell the shell to use
that. Say it's called _make_with_xmake, then
autoload -U _make_with_xmake
compdef _make_with_xmake make
will do the trick. If it's in the function path before _make and
contains the #compdef line below you shouldn't need to bother.
_make_with_xmake will probably look something like:
#compdef make
if <...test whether we want to do the xmake stuff...>; then
<...do the xmake stuff...>
fi
_make "$@"
As long as it ends up with a call to the normal _make you can add
any preprocessing you like. If you don't want to complete anything
special, you're pretty well insulated from the details of the
completion system.
--
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
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to add completion: variant of "make" command
2007-04-30 12:56 ` Peter Stephenson
@ 2007-05-02 15:24 ` Kai Grossjohann
0 siblings, 0 replies; 3+ messages in thread
From: Kai Grossjohann @ 2007-05-02 15:24 UTC (permalink / raw)
To: zsh-users
Peter Stephenson <pws@csr.com> writes:
> Kai Grossjohann wrote:
>> So how do I make a variant of "make" completion that does what the
>> shell script does before it invokes regular "make" completion?
>
> You need to write your own make replacement and tell the shell to
> use that.[...] As long as it ends up with a call to the normal _make
> you can add any preprocessing you like.
Cool. I ended up with the following in my ~/.zshrc:
_xmake () {
if [ -r ./ENV ]; then
. ./ENV
fi
_make "$@"
}
compdef _xmake xmake
It seemed to be too small to put it anywhere else :-) Amazingly
enough, I already had a function and a compdef call; I just hadn't
thought that I could just call the existing function _make... D'oh.
Thanks a lot!
Kai
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-02 15:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-30 12:19 How to add completion: variant of "make" command Kai Grossjohann
2007-04-30 12:56 ` Peter Stephenson
2007-05-02 15:24 ` Kai Grossjohann
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).