diff options
Diffstat (limited to 'Doc/Zsh/mod_zutil.yo')
-rw-r--r-- | Doc/Zsh/mod_zutil.yo | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo index 24aebdfaf..3cf9e5028 100644 --- a/Doc/Zsh/mod_zutil.yo +++ b/Doc/Zsh/mod_zutil.yo @@ -32,20 +32,27 @@ If two patterns are equally specific, the tie is broken in favour of the pattern that was defined first. em(Example) +kindex(preferred-precipitation, example style) +findex(weather, example function) -For example, to define your preferred form of precipitation depending on which -city you're in, you might set the following in your tt(zshrc): +For example, a fictional `tt(weather)' plugin might state in its documentation +that it looks up the tt(preferred-precipitation) style under the +`tt(:weather:)var(continent)tt(:)var(day-of-the-week)tt(:)var(phase-of-the-moon)' context. +According to this, you might set the following in your tt(zshrc): example(zstyle ':weather:europe:*' preferred-precipitation rain -zstyle ':weather:europe:germany:* preferred-precipitation none -zstyle ':weather:europe:germany:*:munich' preferred-precipitation snow) +zstyle ':weather:*:Sunday:*' preferred-precipitation snow) -Then, the fictional `tt(weather)' plugin might run under the hood a command -such as +Then the plugin would run under the hood a command such as -example(zstyle -s ":weather:${continent}:${country}:${county}:${city}" preferred-precipitation REPLY) +example(zstyle -s ":weather:${continent}:${day_of_week}:${moon_phase}" preferred-precipitation REPLY) in order to retrieve your preference into the scalar variable tt($REPLY). +On Sundays tt($REPLY) would be set to `tt(snow)'; in Europe it would be set +to `tt(rain)'; and on Sundays in Europe it would be set to `tt(snow)' again, +because the patterns `tt(:weather:europe:*)' and `tt(:weather:*:Sunday:*)' both +match the var(context) argument to tt(zstyle -s), are equally specific, and the +latter is more specific (because it has more colon-separated components). em(Usage) @@ -143,8 +150,9 @@ enditem() ) findex(zformat) xitem(tt(zformat -f) var(param) var(format) var(spec) ...) +xitem(tt(zformat -F) var(param) var(format) var(spec) ...) item(tt(zformat -a) var(array) var(sep) var(spec) ...)( -This builtin provides two different forms of formatting. The first form +This builtin provides different forms of formatting. The first form is selected with the tt(-f) option. In this case the var(format) string will be modified by replacing sequences starting with a percent sign in it with strings from the var(spec)s. Each var(spec) should be @@ -188,7 +196,13 @@ outputs "The answer is 'yes'." to tt(REPLY) since the value for the format specifier tt(c) is 3, agreeing with the digit argument to the ternary expression. -The second form, using the tt(-a) option, can be used for aligning +With tt(-F) instead of tt(-f), ternary expressions choose between the +`true' or `false' text on the basis of whether the format specifier is +present and non-empty. A test number indicates a minimum width for the +value given in the format specifier. Negative numbers reverse this, +so the test is for whether the value exceeds a maximum width. + +The form, using the tt(-a) option, can be used for aligning strings. Here, the var(spec)s are of the form `var(left)tt(:)var(right)' where `var(left)' and `var(right)' are arbitrary strings. These strings are modified by replacing the colons |