Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Equivalent of Vim's has("feature")?
- X-seq: zsh-users 15565
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- Subject: Re: Equivalent of Vim's has("feature")?
- Date: Mon, 22 Nov 2010 14:02:30 -0500 (EST)
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <20101122173206.31daca15@xxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.1011221149110.2792@hp> <20101122173206.31daca15@xxxxxxxxxxxxxxxxxxxxxxxxx>
On Mon, 22 Nov 2010, Peter Stephenson wrote:
On Mon, 22 Nov 2010 12:12:51 -0500 (EST) "Benjamin R. Haskell" wrote:
For commands and widgets I've found the following to work well:
(( $+commands[screen] )) && # do something with screen
(( $+widgets[history-incremental-pattern-search-backward] )) \
&& bindkey "^R" history-incremental-pattern-search-backward
But, 1) I can't seem to rediscover the documentation for those
arrays,
Look at the documentation for the zsh/parameter module in zshmodules.
Thanks. Didn't realize these weren't standard (for some value of
"standard").
and 2) Is there such an array for things that are more inbuilt? In
particular, I'm looking for a test that the ':A' history modifier
exists.
If you haven't recorded the version when it first appeared so you can
use the is-at-least function, which is the usual way (as long as you
do it as soon as the feature appears it's painless),
Is there any support for ZSH_PATCHLEVEL in is-at-least? :a and :A were
added in ZSH_VERSION=4.3.10(-dev-1?) ZSH_PATCHLEVEL=1.4618.
you have to attempt to make use of the feature and record the result.
integer history_A
( : ${PATH:A} ) 2>/dev/null && history_A=1
Both of these seem slippery-slopy. (Easy for one feature, but
increasingly annoying as more tests are needed. Also, if a given
feature takes non-trivial time to test.). Nonetheless, I guess I don't
have some easy-peasy way to add the feature detection to the case
statement in Src/hist.c and a new parameter in Src/Modules/parameter.c
(<-- note to self in the unlikely even I get back to this), so I'll
retreat with:
( : ${${:-/}:A} ) 2>/dev/null && has_A=true
...
(( $+has_A )) && # use it
which works fine for this case.
--
Thanks,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author