evil-indent-textobject
evil-indent-textobject copied to clipboard
Subindents and empty lines
First, thanks for some of your amazing evil plugins.
I like this one but some of the behaviour decisions strike me as illogical. I've forked your code and made a version that I think works more as one would expect. I haven't submitted a pull request since it's not really a bug, more of an opinion. So I thought it'd give you a heads up.
First, subindents should be included. They are part of the same logical block after all, if you think of indents as forming a tree structure. (Which you should.)
def my_func(n):
|for _ in range(n):
print('hello')
print('done')
I would expect the whole body of the function to be selected, not just the line with the for statement.
Second, empty lines should be skipped. In the current implementation, these are considered to be lines with zero indentation, when in actuality they're just inserted for readability and should be ignored. In a perfect world, you would possibly also skip comments and continued multiline strings, but that's beyond my level of expertise.
Third, does your version work with mixed tabs and spaces? I didn't test, but since you're actually comparing strings instead of counting indentation, I suspect it might break in cases like that.
My fork with these changes is here: https://github.com/TheBB/evil-indent-textobject/
(Not the most elegant, I'm an elisp newbie.)
Thank you for the input! Sorry for the delay.
Ad 1: That's a good point and it really should include further indented lines. However, I'm not really happy with your code. Especially with the unbound variables in your > and >= functions. But I will definitely have a closer look into it!
Ad 2: Another good point, I'll change that (and have a look into the comments / string issue as well).
Ad 3: It's comparing the indentation strings, so consistent mixed indentations will work. Inconsistent mixed indentations will break, however, I'm not sure if I actually want to support those.
However, I'm not really happy with your code. Especially with the unbound variables in your > and >= functions.
If you look closely, the indent variables are actually let-bound.
I actually maintain my own copy of evil-indent-textobject which has been brutally edited. @TheBB has done a much better job than I.
Would love to see this merged; will have to use TheBB's fork until then.
For those interested, my fork now lives here and is on MELPA under the name evil-indent-plus.