From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#68824: treesitter support for outline-minor-mode Date: Thu, 08 Feb 2024 10:30:17 +0200 Message-ID: <86zfwbwe7a.fsf@gnu.org> References: <86le8667u7.fsf@mail.linkov.net> <865xza39vp.fsf@gnu.org> <86y1c6q7oh.fsf@mail.linkov.net> <86mssbbdz5.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14029"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 68824@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 08 09:32:28 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 1rXzpc-0003Oe-GZ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Feb 2024 09:32:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXzpB-0001J7-5b; Thu, 08 Feb 2024 03:32:01 -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 1rXzp0-0001G9-Sm for bug-gnu-emacs@gnu.org; Thu, 08 Feb 2024 03:31:53 -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 1rXzoy-0007cY-0D for bug-gnu-emacs@gnu.org; Thu, 08 Feb 2024 03:31:48 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rXzpC-0004Re-7N for bug-gnu-emacs@gnu.org; Thu, 08 Feb 2024 03:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Feb 2024 08:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68824 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68824-submit@debbugs.gnu.org id=B68824.170738106817008 (code B ref 68824); Thu, 08 Feb 2024 08:32:02 +0000 Original-Received: (at 68824) by debbugs.gnu.org; 8 Feb 2024 08:31:08 +0000 Original-Received: from localhost ([127.0.0.1]:58973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXzoK-0004QF-2o for submit@debbugs.gnu.org; Thu, 08 Feb 2024 03:31:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44832) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXzoH-0004Pa-Vz for 68824@debbugs.gnu.org; Thu, 08 Feb 2024 03:31:06 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXznx-0007Tq-Du; Thu, 08 Feb 2024 03:30:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=JJ6yjQm4U5Qui6movD3D+07oxgzpRu4VTgWS/VKNM0U=; b=eWYuwLKLN+WU vq41EfroadA9tAWoOVxy43XPt/nKUrS4HdcC6gfbZx37SyL9yjGl3+ByoPcjeg7uUK2RaGKcokopq kfeImupl+3IFT1cVK5q7mqd/Sc3p2QO//8V5IhvA5ijUt61mH758gDAoVD8NoemyUZNUPvRVcR+ab 7y48Ixr1R+pt12qZbu3T/IJoPFgbhKYZRAMCCjVFcED1o8/uQKeGahZHMXs6pXum6H0qg3WYUcmWE +crPew5R7/OO21gR3tdva3UaG49J5QrISco9AlbDBlqtpAHQsR7BWihK4RpXm126qNV8xcsdCWdFZ V/WLxXpxiY6WmfwAy4VFZA==; In-Reply-To: <86mssbbdz5.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 08 Feb 2024 09:40:46 +0200) 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:279609 Archived-At: > From: Juri Linkov > Cc: casouri@gmail.com, 68824@debbugs.gnu.org > Date: Thu, 08 Feb 2024 09:40:46 +0200 > > > Here is a new patch with a shorter implementation. > > And I will send a complete patch with documentation changes later. > > So here is a complete patch with documentation changes: Thanks, some comments below. > --- a/doc/emacs/text.texi > +++ b/doc/emacs/text.texi > @@ -1097,6 +1097,11 @@ Outline Format > chapters. This works as long as no other command starts with > @samp{@@chap}. > > +@vindex outline-search-function > + Instead of setting the variable @code{outline-regexp}, you can set > +the variable @code{outline-search-function} to a function that > +matches the current heading and searches for the next one. This should tell which arguments will be passed to the function, and what it is expected to do and return. > --- a/doc/lispref/parsing.texi > +++ b/doc/lispref/parsing.texi > @@ -1895,6 +1895,10 @@ Tree-sitter Major Modes > @item > If @code{treesit-simple-imenu-settings} (@pxref{Imenu}) is > non-@code{nil}, it sets up Imenu. > + > +@item > +If @code{treesit-outline-predicate} is non-@code{nil}, it sets up > +Outline Minor Mode (@pxref{Outline Minor Mode,,, emacs, The GNU Emacs Manual}). > @end itemize There should be an index entry somewhere, probably right here, for treesit-outline-predicate. > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -130,6 +130,12 @@ the signature) the automatically inferred function type as well. > This user option controls outline visibility in the output buffer of > 'describe-bindings' when 'describe-bindings-outline' is non-nil. > > +** Outline Mode > + > +*** 'outline-minor-mode' is supported in tree-sitter major modes. > +It can be used in all tree-sitter major modes that set either the > +variable 'treesit-simple-imenu-settings' or 'treesit-outline-predicate'. If we don't need any more documentation, this entry should be marked with "+++". > +(defvar-local treesit-outline-predicate nil > + "Predicate used to find outline headings in the syntax tree. > +Intended to be set by a major mode. When nil, the predicate > +is constructed from the value of `treesit-simple-imenu-settings' > +when a major mode sets it.") The doc string should explain with what arguments will the predicate be called and when it is expected to return non-nil. > +(defun treesit-outline-predicate-from-imenu (node) > + "Return an outline searching predicate created from Imenu. > +Return the value suitable to set `treesit-outline-predicate'. > +Create this predicate from the value `treesit-simple-imenu-settings' > +that major modes set to find Imenu entries. The assumption here > +is that the positions of Imenu entries most of the time coincide > +with the lines of outline headings. When this assumption fails, > +you can directly set a proper value to `treesit-outline-predicate'." Likewise here: please describe in the doc string the signature and expectations from the predicate returned by this function (or point to the doc of some other variable/function where that information is included). > +(defun treesit-outline-search (&optional bound move backward looking-at) > + "Search for the next outline heading in the syntax tree. > +See the descriptions of arguments in `outline-search-function'." What about the return value (if it is important)?