GNU bug report logs -
#74448
30.0.92; c-ts-mode outlines only work with GNU or emacs style
Previous Next
Reported by: Filippo Argiolas <filippo.argiolas <at> gmail.com>
Date: Wed, 20 Nov 2024 22:23:01 UTC
Severity: normal
Found in version 30.0.92
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 74448 <at> debbugs.gnu.org (full text, mbox):
>> Thanks, I confirm your solution is better than the current state.
>> Hope you could find a common denominator that covers all possible cases.
>
> Seems to work with the code I tested. Guess it's still not perfect, if a
> function declaration is splitted over multiple lines it will be folded
> where the function name is and I think that's what we want.
>
> A minor problem is with GNU style declarations type and storage class
> specifier will go in to the previous subtree when you collapse
> everything.
>
> But it's probably good enough. As far as I can tell the way it works now
> it folds from one outline to the next. The treesitter way would be to
> fold up to where the toplevel node ends.
>
> Maybe that's the job for a more specialized treesit folding package and
> this is already good for outline-minor-mode.
outline-minor-mode is designed to always fold from the current heading line
until the next heading line. Maybe outline-minor-mode could be extended
to detach the heading from the outline boundaries. For example,
by adding separate regexps/functions to match outline boundaries
while outline-regexp/outline-search-function will still be used
only for the heading line.
> By the way, the complete defun with Emacs source parsing restored is:
>
> (defun c-ts-mode--outline-predicate (node)
> "Match outlines on lines with function names."
> (or (when-let* ((decl (treesit-node-child-by-field-name
> (treesit-node-parent node) "declarator"))
> (node-pos (treesit-node-start node))
> (decl-pos (treesit-node-start decl))
> (eol (save-excursion (goto-char node-pos) (line-end-position))))
> (and (equal (treesit-node-type decl) "function_declarator")
> (<= node-pos decl-pos)
> (< decl-pos eol)))
> ;; DEFUNs in Emacs sources.
> (and c-ts-mode-emacs-sources-support
> (c-ts-mode--emacs-defun-p node))))
>
>
> Feel free to improve on this if you decide to install it, I never did
> the copyright assignment but I think it's trivial enough to enter
> without it.
Thanks, will test it more before installing.
This bug report was last modified 191 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.