[Geany-devel] Indentation using regex (was [PATCH 14/19] Rewrite tab switching queue)
techet at xxxxx
Tue Dec 6 16:46:29 UTC 2011
On Tue, Dec 6, 2011 at 08:27, Nathan Broadbent <nathan.f77 at gmail.com> wrote:
>> 1. calculate the indent each change, and then ripple that through the file
>> 2. calculate the indent each change and only apply it to this line
>> 3. calculate and apply the indent to lines N and N-1 only on new line
>> or user command
>> 4. calculate and apply the indent on user command
>> Option 1 is rejected because it is expensive and it will destroy
>> manually adjusted indentation when editing an existing line and
>> because indentation can change as you type causing distracting effects
>> (happens with some Emacs indentation styles)
>> Option 2 is rejected for the same reasons
>> Option 4 is rejected because auto new line indent is really the
>> minimum required to be called "auto" indentation
>> So that leaves option 3. The upside is that new lines get a sensible
>> indentation automatically, the downside is that lines that should be
>> unindented won't be until enter or user command. I have used another
>> editor that worked this way and after a while I became used to it.
>> Note that editing an existing line won't destroy manual indentation
>> unless you tell it to or create a new line after.
> Good auto-indentation is one of the last things I'm missing after my
> switch from Gedit to Geany. It was something that was handled really
> well by the 'Smart Indent' plugin. I would like to share a short video
> (1:24) of the indentation behavior that I grew accustomed to:
> This style of auto-indentation requires Option 1 or 2 (calculate for
> each change), because it unindents the 'end', 'elsif' and 'else'
> keywords as soon as their last characters are pressed.
> I did find this behavior very useful, even though I admit that it
> would sometimes destroy my manual indentation.
This is exactly what my regex-based indentation did and I assume what
Colomban's experiment does too. The problem Colomban was trying to
resolve was what to do when you have an end-block keyword "fi" which
should unindent and then have an identifier "file" (notice the "fi"
prefix) which shouldn't unindent. In this case there should be some
"undo indent" when you add more letters after "fi".
More information about the Devel