]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve support for preprocessor macros in 'c/c++-ts-mode'
authorEli Zaretskii <eliz@gnu.org>
Sat, 23 Mar 2024 09:09:57 +0000 (11:09 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 24 Mar 2024 14:21:01 +0000 (15:21 +0100)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--defun-name)
(c-ts-base-mode): Support preprocessor macros as defuns.  This
fixes both navigation by defuns and add-log when cpp macros are at
point.

(cherry picked from commit 2fb6f252bfe2cd06a49975bc97a794fb70392538)

lisp/progmodes/c-ts-mode.el

index a2e7f6fba2e54deb1ac17a73147916b0fd5bbc73..8383979a3733903e871d31b4a5ebdc96636f18de 100644 (file)
@@ -911,7 +911,8 @@ Return nil if NODE is not a defun node or doesn't have a name."
        t))
      ((or "struct_specifier" "enum_specifier"
           "union_specifier" "class_specifier"
-          "namespace_definition")
+          "namespace_definition"
+          "preproc_def" "preproc_function_def")
       (treesit-node-child-by-field-name node "name"))
      ;; DEFUNs in Emacs sources.
      ("expression_statement"
@@ -1205,7 +1206,9 @@ BEG and END are described in `treesit-range-rules'."
                                    "enum_specifier"
                                    "union_specifier"
                                    "class_specifier"
-                                   "namespace_definition")
+                                   "namespace_definition"
+                                   "preproc_def"
+                                   "preproc_function_def")
                                  (and c-ts-mode-emacs-sources-support
                                       '(;; DEFUN.
                                         "expression_statement"