|
From: | Dmitry Gutov |
Subject: | bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun |
Date: | Thu, 8 Dec 2022 16:18:17 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
On 08/12/2022 10:56, Theodor Thornhill wrote:
(if (or (and (treesit-available-p) (treesit-ready-p (treesit-language-at (point))) (string-match-p treesit-comment-type-regexp (treesit-node-type (treesit-node-at (point)))))
I was kind of hoping that sometime in the near future our tree-sitter code would somehow plug into syntax-ppss (maybe via advice or etc) to provide the same results faster.
Or that we'd add similar helpers which would dispatch to either syntax-ppss or tree-sitter, depending on whether the latter is enabled and working.
The first approach will be more compatible for third-party code to use right now; the second will probably be more powerful. We might even do both.
As a result, a lot of functions won't have to reimplement the quoted part. Inside, and (more importantly) outside Emacs core.
So my preference would be to check in the implementation as-is (if everybody agrees with the behavior), and then migrate it to new helpers (in case plugging into syntax-ppss won't be automatic).
But I don't really mind the code you posted, if somebody (e.g. Eli) is going to insist on it. It just doesn't seem critical from the performance POV, and the variable treesit-comment-type-regexp seems to be a little out of place. But then again, if the helpers will be put in prog-mode.el, the var will be there as well.
[Prev in Thread] | Current Thread | [Next in Thread] |