unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode
@ 2024-08-06  5:57 Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-08-06 11:50 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-08-06  5:57 UTC (permalink / raw)
  To: 72489



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)
```


Regards

yang






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode
  2024-08-06  5:57 bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-08-06 11:50 ` Eli Zaretskii
  2024-08-06 13:06   ` Jostein Kjønigsen
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-08-06 11:50 UTC (permalink / raw)
  To: Yang Yingchao, Jostein Kjønigsen; +Cc: 72489

> 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" <bug-gnu-emacs@gnu.org>
> 
> 
> 
> 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?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode
  2024-08-06 11:50 ` Eli Zaretskii
@ 2024-08-06 13:06   ` Jostein Kjønigsen
  2024-08-07  1:02     ` Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 6+ messages in thread
From: Jostein Kjønigsen @ 2024-08-06 13:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Yang Yingchao, Mr. Jostein Kjønigsen, 72489


> On 6 Aug 2024, at 13:50, Eli Zaretskii <eliz@gnu.org> 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" <bug-gnu-emacs@gnu.org>
>> 
>> 
>> 
>> 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






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode
  2024-08-06 13:06   ` Jostein Kjønigsen
@ 2024-08-07  1:02     ` Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-08-15 10:10       ` Jostein Kjønigsen
  0 siblings, 1 reply; 6+ messages in thread
From: Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-08-07  1:02 UTC (permalink / raw)
  To: Jostein Kjønigsen; +Cc: Eli Zaretskii, Mr. Jostein Kjønigsen, 72489

[-- Attachment #1: Type: text/plain, Size: 1434 bytes --]

> 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?

I think the error in your case also proves the misbehavior of forward-comment, and it breaks `uncomment-region' in my case. And with the suggested fix applied, and then recompile/evaluate, `uncomment-region' works as expected.

> 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.

I only have the required shared libraries (libtree-sitter.so & libtree-sitter-toml.so) installed. This should be enough, right? At least `treesit-explore-mode' works fine in toml buffer.

Regards,

-- *Yang Yingchao*

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode
  2024-08-07  1:02     ` Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-08-15 10:10       ` Jostein Kjønigsen
  2024-08-17  9:31         ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Jostein Kjønigsen @ 2024-08-15 10:10 UTC (permalink / raw)
  To: Yang Yingchao; +Cc: Eli Zaretskii, Mr. Jostein Kjønigsen, 72489

[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]


> On 7 Aug 2024, at 03:02, Yang Yingchao <yang.yingchao@qq.com> wrote:
> 
> I think the error in your case also proves the misbehavior of forward-comment, and it breaks `uncomment-region' in my case. And with the suggested fix applied, and then recompile/evaluate, `uncomment-region' works as expected.
> 
>> 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.
> 
> I only have the required shared libraries (libtree-sitter.so & libtree-sitter-toml.so) installed. This should be enough, right? At least `treesit-explore-mode' works fine in toml buffer.
> 
> Regards,
> 
> -- *Yang Yingchao*

I've recompiled from scratch and confirm this indeed fixes all issues mentioned.

Eli: Feel free to apply the supplied patch. I still don't have commit access :)

https://github.com/emacs-mirror/emacs/blob/e993e479c324bb720bca3f1cf194e55e32f01ccd/lisp/textmodes/toml-ts-mode.el#L53
> ```
> -    (modify-syntax-entry ?\n "> b"  table)
> +    (modify-syntax-entry ?\n ">"  table)
> ```


[-- Attachment #2: Type: text/html, Size: 2000 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode
  2024-08-15 10:10       ` Jostein Kjønigsen
@ 2024-08-17  9:31         ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2024-08-17  9:31 UTC (permalink / raw)
  To: Jostein Kjønigsen; +Cc: yang.yingchao, 72489-done, jostein

> From: Jostein Kjønigsen <jostein@secure.kjonigsen.net>
> Date: Thu, 15 Aug 2024 12:10:46 +0200
> Cc: Eli Zaretskii <eliz@gnu.org>,
>  "Mr. Jostein Kjønigsen" <jostein@kjonigsen.net>,
>  72489@debbugs.gnu.org
> 
>  On 7 Aug 2024, at 03:02, Yang Yingchao <yang.yingchao@qq.com> wrote:
> 
>  I think the error in your case also proves the misbehavior of forward-comment, and it breaks
>  `uncomment-region' in my case. And with the suggested fix applied, and then recompile/evaluate,
>  `uncomment-region' works as expected.
> 
>  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.
> 
>  I only have the required shared libraries (libtree-sitter.so & libtree-sitter-toml.so) installed. This should
>  be enough, right? At least `treesit-explore-mode' works fine in toml buffer.
> 
>  Regards,
> 
>  -- *Yang Yingchao*
> 
> I've recompiled from scratch and confirm this indeed fixes all issues mentioned.
> 
> Eli: Feel free to apply the supplied patch. I still don't have commit access :)
> 
> https://github.com/emacs-mirror/emacs/blob/e993e479c324bb720bca3f1cf194e55e32f01ccd/lisp/textmodes/toml-ts-mode.el#L53
> 
> 
>  ```
>  -    (modify-syntax-entry ?\n "> b"  table)
>  +    (modify-syntax-entry ?\n ">"  table)
>  ```

Thanks, installed on the emacs-30 branch, and closing the bug.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-17  9:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-06  5:57 bug#72489: 29.4.50; forward-comment not working as expected in toml-ts-mode Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-06 11:50 ` Eli Zaretskii
2024-08-06 13:06   ` Jostein Kjønigsen
2024-08-07  1:02     ` Yang Yingchao via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-15 10:10       ` Jostein Kjønigsen
2024-08-17  9:31         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).