about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2020-04-27 10:06:57 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2020-05-02 00:51:26 +0000
commit5d9f7975a97a368ab16e1cd96a361a7594acdbbf (patch)
treeeb09736a51409954bddd7fe2a22b913cbf3d71aa
parent57a3a9a746cf6138fac76bf307a761d5ee3013a2 (diff)
downloadzsh-5d9f7975a97a368ab16e1cd96a361a7594acdbbf.tar.gz
zsh-5d9f7975a97a368ab16e1cd96a361a7594acdbbf.tar.xz
zsh-5d9f7975a97a368ab16e1cd96a361a7594acdbbf.zip
45722: docs: Change zstyle example to a non-hierarchical one
-rw-r--r--ChangeLog3
-rw-r--r--Doc/Zsh/mod_zutil.yo23
-rw-r--r--V05styles.ztst (renamed from Test/V05styles.ztst)13
3 files changed, 31 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index aba434c8c..e980c9187 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-05-02  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
+	* 45722: Doc/Zsh/mod_zutil.yo, V05styles.ztst: docs: Change
+	zstyle example to a non-hierarchical one
+
 	* 45752/0002: Completion/Unix/Command/_gcc: Complete --output
 	like -o.
 
diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo
index 812a1fd38..c69233f9d 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)
+example(zstyle ':weather:*:Sunday:*' preferred-precipitation snow
+zstyle ':weather:europe:*' preferred-precipitation rain)
 
-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 was defined first.
 
 em(Usage)
 
diff --git a/Test/V05styles.ztst b/V05styles.ztst
index c221d9db8..9b5fc4517 100644
--- a/Test/V05styles.ztst
+++ b/V05styles.ztst
@@ -151,3 +151,16 @@
 >one
 >two
 
+ (
+  zstyle ':weather:*:Sunday:*' preferred-precipitation snow
+  zstyle ':weather:europe:*' preferred-precipitation rain
+  zstyle -s ':weather:europe:Sunday:foo' preferred-precipitation REPLY && print $REPLY
+ )
+ (
+  zstyle ':weather:europe:*' preferred-precipitation rain
+  zstyle ':weather:*:Sunday:*' preferred-precipitation snow
+  zstyle -s ':weather:europe:Sunday:foo' preferred-precipitation REPLY && print $REPLY
+ )
+0:the example in the documentation remains correct
+>snow
+>rain