GNU bug report logs - #59662
29.0.50; [PATCH] Add treesit--indent-defun

Previous Next

Package: emacs;

Reported by: Theodor Thornhill <theo <at> thornhill.no>

Date: Mon, 28 Nov 2022 19:33:01 UTC

Severity: wishlist

Tags: patch

Found in version 29.0.50

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Theodor Thornhill <theo <at> thornhill.no>, Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, 59662 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, casouri <at> gmail.org
Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun
Date: Thu, 8 Dec 2022 16:18:17 +0200
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.




This bug report was last modified 2 years and 158 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.