From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: 'typeset -p' of assocs (was: Re: PATCH: [key]=value syntax, work in progress)
Date: Thu, 14 Sep 2017 06:54:17 +0000 [thread overview]
Message-ID: <20170914065417.mbwmxpdkz33wjm56@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <30374.1505294044@thecus.kiddle.eu>
[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]
Oliver Kiddle wrote on Wed, Sep 13, 2017 at 11:14:04 +0200:
> It would be good to make typeset -p output use this new syntax by default
> for associative arrays because (without other cues like alignment) it
> can be clearer which items in the list are keys and which values.
I've been using a local patch that prints one space between key and its
value, but two spaces between value and the following key:
% typeset -p color
typeset -A color=( 00 none 01 bold 02 faint 03 standout 04 underline 05 blink 07 reverse 08 conceal 22 normal 23 no-standout 24 no-underline 25 no-blink 27 no-reverse 28 no-conceal 30 black 31 red 32 green 33 yellow 34 blue 35 magenta 36 cyan 37 white 39 default 40 bg-black 41 bg-red 42 bg-green 43 bg-yellow 44 bg-blue 45 bg-magenta 46 bg-cyan 47 bg-white 49 bg-default bg-black 40 bg-blue 44 bg-cyan 46 bg-default 49 bg-green 42 bg-grey 40 bg-magenta 45 bg-red 41 bg-white 47 bg-yellow 43 black 30 blink 05 blue 34 bold 01 conceal 08 cyan 36 default 39 faint 02 fg-black 30 fg-blue 34 fg-cyan 36 fg-default 39 fg-green 32 fg-grey 30 fg-magenta 35 fg-red 31 fg-white 37 fg-yellow 33 green 32 grey 30 magenta 35 no-blink 25 no-conceal 28 no-reverse 27 no-standout 23 no-underline 24 none 00 normal 22 red 31 reverse 07 standout 03 underline 04 white 37 yellow 33 )
I think I posted it once, but here it is again.
Cheers,
Daniel
[-- Attachment #2: 0001-Print-two-spaces-in-typeset-p-of-assocs.patch --]
[-- Type: text/x-diff, Size: 1431 bytes --]
>From 714da4bb3a26957cbd65058f7fb4afca85f82ee2 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Wed, 28 Sep 2016 13:15:04 +0000
Subject: [PATCH] Print two spaces in 'typeset -p' of assocs
(tweaked for upstream 39704/0f5e670cde5f844680a20f986786249dfe983584)
---
Src/params.c | 6 ++++--
Test/V10private.ztst | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Src/params.c b/Src/params.c
index ef72cba44..39af27c40 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5298,6 +5298,7 @@ printparamvalue(Param p, int printflags)
if (!(printflags & PRINT_KV_PAIR)) {
putchar('(');
putchar(' ');
+ putchar(' ');
}
{
HashTable ht = p->gsu.h->getfn(p);
@@ -5309,9 +5310,10 @@ printparamvalue(Param p, int printflags)
putchar(')');
break;
}
- if (printflags & PRINT_KV_PAIR)
+ if (printflags & PRINT_KV_PAIR) {
putchar(' ');
- else
+ putchar(' ');
+ } else
putchar('\n');
}
diff --git a/Test/V10private.ztst b/Test/V10private.ztst
index 7ebf5a87f..d1d9b0887 100644
--- a/Test/V10private.ztst
+++ b/Test/V10private.ztst
@@ -128,7 +128,7 @@
print ${(kv)hash_test}
0:private hides value from surrounding scope in nested scope
>typeset -a hash_test=( top level )
->typeset -A hash_test=( in function )
+>typeset -A hash_test=( in function )
>typeset -g -a hash_test=( top level )
>array-local top level
>top level
prev parent reply other threads:[~2017-09-14 6:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 20:51 PATCH: [key]=value syntax, work in progress Peter Stephenson
2017-09-11 20:56 ` Peter Stephenson
2017-09-12 20:25 ` Peter Stephenson
2017-09-12 20:28 ` Peter Stephenson
2017-09-13 7:13 ` Bart Schaefer
2017-09-13 8:53 ` Peter Stephenson
2017-09-13 16:44 ` Bart Schaefer
2017-09-14 20:48 ` Peter Stephenson
2017-09-19 1:13 ` Bart Schaefer
2017-09-13 9:14 ` Oliver Kiddle
2017-09-13 19:41 ` Peter Stephenson
2017-09-14 7:03 ` Daniel Shahaf
2017-09-14 20:38 ` Peter Stephenson
2017-09-16 10:30 ` Daniel Shahaf
2017-09-14 6:54 ` Daniel Shahaf [this message]
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=20170914065417.mbwmxpdkz33wjm56@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/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).