From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Users' List" <zsh-users@sunsite.dk>
Subject: Re: What would you say is the most-used way of indenting case labels
Date: Fri, 11 Aug 2006 20:37:41 +0100 [thread overview]
Message-ID: <200608111937.k7BJbfE6003802@pwslaptop.csr.com> (raw)
In-Reply-To: Message from Phil Pennock <phil.pennock@globnix.org> of "Fri, 11 Aug 2006 16:22:25 +0200." <20060811142225.GA15429@parhelion.globnix.org>
Phil Pennock wrote:
> % function foo { case $1 in (a) print alpha; print second; print third;;
> (b) print beta;; (*) print omega;;esac }
>
> % whence -f foo
> foo () {
> case $1 in
> (a) print alpha
> print second
> print third ;;
> (b) print beta ;;
> (*) print omega ;;
> esac
> }
Time for some audience participation. Do you prefer the following
style?
foo () {
case $1 in
(a) print alpha
print second
print third
;;
(b) print beta
;;
(*) print omega
;;
esac
}
Vote now. Lines are open.
Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.16
diff -u -r1.16 text.c
--- Src/text.c 10 Jan 2006 16:57:06 -0000 1.16
+++ Src/text.c 11 Aug 2006 19:33:59 -0000
@@ -530,14 +530,14 @@
taddstr(ecgetstr(state, EC_NODUP, NULL));
state->pc++;
taddstr(") ");
- tindent++;
n = tpush(code, 0);
n->u._case.end = end;
n->pop = (state->pc - 2 + WC_CASE_SKIP(code) >= end);
}
} else if (state->pc < s->u._case.end) {
- tindent--;
- taddstr(WC_CASE_TYPE(code) == WC_CASE_OR ? " ;;" : ";&");
+ if (tnewlins)
+ taddnl();
+ taddstr(WC_CASE_TYPE(code) == WC_CASE_OR ? ";;" : ";&");
if (tnewlins)
taddnl();
else
@@ -547,13 +547,13 @@
taddstr(ecgetstr(state, EC_NODUP, NULL));
state->pc++;
taddstr(") ");
- tindent++;
s->code = code;
s->pop = ((state->pc - 2 + WC_CASE_SKIP(code)) >=
s->u._case.end);
} else {
- tindent--;
- taddstr(WC_CASE_TYPE(code) == WC_CASE_OR ? " ;;" : ";&");
+ if (tnewlins)
+ taddnl();
+ taddstr(WC_CASE_TYPE(code) == WC_CASE_OR ? ";;" : ";&");
tindent--;
if (tnewlins)
taddnl();
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2006-08-11 19:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-11 10:54 Nikolai Weibull
2006-08-11 11:10 ` Peter Stephenson
2006-08-11 12:47 ` Nikolai Weibull
2006-08-11 12:48 ` Nikolai Weibull
2006-08-11 14:22 ` Phil Pennock
2006-08-11 19:37 ` Peter Stephenson [this message]
2006-08-12 15:28 ` Bart Schaefer
2006-08-12 16:44 ` Wayne Davison
2006-08-13 14:17 ` Phil Pennock
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=200608111937.k7BJbfE6003802@pwslaptop.csr.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-users@sunsite.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).