Log in

No account? Create an account
The way per-language auto-indentation works in emacs is really no… - Notes from a Medium-Sized Island [entries|archive|friends|userinfo]

[ website | My Website ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Jun. 14th, 2016|09:17 pm]

The way per-language auto-indentation works in emacs is really no small amount of black magic, apparently. Either you're lucky and you have a C-like language and you can sorta reuse c-mode, or else you write it all yourself (I think julialang did this from what I can tell) or else you use SMIE, which can do a lot for you, but it feels like giving well-intentioned vague suggestions to a feral indentation-djinn.

From: neelk
2016-06-15 10:41 am (UTC)
Woah! I had never heard of SMIE before. I always hacked up my own.

Anyway, something I've always meant to do, but never bothered with, was to use the Semantic package to get a proper parser, and use it to reformat buffers.
(Reply) (Thread)
[User Picture]From: jcreed
2016-06-15 12:12 pm (UTC)
Ohhhhh conversely I had not heard of semantic-mode. Thanks!
(Reply) (Parent) (Thread)
From: neelk
2016-06-16 08:51 am (UTC)
Yeah, emacs feels a lot like being a biologist in a rain forest. Every time you go outside to clean the gutters you discover a new species living in them. :)

Oh, also, js2-mode has a full Javascript parser which it uses for indentation. Might be worth looking at....
(Reply) (Parent) (Thread)