]> git.eshelyaron.com Git - emacs.git/commitdiff
Detect DEFUNs as outline-minor-mode headings in Emacs sources in c-ts-mode.
authorJuri Linkov <juri@linkov.net>
Wed, 14 Feb 2024 07:20:48 +0000 (09:20 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 14 Feb 2024 08:17:15 +0000 (09:17 +0100)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--outline-predicate): When
c-ts-mode-emacs-sources-support is t, use c-ts-mode--emacs-defun-p
(bug#68824).

(cherry picked from commit fa74c7f88a8f3216665ea386c5b6355e3660fb79)

lisp/progmodes/c-ts-mode.el

index c4b48f03d125653e9613882eb571992957af9d11..4ef17daf8765a16528e3c56ae204297a503aeb8b 100644 (file)
@@ -926,12 +926,12 @@ Return nil if NODE is not a defun node or doesn't have a name."
 
 (defun c-ts-mode--outline-predicate (node)
   "Match outlines on lines with function names."
-  (and (treesit-node-match-p
-        node "\\`function_declarator\\'" t)
-       (when-let ((parent (treesit-node-parent node)))
-         (treesit-node-match-p
-          parent
-          "\\`function_definition\\'" t))))
+  (or (and (equal (treesit-node-type node) "function_declarator")
+           (equal (treesit-node-type (treesit-node-parent node))
+                  "function_definition"))
+      ;; DEFUNs in Emacs sources.
+      (and c-ts-mode-emacs-sources-support
+           (c-ts-mode--emacs-defun-p node))))
 
 ;;; Defun navigation