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: Eli Zaretskii <eliz <at> gnu.org>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: casouri <at> gmail.com, 59662 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, dgutov <at> yandex.ru, larsi <at> gnus.org, casouri <at> gmail.org
Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun
Date: Thu, 08 Dec 2022 10:27:39 +0200
> From: Theodor Thornhill <theo <at> thornhill.no>
> Cc: casouri <at> gmail.com, 59662 <at> debbugs.gnu.org, casouri <at> gmail.org
> Date: Thu, 08 Dec 2022 09:11:28 +0100
> 
> > Bonus points for adding something that could use treesit.el
> > capabilities, when those are available, instead of syntax-ppss, to
> > determine when we are in a comment or in a string.  Or maybe Theo or
> > Yuan could suggest such an addition.
> 
> This works perfectly as is in *-ts-modes.  At least for modes where
> syntax-table is set correctly.  I don't think there's a reason to enable
> treesit.el capabilities, unless there's a case where this doesn't work.

My point is that tree-sitter in many cases parses the program better
than syntax-ppss.  So if we can use its information about comments and
strings, why not do that?  It's exactly the same logic that Dmitry
used:

> +    (if (or (nth 8 (syntax-ppss))
> +            (re-search-forward comment-start-skip (line-end-position) t))

which falls back on regexp search if syntax-ppss cannot help.  I'm
asking why not try tree-sitter before we fall back on syntax-ppss or
regexp search?

Does that make sense?  If not, why not?

> If this ends up in master, should I backport some similar feature for
> the *ts-modes?

Why do we need this on the release branch?  A general
indent-or-fill-comment feature for all the progmodes didn't exist
until now, which is why we intend to install this on master.




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.