[Geany-Users] new plugin for automatic alignment

Thomas Martitz kugel at xxxxx
Mon Nov 16 10:45:29 UTC 2015


Am 16.11.2015 um 11:36 schrieb Max Voss:
>
>
> Hello again,
>
> Sure, I can describe the algorithm:
>
> First it checks for the editor signal (although atm it just takes 
> /any/ "editor-notify" not just text change).
>
> Then it gets the line and checks if there is a symbol that has to be 
> aligned.
>
> Then it gets the adjecent lines and checks those too, for misaligned 
> symbols, indentation, and stop conditions like if there is a ":" in 
> that line, for example I don't want to align:
>
> a=1
> while a==1:
>     ...
>
> Then it splits the line into variables and arguments at the location 
> of the "=" , so left, right basically.


Is this plugin specific to python source code? Or can it auto-align (for 
example) C code as well?

>
> Then it strips the indentation white space and newline characters and 
> gets the max. length of a variable. All variable names that are 
> shorter than that get buffered with spaces until they're equal in length.
>
> The newlines get created with " indentation + variable + = + value "
>
> All the old lines and new lines get compiled into a block each, I 
> search the document for the entire old block, do some string slicing 
> and plug the new block into the old blocks place.
>
> Then all text gets set to the text with the plugged new block and the 
> cursor position gets set to the end of the new block.


Setting replacing the entire text has a serious drawback. The undo 
action that is recorded by scintilla will be large in memory, basically 
the size of the document. It seems auto-aligning is a frequent thing so 
this sounds troublesome.

Best regards


More information about the Users mailing list