From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: zstyle+ (was: Re: List of unresolved issues)
Date: Mon, 17 Apr 2000 16:45:53 +0200 (MET DST) [thread overview]
Message-ID: <200004171445.QAA16702@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Fri, 14 Apr 2000 14:57:41 +0000
Bart Schaefer wrote:
> ... [ that function to make defining styles easier ]
>
> No problem. Name it something else, alias it back to zstyle, and make
> sure the completion autoloads use -U.
>
> ...
>
> Is "zstyle+" bad because it would mean a file with a '+' in it's name?
This adds Functions/Misc/zstyle+ (noone objected to that name).
Bye
Sven
--- /dev/null Mon Apr 17 16:43:47 2000
+++ Functions/Misc/zstyle+ Mon Apr 17 16:42:27 2000
@@ -0,0 +1,35 @@
+# This makes defining styles a bit simpler by using a single `+' as a
+# special token that allows to append a context name to the previously
+# used context name. Like this:
+#
+# zstyle+ ':foo:bar' style1 value1 \
+# + ':baz' style2 value2 \
+# + ':frob' style3 value3
+#
+# This defines style1 with value1 for the context :foo:bar as usual.
+# But it also defines styles2 with value2 for the context :foo:bar:baz
+# and style3 with value3 for :foo:bar:frob.
+# Of course, any of the sub-contexts after the plus signs may be
+# empty strings to re-use the previous context unchanged.
+#
+# If you don't want to change all your calls to `zstyle' to use
+# `zstyle+' you can use an alias `alias zstyle=zstyle+' and make sure
+# the completion functions are autoloaded without alias expansion (the
+# -U option to the autoload builtin). The completion system normally
+# loads its functions with without alias expansion.
+
+case "$1" in
+-*) zstyle "$@";;
+
+*) setopt localoptions noksharrays
+ integer i
+ local context="$1"
+ 1=''
+ for ((i=2; $#; ++i)); do
+ if [[ $i -gt $# || "$argv[i]" == '+' ]]; then
+ zstyle "$context${(@)argv[1,i-1]}"
+ shift "i > $# ? $# : i" # Stupid shift error on i > $#
+ i=1
+ fi
+ done;;
+esac
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~2000-04-17 14:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200004171445.QAA16702@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).