Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: expansion of custom abbreviations in configure (autoconf) completion
- X-seq: zsh-workers 54836
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: PATCH: expansion of custom abbreviations in configure (autoconf) completion
- Date: Sun, 21 Jun 2026 21:04:00 +0000
- Archived-at: <https://zsh.org/workers/54836>
- Feedback-id: i425e4195:Fastmail
- In-reply-to: <26210-1781829645.262695@5TbQ.98ks.mcCy>
- List-id: <zsh-workers.zsh.org>
- References: <26210-1781829645.262695@5TbQ.98ks.mcCy>
Oliver Kiddle wrote on Fri, 19 Jun 2026 00:40 +00:00:
> configure scripts are one place where I often want to reuse complex
> mixes of options that I tend to forget. They also don't take any normal
> arguments aside from uppercase variable assignments and options so extra
> expandable arguments won't conflict.
>
> The patch below allows, e.g.:
>
> zstyle ':completion:*:configure:*:arguments' build-profiles \
> zdebug 'CC=clang-devel CFLAGS="-ggdb -Og -Wall" --prefix=$scratch/inst --enable-zsh-debug' \
> asan 'CFLAGS="-fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address"'
>
> And then, completion after configure zd<tab> will expand those options.
> Without the style, nothing much changes so the feature is hidden from
> most users.
>
> Or should we leave such things to abbreviation plugins? Or does anyone
> have better suggestions for solving this? I also pondered separating
> this out so it can be used elsewhere and use more consistent style/tag
> naming. There are other commands where I could imagine using this but
> often the aliases might clash with real arguments.
I have a local command that lets me do
.
,build zsh [BUILD_PROFILE] [SRCDIR]
.
where BUILD_PROFILE might be "zdebug" or "asan" to use your example, and
SRCDIR defaults to my primary worktree's absolute path. That runs SRCDIR/configure
in cwd with the appropriate arguments, including some dynamically-determined arguments
(e.g., «--prefix="$PREFIX/stow/zsh-$(date +%Y%m%dT%H:%M:%S%z)"»); sets link=static in
config.modules; and creates a symlink along the lines of «ln -s SRCDIR $BUILDDIR/foo».
You guys can think of this as a «~/bin/,build», since there's nothing in
,build that requires it to run as part of the interactive shell.
----
Another idea: imagine that once the user runs
.
make-wrapper cc FOO'-Wall -O0 -g'
.
, thereafter whenever «cc» is run, any occurrence of the word "FOO" in
argv would be replaced with ${=:-${'-Wall -O0 -g'}}. Would this be a
good thing? It wouldn't involve completion, and it'll keep the
snippet's name, rather than its value, in the shell history.
----
Yet another approach would be to use global aliases, for instance,
.
alias -g ,,asan='CFLAGS="-fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address"'
.
using the ",," prefix proposed downthread for the sake of example.
That wouldn't actually solve the risk of clashes, though: there is still
a possibility of clash with anything else that uses the prefix (",,"
here) "because no one else does".
Cheers,
Daniel
P.S. Speaking of global aliases, why doesn't «alias -g bar=42» followed
by «foo ba<TAB>» offer «bar»?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author