bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60355: 29.0.60; Tree sitter incorrectly handles of PRED for treesit-


From: Wilhelm H Kirschbaum
Subject: bug#60355: 29.0.60; Tree sitter incorrectly handles of PRED for treesit-defun-type-regexp
Date: Wed, 28 Dec 2022 08:31:32 +0200
User-agent: mu4e 1.9.3; emacs 29.0.60


Thanks Yuan, just checked and both the fix and your suggestion works.

I see there is a typo in your last change:

@@ -310,7 +310,7 @@ java-ts-mode
  ;; Imenu.
  (setq-local treesit-simple-imenu-settings
              '(("Class" "\\`class_declaration\\'" nil nil)
- ("Interface "\\`interface_declaration\\'" nil nil) + ("Interface" "\\`interface_declaration\\'" nil nil)
                ("Enum" "\\`record_declaration\\'" nil nil)
                ("Method" "\\`method_declaration\\'" nil nil)))
  (treesit-major-mode-setup))


Yuan Fu <casouri@gmail.com> writes:

Wilhelm H Kirschbaum <wkirschbaum@gmail.com> writes:

When `treesit-defun-type-regexp` is set with a cons cell (regexp .
some-pred)
the following case does not get handled as expected when calling
(end-of-defun):

```elixir
defmodule Example do
 def foo() do ; regexp match, pred match
 end

 ;; <point here>
 @impl true    ; regexp match, pred does not match
 def bar() do  ; regexp match, pred match
 end
 ;; <should jump to here>

 def baz() do
 end
end
;; <jumps to point here>
```

Thank you very much! The root cause is actually another problem, but
anyway it is fixed now.

May I also suggest you to use this function for the predicate:

(defun elixir-ts-mode--capture-defun (node)
  ;; NODE should be a ‘call’ node.
  (member (treesit-node-text
           (treesit-node-child-by-field-name node "target"))
          elixir-ts-mode--definition-keywords))

This should be more accurate than the current one, and is IMO simpler
too.

Yuan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]