emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 d724d7d6785 2/3: Fix c-ts-mode indentation


From: Yuan Fu
Subject: emacs-29 d724d7d6785 2/3: Fix c-ts-mode indentation
Date: Sun, 5 Mar 2023 18:26:58 -0500 (EST)

branch: emacs-29
commit d724d7d6785db7224b5a9f04b092d8671bddd290
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Fix c-ts-mode indentation
    
    Mentioned in bug#61893, although not the subject of it.
    
    * lisp/progmodes/c-ts-mode.el:
    (c-ts-mode--anchor-prev-sibling): Fix the child index for preproc_else
    and preproc_elif case.
    * test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts:
    New test.
---
 lisp/progmodes/c-ts-mode.el                              |  4 +++-
 .../progmodes/c-ts-mode-resources/indent-preproc.erts    | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index ee4a3bb2de0..2c534aa785a 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -292,8 +292,10 @@ PARENT and BOL are like other anchor functions."
            (setq prev-sibling (treesit-node-child prev-sibling 2)))
           ;; Get the last statement in the preproc.  Tested by
           ;; "Prev-Sibling When Prev-Sibling is Preproc" test.
-          ((or "preproc_if" "preproc_ifdef" "preproc_elif" "preproc_else")
+          ((or "preproc_if" "preproc_ifdef")
            (setq prev-sibling (treesit-node-child prev-sibling -2)))
+          ((or "preproc_elif" "preproc_else")
+           (setq prev-sibling (treesit-node-child prev-sibling -1)))
           ;; 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 0f9256ad984..a82596e0010 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts
@@ -78,3 +78,19 @@ free_glyph_pool (struct glyph_pool *pool)
     }
 }
 =-=-=
+
+Name: Prev-Sibling Plus Preproc
+
+=-=-=
+int main() {
+#ifdef MSDOS
+  f->output_data.tty = &the_only_tty_output;
+  f->output_data.tty->display_info = &the_only_display_info;
+#else
+  if (f->output_method == output_termcap)
+    create_tty_output (f);
+#endif
+  t->display_info.tty->top_frame = selected_frame;
+  change_frame_size ();
+}
+=-=-=



reply via email to

[Prev in Thread] Current Thread [Next in Thread]