Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Emacs' indentation system is notoriously difficult to configure, so it's good to see some work being done in that area. However, the particular point described in the article is less exciting. I think every serious Emacs user who wants this behavior (binding RET to newline-and-indent) has it set up this way already anyway.

Some may consider it a good default behavior (though a matter of taste) for some modes (such as, e.g., programming language modes) but not for others (e.g. text-mode). The default behavior so far has been "no automatic indent" while now it will be "automatic indent". But since it will still be necessary for the user to maintain a list of modes s/he wants it enabled it for, therefore this change is really not such a big deal.

IMHO, the most pressing issue with indentation in Emacs is to make it easy for the user to adapt it, and especially to adjust certain edge cases. Given the mode-centered architecture of Emacs, this is a big challenge. But questions about very specific indentation preferences pop up on sites like stackoverflow all the time: people want to be able to say "I want a continuation of a line be indented by four spaces, except when the line break is in the middle of the argument list of a function definition -- then the arguments should all indent to the same column."

Coming up with a configurable indentation system that works for every mode would be very cool and thought-after feature.



I don't know if you were thinking about that, but Emacs provides smie (simple minded indentation engine) https://www.gnu.org/software/emacs/manual/html_node/elisp/SM...

used by tuareg-mode and sml-mode (AFAIK) with good results. I never used it personally but I felt it should be mentioned if someone else wants to dig into it.


The bounce indenter in Steve Yegge's js2-mode is an interesting approach:

   For any given line, there are some obvious possible indentation points:

    - whatever position Karl's guesser wants to use
    - the beginning of the line
    - after the '=' if the previous line is an assignment
    - same indentation as the previous line
    - first preceding line with less indentation than the preceding line

    [...]the TAB key cycles among them.
http://steve-yegge.blogspot.co.nz/2008_03_01_archive.html

It takes a lot of the frustration out of the indenter getting it wrong; in practice this doesn't cycle around tab points as much as you'd think.

And then there's cc-guess.el, which guesses your preferred indentation style by examining the current file. It would be soooooo nice if these ideas were available across all modes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: