1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00
emacs/doc
Yuan Fu 0f15286c53
New tree-sitter indent anchor standalone-parent used by c-ts-mode
When writing c-ts-mode Theo used parent-bol which works well except
one case:

1 for (int i=0;
2      i < 5;
3      i++) {
4   func(i);
5 }

In this case, when indenting "func(i)", parent-bol returns the start
of "i++" on line 3, instead of the "correct" anchor, the start of
"for" on line 1.  parent-bol would have worked if the "for (...) {"
part is in one line.

To support this case I tried numerous things and added a bunch of
stuff, culminating in c-ts-common-statement-offset.  It's complicated,
requires extra setup, and slow.

Not anymore! I think the new anchor standalone-parent really captures
the logic behind how people expect indentation to work. It's simple
and fast, and requires no setup.

* doc/lispref/modes.texi (Parser-based Indentation): Update manual.

* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--standalone-grandparent): New anchor.
(c-ts-mode--indent-styles): Replace c-ts-common-statement-offset with
standalone-parent.
(c-ts-base-mode): Add comment.

* lisp/treesit.el:
(treesit-simple-indent-presets): New anchor standalone-parent.
2023-02-26 21:38:22 -08:00
..
emacs ; Improve documentation of loading *.eln files 2023-02-26 19:51:59 +02:00
lispintro ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
lispref New tree-sitter indent anchor standalone-parent used by c-ts-mode 2023-02-26 21:38:22 -08:00
man ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
misc Eglot: simplify inlay hints implementation with jit-lock 2023-02-24 02:14:44 +00:00