[Geany-devel] Parentheses auto-indentation

Colomban Wendling lists.ban at xxxxx
Mon Jun 7 14:43:05 UTC 2010

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)[1], but I have a couple of problems (probably related to my
little habit of Scintilla) and questions.
First, the problems:

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

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

Thanks for your help!

[1] But if anybody would like to do this, I'd be happy to let him/her do :D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20100607/919d1b56/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: indent-matching-parentheses-draft.patch
Type: text/x-patch
Size: 4073 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100607/919d1b56/attachment.bin>

More information about the Devel mailing list