all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Daan Ro <daanturo@gmail.com>
Cc: "74412@debbugs.gnu.org" <74412@debbugs.gnu.org>,
	Eli Zaretskii <eliz@gnu.org>,
	"liaotx2@gmail.com" <liaotx2@gmail.com>
Subject: bug#74412: 31.0.50; Treesit-outline conflict with outli in Emacs 31
Date: Thu, 21 Nov 2024 19:58:16 +0200	[thread overview]
Message-ID: <875xogh3xk.fsf@mail.linkov.net> (raw)
In-Reply-To: <85CA4585-4E56-482E-AB91-2D0046D9B659@getmailspring.com> (Daan Ro's message of "Thu, 21 Nov 2024 15:16:14 +0700")

> 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)))))))))





      parent reply	other threads:[~2024-11-21 17:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-18  2:59 bug#74412: 31.0.50; Treesit-outline conflict with outli in Emacs 31 Taka Obsid
2024-11-18 12:29 ` Eli Zaretskii
2024-11-19  1:47   ` Taka Obsid
2024-11-19 15:37     ` Eli Zaretskii
2024-11-19 18:09 ` Juri Linkov
2024-11-20  3:34   ` Taka Obsid
2024-11-20  7:15     ` Juri Linkov
2024-11-20 14:06       ` Taka Obsid
2024-11-20 17:21         ` Juri Linkov
2024-11-20 18:23         ` Juri Linkov
2024-11-21  1:48           ` Taka Obsid
2024-11-21  6:51             ` Eli Zaretskii
2024-11-20 17:06 ` Daan Ro
2024-11-20 17:18   ` Juri Linkov
2024-11-20 17:51     ` Daan Ro
2024-11-20 18:25       ` Juri Linkov
2024-11-20 18:53     ` Eli Zaretskii
2024-11-20 18:50   ` Eli Zaretskii
2024-11-21  8:16     ` Daan Ro
2024-11-21  9:07       ` Eli Zaretskii
2024-11-23 20:46         ` Yuan Fu
2024-11-21 17:58       ` Juri Linkov [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xogh3xk.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=74412@debbugs.gnu.org \
    --cc=daanturo@gmail.com \
    --cc=eliz@gnu.org \
    --cc=liaotx2@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.