GNU bug report logs - #76791
31.0.50; forward-list doesn't work in bash-ts-mode

Previous Next

Package: emacs;

Reported by: the_wurfkreuz <the_wurfkreuz <at> proton.me>

Date: Thu, 6 Mar 2025 21:04:01 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #16 received at control <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Yuan Fu <casouri <at> gmail.com>
Cc: the_wurfkreuz <the_wurfkreuz <at> proton.me>, 76791 <at> debbugs.gnu.org
Subject: Re: bug#76791: 31.0.50; forward-list doesn't work in bash-ts-mode
Date: Thu, 10 Apr 2025 19:21:10 +0300
close 76791 31.0.50
thanks

>> check_dirs_file() {
>>     if [ "$(wc -l "$dirs_file")" -gt 10 ]; then
>> tmp_dirs_file="$(mktemp)"
>> sed '1d' "$dirs_file" > "$tmp_dirs_file"
>> cp "$tmp_dirs_file" "$dirs_file"
>>     fi
>> }
>>
>> 3. M-x bash-ts-mode
>> 4. Move the cursor to the opening bracket of '$(mktemp)' and execute
>> 'forward-list'. It gives "No next group" message.
>
> The problem is that many tree-sitter grammars are so imperfect that even
> the current heuristics in 'treesit-forward-list' can't help to handle
> many cases.  Here are a few examples:
>
> 1. bash-ts-mode
>
>   $(a)
> =>
>   (command_substitution "$("
>    (command
>     name: (command_name (word)))
>    ")")
>
> Here the open paren is inside the node "$(".
>
> 2. ruby-ts-mode
>
>   "#{a}"
> =>
>   (string " (interpolation "#{" (identifier) "}") ")
>
> Here the open curly brace is inside the node "#{".
>
> 3. elixir-ts-mode
>
>   &(a)
> =>
>   (unary_operator operator: "&" operand: "(" (identifier) ")")
>
> Here the open paren is the second node "(" after "&".
>
> 4. go-ts-mode
>
>   switch a { }
> =>
>   (expression_switch_statement "switch" value: (identifier) "{" "}")
>
> Here the open curly brace is far from the sibling "switch" node.
>
> (A similar case in 'for_statement' is already handled
> surprisingly well by the current heuristics in 'treesit-forward-list'.)
>
> I see only 2 variants how to allow 'forward-list' to handle all cases:
>
> 1. Improve the current heuristics to decide when to fall back
>    to the default syntax-based navigation;
>
> 2. Explicitly specify the positions that should fall back
>    to the default syntax-based navigation.
>
> I can't find a better heuristics, so probably we need to have
> another thing 'sexp-list' that specifies when to use
> 'forward-sexp-default-function' and 'forward-list-default-function'.
>
> This patch solves all the above problems:

Now pushed and closed.




This bug report was last modified 94 days ago.

Previous Next


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