I finally had some time to have a look. I don't see any more issues, thank you for the fantastic work on this. The defun-type-regexp is not enough to identify a defun in elixir this is the query I am using currently: (defvar elixir--treesit-query-defun (let ((query `((call target: (identifier) @type (arguments [ (alias) @name (identifier) @name (call target: (identifier)) @name (binary_operator left: (call target: (identifier)) @name operator: "when") ]) (:match ,elixir--definition-keywords-re @type) )))) (treesit-query-compile 'elixir query))) Regex will work in most cases I guess, but does not really deal with more complex queries for more complex cases like in elixir as there is not one type which is always the defun. elixir relies heavily on macros and different defun macros can be defined on the fly. Maybe if there is an option for using either a regex or a function? I am also not sure how forward-sexp can work with the current treesit-search-forward-goto function as it does not take into consideration the level. Is there perhaps a way to move forward/backward, but do not jump to parents or children? On Mon, 24 Oct 2022 at 22:19, Yuan Fu wrote: > > > > Thanks, I would need some time to have a proper look. The reporting > issue > > seems to have been fixed. There are some complications to identify the > > appropriate node for defun in elixir as a "call" node might, or might > not be > > defun, depending on its child identifier ( i currently have to do a > query on > > cycling up the parent ), but will try the respond in more detail in > another > > thread. > > While fixing the hanging issue, I also improved > treesit-beginning-of-defun, which now first goes backward to find a node > that matches tresit-defun-type-regexp, then goes upward and finds the > top-most parent matching treesit-defun-type-regexp, IOW, it now only stops > at top-level defun matches. Does that help with your case? > > Yuan