Re: [jasspa] Auto-indentation for Python
- Steven and Gabriel,
> I'm kind of in agreement here, by using the 'indent' mode pressing enterBut why does it lose the indentation level if the previous line contains
> will start a new line with the same indent as the previous line then you
> can either press 'tab' to indent more or 'S-tab' (shift-tab) to reduce the
only whitespaces? I often want to leave empty lines between statements which
are at the same indentation level, and after the empty line I certainly
don't want to hit tab several times to get back to the same indentation
I tried to find the code which implements the 'indent' mode but couldn't
find it. I guess it's written in C but emode.def's MDINDEN was about the
only thing I could find. Sure I grepped for MDINDEN but didn't find anything
interesting. Is there already a way to pass parameters to modes to finetune
their behavior? It'd be nice if the 'indent' mode could be configured to
maintain the indentation even when the previous line contains only
> Creating an indent rule would suggest that a 'restyle-buffer' should workIndeed, so no indent mode for Python then.
> The one thing that I think could be useful is doing a semi-automaticYes, that's good.
> indentation when the enter key is pressed. In this situation it could do
> some vaguely useful things, i.e. if the current line ends in a ':' then
> create a new line with an extra indent,
> if the current line is blank (just has white spaces) then remove all whiteBut I don't like this. IMHO it shouldn't remove whitespaces from the current
> spaces on the current line and create a new empty line with no indentation
line, and it definitely shouldn't lose the indentation on the next line.
Assuming that's what you meant by "no indentation", i.e. that the next line
wouldn't contain any whitespaces and the cursor would be at column 0.
It'd be much better if it would simply retain the indentation level even
when the previous line contains only whitespaces. That's exactly what GNU
Emacs does and I never need to hit tab when coding with it, which is nice.
Furthermore, to reduce the indentation by one level, there's no separate key
combination for it (like S-tab) but instead I simply hit backspace and it
eats one indentation level. (Assuming the cursor is right after the
indentation, of course.)
I actually wrote a quite primitive auto indentation because I wanted to
learn the macro language. It's long enough that I don't want to include it
in this mail, but it can be found here:
It's probably a bit amateurishly coded because I don't know all the tricks
of the language. For example, is there a better way to return values from a
macro than to set #p? variables? If I understood correctly, !return can
return only boolean values.
Anyway, it seems to work pretty much the way I like, and though it still
needs lots of improvements, it's already usable.