[comp.emacs] C++ mode and <<

sane@cs.uiuc.edu (Aamod Sane) (12/12/90)

With the current C++ mode, I lines beginning with "<<" for output are
indented like the others.

i.e 
	cout << djfhsjdf << sdjfhsdhfjdf
	    << sjhfjshf << sdjfhjkdfh
		 << jsdhfjkhf dfhjksdhf 
		      << jdfhjhdfjhdf << \n

Can someone fix this to give

	cout << sjfjskdf << sdjfhsdkjf
	    << shfdjhf << jahdkjhskjdhf
	    << dhfjhda << sdfhjsdhfjkh
	    << jdhfkjsdhfhs << \n;

If the previous and current lines *begin* with << then indent them at one
indentation.

Thanks

Aamod Sane
-- 
sane@cs.uiuc.edu
         ==         / \  
-----    ==    *    \_/     -|||- 
         ==     

francis@sunquest.UUCP (Francis Sullivan) (12/13/90)

sane@cs.uiuc.edu (Aamod Sane) writes:

>With the current C++ mode, I lines beginning with "<<" for output are
>indented like the others.

>i.e 
>	cout << djfhsjdf << sdjfhsdhfjdf
>	    << sjhfjshf << sdjfhjkdfh
>		 << jsdhfjkhf dfhjksdhf 
>		      << jdfhjhdfjhdf << \n;

The same thing happens with quoted strings (in both c-mode and c++-mode):
    char * cp = "abcdefghijklmnopqrstyvwxyzABCDEDGHIJKLMNOPQRSTUVWXYZ"
	"abcdefghijklmnopqrstyvwxyzABCDEDGHIJKLMNOPQRSTUVWXYZ"
	    "abcdefghijklmnopqrstyvwxyzABCDEDGHIJKLMNOPQRSTUVWXYZ"
		"abcdefghijklmnopqrstyvwxyzABCDEDGHIJKLMNOPQRSTUVWXYZ";

I think that this is the same problem.  Even if it isn't, does someone
know how to fix it so that the three strings line up.
-- 
   Francis Sullivan			Sunquest Information Systems
   email: francis@sunquest.com  or	930 N. Finance Center Drive
   {uunet,arizona}!sunquest!francis	Tucson, AZ 85710	(602)885-7700

jackr@dblues.wpd.sgi.com (John (Jack) Repenning) (12/17/90)

In article <1990Dec11.174324.11176@julius.cs.uiuc.edu> sane@cs.uiuc.edu (Aamod Sane) wants:

Not this:
	   cout << djfhsjdf << sdjfhsdhfjdf
	       << sjhfjshf << sdjfhjkdfh
		    << jsdhfjkhf dfhjksdhf 
			 << jdfhjhdfjhdf << \n

but rather this:

	   cout << sjfjskdf << sdjfhsdkjf
	       << shfdjhf << jahdkjhskjdhf
	       << dhfjhda << sdfhjsdhfjkh
	       << jdhfkjsdhfhs << \n;

I think I agree with Aamod's sense of aesthetics.  In fact, I think I
would go a step further.  What c++-mode is doing with the "<<" lines
here is consistent with what it does with other continuation lines,
and I think I'd like Aamod's treatment applied there, too.  For
example:

	sum = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] +
	    a[8] + a[9] + a[10] + a[11] + a[12] + a[13] + a[14] +
		a[15] + a[16] + a[17] + a[18] + a[19] + a[20] + a[21]
		    + a[22] + a[23] + a[24] + a[25];

Wouldn't this look better like this?

	sum = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] +
	    a[8] + a[9] + a[10] + a[11] + a[12] + a[13] + a[14] +
	    a[15] + a[16] + a[17] + a[18] + a[19] + a[20] + a[21] +
	    a[22] + a[23] + a[24] + a[25]; 

It appears to me that the "<<" behavior is merely a consequence of
this more general behavior: what Aamod proposes specifically would be
some kind of special case, while changing the general behavior would
also fix Aamod's desires.  I suppose this hadn't up very often, even
in c-mode, until people started stringing "<<" together.

What I'm wondering is, is there some semantic confusion here I should
consider?  Does the cascading indentation represent some meaning that
ought to be preserved?  Does the columnar indentation suggest
something that it oughtn't?  What does this group's readership think?



----------------
Jack Repenning			9U-530			     jackr@wpd.sgi.com
Silicon Graphics, Inc.				            Off:(415) 335-7477