From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#74448: 30.0.92; c-ts-mode outlines only work with GNU or emacs style Date: Fri, 22 Nov 2024 09:39:16 +0200 Organization: LINKOV.NET Message-ID: <87o727ohf9.fsf@mail.linkov.net> References: <875xoh9gnw.fsf@mail.linkov.net> <87v7wge93a.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22232"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 74448@debbugs.gnu.org To: Filippo Argiolas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 22 08:51:15 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tEORf-0005cp-1e for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Nov 2024 08:51:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tEORb-0007Xt-P7; Fri, 22 Nov 2024 02:51:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tEORS-0007WH-OR for bug-gnu-emacs@gnu.org; Fri, 22 Nov 2024 02:51:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEORS-0003mD-F0 for bug-gnu-emacs@gnu.org; Fri, 22 Nov 2024 02:51:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=ZqYGlAur8SSjJx7yGutVqdG7lvHLEk0Nip+zaN/LiRc=; b=iNzx5IdqC+aCtOEfwvw7hgNiEFq85KuFIpr4mNDIQ+mpUnBe7sFnu2pI7a1J5QfPFiGc6oVsK5jhDhWn/QeQ9qcWQurPzVu+IuRd9GFAHtksDNlevnEvqnWSSCNIgH+nEy8jGFC02OSPu3ORcmgi8yO2JNi329jrs4rtiC4Un3GmnVplxZXIVsIjRSOUKwKhpRKJic8P3PHtwbkskU/WrOHDlnFOuXFoOj0OiJf8ZaRqzZgPphqmYEcuMX/wiqD5R3g+RT3feViIUs+s5s5axEoZSUE4L0zI/nI4sh1drCIMhCEBkkuHsHF/2NlWDY85YRSCJeQfByvpTo0r+/YL/w==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tEORS-0003YE-97 for bug-gnu-emacs@gnu.org; Fri, 22 Nov 2024 02:51:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Nov 2024 07:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74448 X-GNU-PR-Package: emacs Original-Received: via spool by 74448-submit@debbugs.gnu.org id=B74448.173226181113237 (code B ref 74448); Fri, 22 Nov 2024 07:51:02 +0000 Original-Received: (at 74448) by debbugs.gnu.org; 22 Nov 2024 07:50:11 +0000 Original-Received: from localhost ([127.0.0.1]:52901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEOQc-0003RN-JX for submit@debbugs.gnu.org; Fri, 22 Nov 2024 02:50:10 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:45399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEOQX-0003Q4-Qb for 74448@debbugs.gnu.org; Fri, 22 Nov 2024 02:50:06 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id C63E51C0003; Fri, 22 Nov 2024 07:49:57 +0000 (UTC) In-Reply-To: (Filippo Argiolas's message of "Fri, 22 Nov 2024 07:01:30 +0100") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295777 Archived-At: >> 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.