From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 560 invoked from network); 27 Apr 2020 10:07:57 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 27 Apr 2020 10:07:57 -0000 Received: (qmail 15132 invoked by alias); 27 Apr 2020 10:07:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45722 Received: (qmail 18545 invoked by uid 1010); 27 Apr 2020 10:07:46 -0000 X-Qmail-Scanner-Diagnostics: from wout1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25793. spamassassin: 3.4.4. Clear:RC:0(64.147.123.24):SA:0(-2.6/5.0):. Processed in 4.843406 secs); 27 Apr 2020 10:07:46 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrheelgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecuogfggedutddqvdejucdlgedtmdenucfjughrpefhvf fufffkofgggfestdektddtredttdenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcu oegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvgeqnecukfhppeejledrudektd drudeftddrudegjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] docs: Change zstyle example to a non-hierarchical one Date: Mon, 27 Apr 2020 10:06:57 +0000 Message-Id: <20200427100657.24000-1-danielsh@tarpaulin.shahaf.local2> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmail-Scanner-2.11: added fake Content-Type header Content-Type: text/plain --- Doc/Zsh/mod_zutil.yo | 23 +++++++++++++++-------- Test/V05styles.ztst | 13 +++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) 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/Test/V05styles.ztst index c221d9db8..9b5fc4517 100644 --- a/Test/V05styles.ztst +++ Test/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