Subject: bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode

From: Jostein Kjønigsen <[email-masked]>
Date: Tue, 6 Aug 2024 15:06:03 +0200

> On 6 Aug 2024, at 13:50, Eli Zaretskii <[email-masked]> wrote:
> 
>> Date: Tue, 06 Aug 2024 13:57:28 +0800
>> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <[email-masked]>
>> 
>> 
>> 
>> Steps to reproduce:
>> 
>> 1. Open a new buffer in `toml-ts-mode`.
>> 2. Insert the following simple snippets:
>> ```
>> # (forward-comment 1)
>> # [[keyboard.bindings]]
>> # chars = "a"
>> # key = "Tab"
>> # mods = "Alt"
>> ```
>> 3. Move the cursor to the first line and call `eval-last-sexp`.
>> 
>> This should move the cursor to the beginning of the line "chars = a", but actually it moves the cursor to the end of the whole block.
>> 
>> This might be an issue with `toml-ts-mode--syntax-table`.
>> 
>> Making a change in https://github.com/emacs-mirror/emacs/blob/e993e479c324bb720bca3f1cf194e55e32f01ccd/lisp/textmodes/toml-ts-mode.el#L53 can fix this issue:
>> 
>> ```
>> -    (modify-syntax-entry ?\n "> b"  table)
>> +    (modify-syntax-entry ?\n ">"  table)
>> ```
> 
> Thanks.
> 
> Jostein, could you please look into this?

Hey there. Let me see if I can help.

Just to be clear I understand the issue and how to reproduce it:

1. you create an empty buffer and activate toml-ts-mode
2. you paste in the supplied text, which is all comments according to TOML syntax
3. first line is actually a commented out emacs-lisp command.
4. you use (eval-last-sexp) to invoke the command emacs-lisp (forward-comment 1)

And once you do that, the expected outcome would be to jump to next comment-line (ie each commented line is considered its own comment-block)?

I ask, because if I do that, I get an *error* about reaching the end of file, so it seems like whatever I'm doing I'm getting slightly different results than you are. Applying the suggested fix does not seem to change behaviour either?

Yang: Have you loaded/compiled/provided the toml typescript-grammar before using this mode?

The *-ts-modes depends on external grammar in order to properly initialize the major-mode and provide correct highlighting and indentation.

--
Jostein