zsh-workers
 help / color / mirror / code / Atom feed
* Re: Bug#163190: zsh: Bad indentation in displayed shell function (whence -f)
       [not found] <E17x37s-0005VN-00@ay>
@ 2002-10-04 21:46 ` Clint Adams
  2002-10-25 13:01   ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Clint Adams @ 2002-10-04 21:46 UTC (permalink / raw)
  To: zsh-workers; +Cc: Vincent Lefevre, 163190-forwarded

In the following example, the subshell commands are not indented
uniformly.

> $ blah() { ( echo; echo; echo ) }
> $ whence -f blah
> blah () {
>         ( echo
>                 echo
>                 echo )
> }

Here's one possible fix.  Thoughts?

Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.11
diff -u -r1.11 text.c
--- Src/text.c	7 Jun 2002 14:44:25 -0000	1.11
+++ Src/text.c	4 Oct 2002 21:43:16 -0000
@@ -345,14 +345,16 @@
 	    break;
 	case WC_SUBSH:
 	    if (!s) {
-		taddstr("( ");
+		taddstr("(");
 		tindent++;
+		taddnl();
 		n = tpush(code, 1);
 		n->u._subsh.end = state->pc + WC_SUBSH_SKIP(code);
 	    } else {
 		state->pc = s->u._subsh.end;
 		tindent--;
-		taddstr(" )");
+		taddnl();
+		taddstr(")");
 		stack = 1;
 	    }
 	    break;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug#163190: zsh: Bad indentation in displayed shell function (whence -f)
  2002-10-04 21:46 ` Bug#163190: zsh: Bad indentation in displayed shell function (whence -f) Clint Adams
@ 2002-10-25 13:01   ` Oliver Kiddle
  2002-11-13 21:06     ` Clint Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2002-10-25 13:01 UTC (permalink / raw)
  To: Clint Adams; +Cc: zsh-workers, 163190-forwarded

On Fri, Oct 04, 2002 at 05:46:00PM -0400, Clint Adams wrote:
> In the following example, the subshell commands are not indented
> uniformly.
> 
> > $ blah() { ( echo; echo; echo ) }
> > $ whence -f blah
> > blah () {
> >         ( echo
> >                 echo
> >                 echo )
> > }
> 
> Here's one possible fix.  Thoughts?

That looks fine. You'd want to do the same for { ... } (WC_CURSH) too of
course.

The only thing better that I can think of would be to search ahead to see
if the sub shell contains anything more than one command. But that would
probably be more hassle than it's worth.

Oliver

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug#163190: zsh: Bad indentation in displayed shell function (whence -f)
  2002-10-25 13:01   ` Oliver Kiddle
@ 2002-11-13 21:06     ` Clint Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Clint Adams @ 2002-11-13 21:06 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-workers, 163190-forwarded

> That looks fine. You'd want to do the same for { ... } (WC_CURSH) too of
> course.

Okay, committing this one.

Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.11
diff -u -r1.11 text.c
--- Src/text.c	7 Jun 2002 14:44:25 -0000	1.11
+++ Src/text.c	13 Nov 2002 21:06:10 -0000
@@ -345,27 +345,31 @@
 	    break;
 	case WC_SUBSH:
 	    if (!s) {
-		taddstr("( ");
+		taddstr("(");
 		tindent++;
+		taddnl();
 		n = tpush(code, 1);
 		n->u._subsh.end = state->pc + WC_SUBSH_SKIP(code);
 	    } else {
 		state->pc = s->u._subsh.end;
 		tindent--;
-		taddstr(" )");
+		taddnl();
+		taddstr(")");
 		stack = 1;
 	    }
 	    break;
 	case WC_CURSH:
 	    if (!s) {
-		taddstr("{ ");
+		taddstr("{");
 		tindent++;
+		taddnl();
 		n = tpush(code, 1);
 		n->u._subsh.end = state->pc + WC_CURSH_SKIP(code);
 	    } else {
 		state->pc = s->u._subsh.end;
 		tindent--;
-		taddstr(" }");
+		taddnl();
+		taddstr("}");
 		stack = 1;
 	    }
 	    break;


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-13 21:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E17x37s-0005VN-00@ay>
2002-10-04 21:46 ` Bug#163190: zsh: Bad indentation in displayed shell function (whence -f) Clint Adams
2002-10-25 13:01   ` Oliver Kiddle
2002-11-13 21:06     ` Clint Adams

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).