summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2023-03-05 15:22:36 -0800
committerYuan Fu <casouri@gmail.com>2023-03-05 15:22:36 -0800
commit1c67e4f895faf895f3ff132261edcbe6d08bb91d (patch)
tree2eee93fac27d630ddb7770442e8cd06be2568577
parentd724d7d6785db7224b5a9f04b092d8671bddd290 (diff)
downloademacs-1c67e4f895faf895f3ff132261edcbe6d08bb91d.tar.gz
Fix c-ts-mode indentation
Mentioned in bug#61893. * lisp/progmodes/c-ts-mode.el (c-ts-mode--anchor-prev-sibling): Handle "#elif" and "#else". * test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts: Add an "#elif" to the test.
-rw-r--r--lisp/progmodes/c-ts-mode.el3
-rw-r--r--test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts3
2 files changed, 6 insertions, 0 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 2c534aa785a..0b775b2d5c8 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -296,6 +296,9 @@ PARENT and BOL are like other anchor functions."
(setq prev-sibling (treesit-node-child prev-sibling -2)))
((or "preproc_elif" "preproc_else")
(setq prev-sibling (treesit-node-child prev-sibling -1)))
+ ((or "#elif" "#else")
+ (setq prev-sibling (treesit-node-prev-sibling
+ (treesit-node-parent prev-sibling) t)))
;; If the start of the previous sibling isn't at the
;; beginning of a line, something's probably not quite
;; right, go a step further.
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts b/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts
index a82596e0010..ce753b5b3ea 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts
@@ -89,6 +89,9 @@ int main() {
#else
if (f->output_method == output_termcap)
create_tty_output (f);
+#elif defined (HAVE_X_WINDOWS) /* X without toolkit. */
+ if (FRAME_WINDOW_P (f))
+ {}
#endif
t->display_info.tty->top_frame = selected_frame;
change_frame_size ();