From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Juri Linkov <juri@linkov.net>
Newsgroups: gmane.emacs.bugs
Subject: bug#74412: 31.0.50; Treesit-outline conflict with outli in Emacs 31
Date: Thu, 21 Nov 2024 19:58:16 +0200
Organization: LINKOV.NET
Message-ID: <875xogh3xk.fsf@mail.linkov.net>
References: <86ikshspsm.fsf@gnu.org>
 <85CA4585-4E56-482E-AB91-2D0046D9B659@getmailspring.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="24249"; 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: "74412@debbugs.gnu.org" <74412@debbugs.gnu.org>,
 Eli Zaretskii <eliz@gnu.org>, "liaotx2@gmail.com" <liaotx2@gmail.com>
To: Daan Ro <daanturo@gmail.com>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 21 19:15:18 2024
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
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 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1tEBi2-00068Z-12
	for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Nov 2024 19:15:18 +0100
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1tEBho-0002RS-LX; Thu, 21 Nov 2024 13:15:04 -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 <Debian-debbugs@debbugs.gnu.org>)
 id 1tEBhn-0002Qo-4J
 for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 13:15:03 -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 <Debian-debbugs@debbugs.gnu.org>)
 id 1tEBhm-0005Qa-Rj
 for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 13:15: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=5RwXrT8yzGl9h15ia0EwEh40MQ9LV3GtxNV5HeSUSe4=; 
 b=C0WYmFkvWkRCHJfKNsXWBenoRTBqHhfX5M+qHMMVG1YHEjTIcZHiGYBnkJ8vvmQLSS0n2FkUDUbuWPIxBAVMHtzowHjr5dYei1Jl47kYtKWhObQraTwhzd2TNmaGM2MmEMoQOBlCnaGzIejy4eHxZRBjLmc3avDtdeEfw+EcM/KFAUih5m/vo88ae/dE116keej84W7BAS72R7+S5vMtIP/Fg3gXrjl0cH5BnYjdwiginPHU72OHdulm/AzPoWoZE+Er5c73gSRlnZO0t7tguPWD6vTkbQu8hXq6wWuprUMGXy9U/zjOtzwAD/H5fmGsVGSQE6MoGrVBlp5BJN2n/g==;
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tEBhm-0007j1-MA
 for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 13:15:02 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Juri Linkov <juri@linkov.net>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Thu, 21 Nov 2024 18:15:02 +0000
Resent-Message-ID: <handler.74412.B74412.173221286729615@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 74412
X-GNU-PR-Package: emacs
Original-Received: via spool by 74412-submit@debbugs.gnu.org id=B74412.173221286729615
 (code B ref 74412); Thu, 21 Nov 2024 18:15:02 +0000
Original-Received: (at 74412) by debbugs.gnu.org; 21 Nov 2024 18:14:27 +0000
Original-Received: from localhost ([127.0.0.1]:51625 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1tEBhC-0007ha-JY
 for submit@debbugs.gnu.org; Thu, 21 Nov 2024 13:14:26 -0500
Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:35083)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@linkov.net>) id 1tEBhA-0007hM-H3
 for 74412@debbugs.gnu.org; Thu, 21 Nov 2024 13:14:24 -0500
Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 26B54FF803;
 Thu, 21 Nov 2024 18:13:54 +0000 (UTC)
In-Reply-To: <85CA4585-4E56-482E-AB91-2D0046D9B659@getmailspring.com> (Daan
 Ro's message of "Thu, 21 Nov 2024 15:16:14 +0700")
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" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=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:295736
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/295736>

> The above is my use of outline-minor-mode, maybe other people have
> different use cases. treesit.el makes the configuration harder by the
> additional variable setting. I wish there's a hook like
> treesit-after-major-mode-setup-hook to let people fine-tune or even undo
> settings, but of course treesit-disable-features to prevent any
> execution from the start is still better.

If a ts-mode doesn't allow using a hook to override
mode's default settings, this would be a serious limitation.
But does such a limitation really exist?
It seems there is no need to add treesit-after-major-mode-setup-hook,
since I see no problem with using the existing hooks.
For example, such customization correctly overrides outline settings
for both non-ts and ts-modes:

  ;; non-ts
  (add-hook 'ruby-base-mode-hook
            (lambda ()
              ;; Add more Rails spec keywords
              (setq-local outline-regexp
                          (concat "^\\s *"
                                  (regexp-opt '("module" "class" "def" "private"
                                                "describe" "feature" "context" "before" "after"
                                                "it" "fit" "xit"))
                                  "\\_>"))))
  ;; same for ts-mode
  (add-hook 'ruby-ts-mode-hook
            (lambda ()
              ;; Add more Rails spec keywords
              (setq-local
               treesit-outline-predicate
               (lambda (node)
                 (or (string-match-p
                      (rx bos (or "module"
                                  "class"
                                  "singleton_class"
                                  "method"
                                  "singleton_method"
                                  "alias")
                          eos)
                      (treesit-node-type node))
                     (and (equal (treesit-node-type node) "call")
                          (if-let ((method (treesit-node-child-by-field-name
                                            node "method")))
                              (string-match-p
                               (rx bos (or "describe"
                                           "feature"
                                           "context"
                                           "before"
                                           "after"
                                           "it"
                                           "fit"
                                           "test")
                                   eos)
                               (treesit-node-text method)))))))))