]> git.eshelyaron.com Git - emacs.git/commit
Fix c-ts-mode preproc directive indentation
authorYuan Fu <casouri@gmail.com>
Sat, 4 Mar 2023 22:39:44 +0000 (14:39 -0800)
committerYuan Fu <casouri@gmail.com>
Sat, 4 Mar 2023 23:03:12 +0000 (15:03 -0800)
commit836044f329a0a96810f2d88471cb040b9d373cce
treef0f8514874fd290f6d89fc63183d76f64231d7dd
parent64980a59b65245c450fedefa38c8140780d1a526
Fix c-ts-mode preproc directive indentation

Mentioned in bug#61893, although not the subject of that report.  This
change fixes indentation for nested directives.  For example, when the
directive involves elif and the like, the elif is nested in the if
directive, so simply using grand-parent and great-grand-parent for
anchor is insufficient, because the nesting can grow arbitrarily.

The test added also covers the last preproc fix.

* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--standalone-parent-skip-preproc): New function.
(c-ts-mode--indent-styles): New rules.
* test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts: New test.
lisp/progmodes/c-ts-mode.el
test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts