GNU bug report logs - #68899
Treesitter's forward-sexp-function

Previous Next

Package: emacs;

Reported by: João Távora <joaotavora <at> gmail.com>

Date: Fri, 2 Feb 2024 21:49:01 UTC

Severity: normal

Fixed in version 30.1

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: João Távora <joaotavora <at> gmail.com>
To: 68899 <at> debbugs.gnu.org, casouri <at> gmail.com
Subject: bug#68899: Treesitter's forward-sexp-function
Date: Sat, 3 Feb 2024 00:57:23 +0000
[Message part 1 (text/plain, inline)]
On Sat, Feb 3, 2024 at 12:42 AM João Távora <joaotavora <at> gmail.com> wrote:

> > This doesn't seem to break tests, assuming it's not in these 3 there
> > were skipped because I don't have the grammar installed.
>
> Despite that, I think it's still wrong :-/ Now it moves too much,
> i.e. it never stops moving.

This looks more promising.  Works well in my tests.

diff --git a/lisp/treesit.el b/lisp/treesit.el
index c6b9d8ff4bc..cad7497fb74 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -2579,9 +2579,12 @@ treesit--navigate-thing
             (setq parent (treesit-node-top-level parent thing t)
                   prev nil
                   next nil))
-          ;; If TACTIC is `restricted', the implementation is very simple.
+          ;; If TACTIC is `restricted', the implementation is reasonably
simple.
           (if (eq tactic 'restricted)
-              (setq pos (funcall advance (if (> arg 0) next prev)))
+              (setq pos (funcall advance (cond ((and (null next) (null
prev))
+                                                parent)
+                                               ((> arg 0) next)
+                                               (t prev))))
             ;; For `nested', it's a bit more work:
             ;; Move...
             (if (> arg 0)
[Message part 2 (text/html, inline)]

This bug report was last modified 1 year and 102 days ago.

Previous Next


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