From: Filippo Argiolas <filippo.argiolas@gmail.com>
To: 74448@debbugs.gnu.org
Subject: bug#74448: 30.0.92; c-ts-mode outlines only work with GNU or emacs style
Date: Wed, 20 Nov 2024 23:22:19 +0100 [thread overview]
Message-ID: <m2serlim04.fsf@gmail.com> (raw)
Hi, I've been playing with the new treesitter based outline minor mode
and c-ts-mode.
It seems that `outline-hide-subtree' is only working properly when code
is formatted with either GNU or emacs style.
To test try it with a function where the function declarator is preceded on the
same line by either type or storage class and type. It will fold the
function heading instead of the function body.
Problem seems `c-ts-mode--outline-predicate' only checks for
function_declarator nodes at the beginning of line (like in GNU coding
style) but other coding style will start the function line with either
storage class (e.g. static) or type.
Something like this seems to work a little better:
(defun c-ts-mode--outline-predicate (node)
"Match outlines on lines with function names."
(or (and (or (equal (treesit-node-type node) "function_declarator")
(equal (treesit-node-type node) "storage_class_specifier")
(equal (treesit-node-type node) "primitive_type")
(equal (treesit-node-type node) "type_identifier"))
(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))))
But it kind of breaks GNU style by adding two outlines per function
definition. Also it seems a bit ugly to enumerate all the node types by
hand, there probably is a nicer way to detect a line with a
function_declarator not at bol.
Any better idea?
Thanks,
Filippo
next reply other threads:[~2024-11-20 22:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 22:22 Filippo Argiolas [this message]
2024-11-21 7:42 ` bug#74448: 30.0.92; c-ts-mode outlines only work with GNU or emacs style Juri Linkov
2024-11-21 9:47 ` Filippo Argiolas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2serlim04.fsf@gmail.com \
--to=filippo.argiolas@gmail.com \
--cc=74448@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).