[Geany-devel] Parentheses auto-indentation
elextr at xxxxx
Tue Jun 8 02:34:13 UTC 2010
On 8 June 2010 00:43, Colomban Wendling <lists.ban at herbesfolles.org> wrote:
> Hi there!
> I'd very much like to see some auto-parentheses indentation in Geany. I mean
> that this kind of indentation would be auto-generated on typing:
> if (cond1 &&
> fun_call (param1,
> param2) &&
> another_call (param1,
> /* and so on */
> This includes:
> Indent new lines to match the position of the last opening parenthesis
> (lines 2, 3, 7);
> Automatically reduce indentation on closing parenthesis to fit the
> indentation of it's matching opening one (lines 4, 5, 8).
> I'm trying to get this to work (attached WIP patch, which works but have
> caveats), but I have a couple of problems (probably related to my little
> habit of Scintilla) and questions.
> First, the problems:
> How to know if a character is or not part of a comment, string or so? (e.g.
> should be interpreted as a syntactic element by itself) I need this to find
> the parenthesis -- and no, I can't do the same than brace_match() since I
> don't know the position of any of the parentheses.
The brace match indenting code needs fixing too, since it adjusts the
indent of a } in a comment!!!
Also brace_match ability to go forward and backward is wasted since it
is only ever called from close_brace which AFAICT is only ever called
with the current character a }
> Why brace_match() uses the character at (pos - 1) but the style at (pos)?
> This seems to be needed for brackets but breaks with parentheses (see
> comments in the WIP patch).
Hmmm, actually the question is how do braces work when it does that?
Probably pos is always > sci_get_end_styling since a } has just been
added to the buffer and the scintilla documentation says the charadded
notification is called before styling is done.
> And now the unique question (not that urgent since the patch isn't ready):
> how to add this as part of the auto-indentation? (I mean, always enable it
> -- I don't think everybody will like --, add a new indent method, a new
> separated setting, or what?)
I think it needs to be a separate setting, parentheses indent mode.
> Thanks for your help!
>  But if anybody would like to do this, I'd be happy to let him/her do :D
> Geany-devel mailing list
> Geany-devel at uvena.de
More information about the Devel