emacs - What are good *abstractions* for writing custom functions to autoindent code? -
this month i've spent time fighting emacs lisp try automatic indentation better meets needs. it's striking how low-level of indentation code is. i've seen small number of abstractions such as
- search first instance of regular expression not in string or comment
i suspect there many more useful abstractions out there write indentation code easier understand , easier modify. (even abstraction cite improved "apply function these arguments repeatedly until either function returns nil or point not in string or comment".)
i'm working emacs i've tagged question vim because i'll take ideas anywhere.
if wanted program clean, well-designed, modular, custom indentation functions, what abstractions use? (i happy see pointers code think uses abstractions or designed.)
it sounds you're looking higher level, macs 23 came smie, seeks solve generally. it's major-mode developers, not modify existing indentation behaviour.
edit: major abstractions appear be
a weak operator-precedence parser supplemented dirty-tricks lexer
each token gets notion of 'virtual indentation', appear if starting line
each token has 'parent' start of enclosing syntactic construct.
the cost of entry appears large, , software accompanied disclaimer:
in practice, [the] default indentation style not enough. want tweak in many different cases.
(edit ends)
what say:
search first instance of regular expression not in string or comment
is done calling syntax-ppss
, re-search-backward
.
Comments
Post a Comment