* Support for inverting of options?
@ 2007-09-15 0:29 Richard Hartmann
2007-09-15 6:36 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Richard Hartmann @ 2007-09-15 0:29 UTC (permalink / raw)
To: zsh-users
Hi all,
I am wondering what other people think about an option like vim's
:set invoption
for ZSH. At the moment, you can either set or unset an option,
but toggling it intot the other state is not possible without some
extra wrapper. While
toggleopt () {
[[ -o $1 ]] && unsetopt $1 || setopt $1
}
works fine, especially with
compdef _options toggleopt
it would still be nice to be able to do
setopt invtransientrprompt
What do you guys think about this? Is this a worthwhile feature
or is this use case pretty much limited to myself?
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Support for inverting of options?
2007-09-15 0:29 Support for inverting of options? Richard Hartmann
@ 2007-09-15 6:36 ` Bart Schaefer
[not found] ` <2d460de70709161417x1e6557c0n4f9ee8a1b2f18df2@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2007-09-15 6:36 UTC (permalink / raw)
To: zsh-users
On Sep 15, 2:29am, Richard Hartmann wrote:
}
} I am wondering what other people think about an option like vim's
}
} :set invoption
}
} What do you guys think about this? Is this a worthwhile feature
} or is this use case pretty much limited to myself?
Personally I almost never change the setting of an option, and when
I do I always know in which direction I want it to end up. If this
is nothing but a way to change an option temporarily and then change
it back without thinking about whether you need the "no" prefix, then
I'd be inclined not to expend built-in code on it.
function :set {
setopt nolocaloptions
local o
zmodload -i zsh/parameter
for o; do setopt ${o/inv/${${options[${o/inv/}]/on/no}/off/}}; done
}
That works for everything but localoptions itself.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Support for inverting of options?
[not found] ` <070916153114.ZM21571@torch.brasslantern.com>
@ 2007-09-16 22:49 ` Richard Hartmann
2007-09-17 0:06 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Richard Hartmann @ 2007-09-16 22:49 UTC (permalink / raw)
To: zsh-users
On 17/09/2007, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Sep 16, 11:17pm, Richard Hartmann wrote:
> }
> } Of course, you will pretty much always know what a specific option
> } is set to (at least if you touch it in your zshrc), but scripting and
> } key-binding gets a lot easier if you use inversion.
>
> I might agree about keybinding, but I'd say scripting gets *sloppier*,
> not easier, with inversion. Miss one inversion, whether by programming
> mistake or by run-time error, and everything from then on is trashed.
> Far better to explicitly set exactly the state you expect.
Well, I meant scripts invoked by key bindings, so we actually agree :)
> (Did you intend this to be off-list?)
No. I really regret using GMail for my mailing lists, these days..
Disadvantages of your solution over a native invoption are that you can
not use the normal setopt and that you can not tab complete on
invoption without writing a new completion.
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Support for inverting of options?
2007-09-16 22:49 ` Richard Hartmann
@ 2007-09-17 0:06 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2007-09-17 0:06 UTC (permalink / raw)
To: zsh-users
On Sep 17, 12:49am, Richard Hartmann wrote:
}
} Disadvantages of your solution over a native invoption are that you can
} not use the normal setopt and that you can not tab complete on
} invoption without writing a new completion.
Change the name of the function from ":set" to "setopt" and replace the
"setopt" in the "do" loop with "builtin setopt".
Or just do
compdef :set=setopt
Either way, some matcher-list styles would deal with ignoring the "inv"
at the beginning of the option names, I think.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-09-17 0:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-15 0:29 Support for inverting of options? Richard Hartmann
2007-09-15 6:36 ` Bart Schaefer
[not found] ` <2d460de70709161417x1e6557c0n4f9ee8a1b2f18df2@mail.gmail.com>
[not found] ` <070916153114.ZM21571@torch.brasslantern.com>
2007-09-16 22:49 ` Richard Hartmann
2007-09-17 0:06 ` Bart Schaefer
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).