From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 1e07d5b8 for ; Mon, 13 Jan 2020 17:42:11 +0000 (UTC) Received: (qmail 23947 invoked by alias); 13 Jan 2020 17:42:04 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24656 Received: (qmail 9416 invoked by uid 1010); 13 Jan 2020 17:42:04 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25691. spamassassin: 3.4.2. Clear:RC:0(66.111.4.26):SA:0(-2.6/5.0):. Processed in 5.763651 secs); 13 Jan 2020 17:42:04 -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: gggruggvucftvghtrhhoucdtuddrgedufedrvdejtddguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujggfsehttddttddtredvnecuhfhrohhmpeffrghn ihgvlhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqe enucfkphepjeelrddukedtrdehjedrudduleenucfrrghrrghmpehmrghilhhfrhhomhep ugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvnecuvehluhhsthgvrhfuihiivg eptd X-ME-Proxy: Date: Mon, 13 Jan 2020 17:41:21 +0000 From: Daniel Shahaf To: Pier Paolo Grassi Cc: Zsh-Users List Subject: [PATCH] docs: Add an example of setting and querying zstyles (was: Re: problem with context specification) Message-ID: <20200113174121.GA8678@tarpaulin.shahaf.local2> References: <20200113170630.GA8134@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200113170630.GA8134@tarpaulin.shahaf.local2> User-Agent: Mutt/1.10.1 (2018-07-13) diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo index 1e35d2245..e556e2b37 100644 --- a/Doc/Zsh/mod_zutil.yo +++ b/Doc/Zsh/mod_zutil.yo @@ -17,18 +17,37 @@ item(tt(zstyle -m) var(context) var(style) var(pattern))( This builtin command is used to define and lookup styles. Styles are pairs of names and values, where the values consist of any number of strings. They are stored together with patterns and lookup is done by -giving a string, called the `context', which is compared to the -patterns. The definition stored for the first matching pattern will be -returned. +giving a string, called the `em(context)', which is matched against the +patterns. The definition stored for the most specific pattern that matches +will be returned. -For ordering of comparisons, patterns are searched from most specific to -least specific, and patterns that are equally specific keep the order in -which they were defined. A pattern is considered to be more specific +A pattern is considered to be more specific than another if it contains more components (substrings separated by colons) or if the patterns for the components are more specific, where simple strings are considered to be more specific than patterns and complex patterns are considered to be more specific than the pattern -`tt(*)'. +`tt(*)'. A `tt(*)' in the pattern will match zero or more characters +in the context; colons are not treated specially in this regard. +If two patterns are equally specific, the tie is broken in favour of +the pattern that was defined first. + +em(Example) + +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): + +example(zstyle ':weather:europe:*' preferred-precipitation rain +zstyle ':weather:europe:germany:* preferred-precipitation none +zstyle ':weather:europe:germany:*:munich' preferred-precipitation snow) + +Then, the fictional `tt(weather)' plugin might run under the hood a command +such as + +example(zstyle -s ":weather:${continent}:${country}:${county}:${city}" preferred-precipitation REPLY) + +in order to retrieve your preference into the scalar variable tt($REPLY). + +em(Usage) The first form (without arguments) lists the definitions. Styles are shown in alphabetic order and patterns are shown in the order @@ -39,7 +58,7 @@ tt(zstyle). The optional first argument is a pattern which will be matched against the string supplied as the pattern for the context; note that this means, for example, `tt(zstyle -L ":completion:*")' will match any supplied pattern beginning `tt(:completion:)', not -just tt(":completion:*"): use tt(":completion:\*") to match that. +just tt(":completion:*"): use tt(':completion:\*') to match that. The optional second argument limits the output to a specific var(style) (not a pattern). tt(-L) is not compatible with any other options.