From: Andries E. B. <And...@cw...> - 2008-04-10 21:38:02
|
Hi Alan! On Thu, Apr 10, 2008 at 08:38:28PM +0000, Alan Mackenzie wrote: >>> (defun ab-+-from-indentation-point (elt) >>> "Indent the line one step from the anchor point's line's indentation point." >>> (save-excursion >>> (goto-char (c-langelem-pos elt)) >>> (back-to-indentation) >>> (make-vector 1 (+ (current-column) c-basic-offset)))) >>> >>> , which you would have applied to your setup with C-c C-o for testing, >>> and then, more permanently, with >>> >>> (c-set-offset 'substatement 'ab-+-from-indentation-point) >>> >>> in your .emacs. :-) >> Perhaps. (I just tried precisely this and it failed. Have not >> investigated further.) > > Please do. I tested it first, and it worked for me. Last time I tested on the case with a block, and there it fails, now I see that with just nested "for"s it works. >>>> then cc-mode indents this as >>>> for (x=x0; x<x1; x++) for (y=y0; y<y1; y++) for (z=z0; z<z1; z++) { >>>> do_something(a[x][y], b[x][y], c[z], x, y, z); >>>> do_something_else(a[x][y]-b[x][y], x+y+z); >>>> } >>>> Strange and ugly. > >>> Funny, for me it does indent it the way you want. This works with style >>> "gnu". What have you got set on the "do_something(a[x]..." line? Please >>> do a C-c C-o, and tell me what it tells you. > >> On the do_something line ^C^O replies: statement-block-intro >> and ^C^S says: Syntactic analysis: >> ((substatement 3975) (substatement 3975) (statement-block-intro 3975)) > > Where exactly is the anchor point 3975 in your file? For me, it's at the > "for". Yes. More precisely, at the first, the outermost "for". >> I tried gnu instead of K&R, and also not specifying any style, >> and things changed but not to the desired state. > > Hmmm. "changed"? For the better? No. You know - 2 spaces instead of a tab and that kind of thing. (So instead of getting 3 tabs I got 6 spaces, while the for it should align with was indented 2 spaces.) Andries |