GNU bug report logs -
#60025
[PATCH] Add go-ts-mode and go-mod-ts-mode
Previous Next
Reported by: Randy Taylor <dev <at> rjt.dev>
Date: Tue, 13 Dec 2022 02:15:01 UTC
Severity: normal
Tags: patch
Done: Randy Taylor <dev <at> rjt.dev>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60025 in the body.
You can then email your comments to 60025 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
casouri <at> gmail.com, theo <at> thornhill.no, bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Tue, 13 Dec 2022 02:15:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Randy Taylor <dev <at> rjt.dev>
:
New bug report received and forwarded. Copy sent to
casouri <at> gmail.com, theo <at> thornhill.no, bug-gnu-emacs <at> gnu.org
.
(Tue, 13 Dec 2022 02:15:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
X-Debbugs-CC: casouri <at> gmail.com, theo <at> thornhill.no
I am having a tiny bit of trouble with a go.mod indentation rule. Using the patch, create a go.mod file anywhere, activate go-mod-ts-mode and add the following:
require ()
Place point inside the parens, and then hit enter. The expectation is that point will end up indented inside that block. If you add the text "test v1.0.0" and hit TAB, it will indent properly (and if you hit enter after that text it will indent properly for the next entry). If you go to the end of the line for the top paren and hit enter, it will not indent (and we want it to). It seems to give us no-node in that circumstance. Is there a simple indent rule that can match exactly that that I'm missing?
[Message part 2 (text/html, inline)]
[0001-Add-go-ts-mode-and-go-mod-ts-mode.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Tue, 13 Dec 2022 12:26:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 60025 <at> debbugs.gnu.org (full text, mbox):
> Cc: casouri <at> gmail.com, theo <at> thornhill.no
> Date: Tue, 13 Dec 2022 02:13:47 +0000
> From: Randy Taylor <dev <at> rjt.dev>
>
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -3078,6 +3078,11 @@ A major mode based on the tree-sitter library for editing CMake files.
> It includes support for font-locking, indentation, Imenu, and
> which-func.
>
> +** New major modes 'go-ts-mode' and 'go-mod-ts-mode'.
> +Major modes based on the tree-sitter library for editing programs in
> +the Go language. It includes support for font-locking, indentation,
> +Imenu, and which-func.
This should say something about go-mod-ts-mode, at least which files
it's supposed to support and for what purpose.
> +(add-to-list 'auto-mode-alist '("go\\.mod\\'" . go-mod-ts-mode))
Aren't the files's base name always exactly "go.mod" and nothing else?
If so, the regexp should be augmented, because we don't want to use
this moder for, say, foogo.mod or fubar-go.mod, right?
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Tue, 13 Dec 2022 19:40:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 60025 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tuesday, December 13th, 2022 at 07:25, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > Cc: casouri <at> gmail.com, theo <at> thornhill.no
>
> > Date: Tue, 13 Dec 2022 02:13:47 +0000
> > From: Randy Taylor dev <at> rjt.dev
> >
> > --- a/etc/NEWS
> > +++ b/etc/NEWS
> > @@ -3078,6 +3078,11 @@ A major mode based on the tree-sitter library for editing CMake files.
> > It includes support for font-locking, indentation, Imenu, and
> > which-func.
> >
> > +** New major modes 'go-ts-mode' and 'go-mod-ts-mode'.
> > +Major modes based on the tree-sitter library for editing programs in
> > +the Go language. It includes support for font-locking, indentation,
> > +Imenu, and which-func.
>
>
> This should say something about go-mod-ts-mode, at least which files
> it's supposed to support and for what purpose.
Indeed, thanks. I decided to split them up, and I also added that they will be auto-enabled.
> > +(add-to-list 'auto-mode-alist '("go\\.mod\\'" . go-mod-ts-mode))
>
>
> Aren't the files's base name always exactly "go.mod" and nothing else?
> If so, the regexp should be augmented, because we don't want to use
> this moder for, say, foogo.mod or fubar-go.mod, right?
Oops, that's right. Good catch.
[0001-Add-go-ts-mode-and-go-mod-ts-mode-Bug-60025.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Wed, 14 Dec 2022 02:23:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 60025 <at> debbugs.gnu.org (full text, mbox):
Randy Taylor <dev <at> rjt.dev> writes:
> On Tuesday, December 13th, 2022 at 07:25, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>
>> > Cc: casouri <at> gmail.com, theo <at> thornhill.no
>>
>> > Date: Tue, 13 Dec 2022 02:13:47 +0000
>> > From: Randy Taylor dev <at> rjt.dev
>> >
>> > --- a/etc/NEWS
>> > +++ b/etc/NEWS
>> > @@ -3078,6 +3078,11 @@ A major mode based on the tree-sitter library for editing CMake files.
>> > It includes support for font-locking, indentation, Imenu, and
>> > which-func.
>> >
>> > +** New major modes 'go-ts-mode' and 'go-mod-ts-mode'.
>> > +Major modes based on the tree-sitter library for editing programs in
>> > +the Go language. It includes support for font-locking, indentation,
>> > +Imenu, and which-func.
>>
>>
>> This should say something about go-mod-ts-mode, at least which files
>> it's supposed to support and for what purpose.
>
> Indeed, thanks. I decided to split them up, and I also added that they will be auto-enabled.
>
>> > +(add-to-list 'auto-mode-alist '("go\\.mod\\'" . go-mod-ts-mode))
>>
>>
>> Aren't the files's base name always exactly "go.mod" and nothing else?
>> If so, the regexp should be augmented, because we don't want to use
>> this moder for, say, foogo.mod or fubar-go.mod, right?
>
> Oops, that's right. Good catch.
Looks pretty good to me :-)
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Wed, 14 Dec 2022 12:03:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 60025 <at> debbugs.gnu.org (full text, mbox):
> Date: Tue, 13 Dec 2022 19:39:18 +0000
> From: Randy Taylor <dev <at> rjt.dev>
> Cc: 60025 <at> debbugs.gnu.org, theo <at> thornhill.no, casouri <at> gmail.com
>
> +** New major mode 'go-mod-ts-mode'.
> +A major mode based on the tree-sitter library for editing go.mod
> +files. It includes support for font-locking and indentation. This
> +mode will be auto-enabled for go.mod files.
Please quote go.mod as 'go.mod' (we quote file names and symbols in
NEWS).
Otherwise, this LGTM, thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Wed, 14 Dec 2022 16:22:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 60025 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Wednesday, December 14th, 2022 at 07:02, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > Date: Tue, 13 Dec 2022 19:39:18 +0000
>
> > From: Randy Taylor dev <at> rjt.dev
> > Cc: 60025 <at> debbugs.gnu.org, theo <at> thornhill.no, casouri <at> gmail.com
> >
> > +** New major mode 'go-mod-ts-mode'.
> > +A major mode based on the tree-sitter library for editing go.mod
> > +files. It includes support for font-locking and indentation. This
> > +mode will be auto-enabled for go.mod files.
>
>
> Please quote go.mod as 'go.mod' (we quote file names and symbols in
> NEWS).
>
> Otherwise, this LGTM, thanks.
>
Thanks, here's the new patch. I double-quoted it since that's what other file names and extensions have in NEWS - hopefully that's right. Assuming that's OK, should be good to install.
Yuan, did you see my original post in this thread? I'm wondering how to go about tackling that indentation problem (I'm probably missing something very simple and obvious).
[0001-Add-go-ts-mode-and-go-mod-ts-mode-Bug-60025.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Wed, 14 Dec 2022 19:56:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 60025 <at> debbugs.gnu.org (full text, mbox):
> On Dec 14, 2022, at 8:21 AM, Randy Taylor <dev <at> rjt.dev> wrote:
>
> On Wednesday, December 14th, 2022 at 07:02, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>
>>> Date: Tue, 13 Dec 2022 19:39:18 +0000
>>
>>> From: Randy Taylor dev <at> rjt.dev
>>> Cc: 60025 <at> debbugs.gnu.org, theo <at> thornhill.no, casouri <at> gmail.com
>>>
>>> +** New major mode 'go-mod-ts-mode'.
>>> +A major mode based on the tree-sitter library for editing go.mod
>>> +files. It includes support for font-locking and indentation. This
>>> +mode will be auto-enabled for go.mod files.
>>
>>
>> Please quote go.mod as 'go.mod' (we quote file names and symbols in
>> NEWS).
>>
>> Otherwise, this LGTM, thanks.
>>
>
> Thanks, here's the new patch. I double-quoted it since that's what other file names and extensions have in NEWS - hopefully that's right. Assuming that's OK, should be good to install.
>
> Yuan, did you see my original post in this thread? I'm wondering how to go about tackling that indentation problem (I'm probably missing something very simple and obvious).
Ah, oops, replies below:
> I am having a tiny bit of trouble with a go.mod indentation rule. Using the patch, create a go.mod file anywhere, activate go-mod-ts-mode and add the following:
>
> require ()
>
> Place point inside the parens, and then hit enter. The expectation is that point will end up indented inside that block. If you add the text "test v1.0.0" and hit TAB, it will indent properly (and if you hit enter after that text it will indent properly for the next entry). If you go to the end of the line for the top paren and hit enter, it will not indent (and we want it to). It seems to give us no-node in that circumstance. Is there a simple indent rule that can match exactly that that I'm missing?
I think you can just test for the parent? In C, if point is at an empty line after a statement in a block, like this:
int main() {
return 0;
|
}
The matched rule is (parent-is “compond_statement”), where compound_statement is the block. In your case, I guess you can test if parent is the argument list.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Wed, 14 Dec 2022 20:56:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 60025 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Wednesday, December 14th, 2022 at 14:55, Yuan Fu <casouri <at> gmail.com> wrote:
>
> > I am having a tiny bit of trouble with a go.mod indentation rule. Using the patch, create a go.mod file anywhere, activate go-mod-ts-mode and add the following:
> >
> > require ()
> >
> > Place point inside the parens, and then hit enter. The expectation is that point will end up indented inside that block. If you add the text "test v1.0.0" and hit TAB, it will indent properly (and if you hit enter after that text it will indent properly for the next entry). If you go to the end of the line for the top paren and hit enter, it will not indent (and we want it to). It seems to give us no-node in that circumstance. Is there a simple indent rule that can match exactly that that I'm missing?
>
>
> I think you can just test for the parent? In C, if point is at an empty line after a statement in a block, like this:
>
> int main() {
> return 0;
> |
> }
>
> The matched rule is (parent-is “compond_statement”), where compound_statement is the block. In your case, I guess you can test if parent is the argument list.
>
> Yuan
I do match for the parent, but it doesn't seem to help.
Here's what tree-sitter explorer shows for the following:
require (
)
(require_directive require ( \n ) \n)
If I put point on the line right below r and do C-S-a, tree-sitter explorer shows:
(require_directive require (*\n ) \n)
The * indicates that part is highlighted.
The second I make it "proper" like so:
require (
test v1
)
I can hit TAB and it will indent properly (but not anything above it, only that line and anything below).
I would think that checking parent-is for require_directive would be enough but it's not somehow???
It's instead matching my no-node rule...
(Also I attached a new patch which contains a few more indent rules for go.mod I forgot about).
[0001-Add-go-ts-mode-and-go-mod-ts-mode-Bug-60025.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Wed, 14 Dec 2022 21:28:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 60025 <at> debbugs.gnu.org (full text, mbox):
Randy Taylor <dev <at> rjt.dev> writes:
> On Wednesday, December 14th, 2022 at 14:55, Yuan Fu <casouri <at> gmail.com> wrote:
>>
>> > I am having a tiny bit of trouble with a go.mod indentation rule. Using the patch, create a go.mod file anywhere, activate go-mod-ts-mode and add the following:
>> >
>> > require ()
>> >
>> > Place point inside the parens, and then hit enter. The expectation is that point will end up indented inside that block. If you add the text "test v1.0.0" and hit TAB, it will indent properly (and if you hit enter after that text it will indent properly for the next entry). If you go to the end of the line for the top paren and hit enter, it will not indent (and we want it to). It seems to give us no-node in that circumstance. Is there a simple indent rule that can match exactly that that I'm missing?
>>
>>
>> I think you can just test for the parent? In C, if point is at an empty line after a statement in a block, like this:
>>
>> int main() {
>> return 0;
>> |
>> }
>>
>> The matched rule is (parent-is “compond_statement”), where compound_statement is the block. In your case, I guess you can test if parent is the argument list.
>>
>> Yuan
>
> I do match for the parent, but it doesn't seem to help.
> Here's what tree-sitter explorer shows for the following:
> require (
>
> )
>
> (require_directive require ( \n ) \n)
>
> If I put point on the line right below r and do C-S-a, tree-sitter explorer shows:
> (require_directive require (*\n ) \n)
> The * indicates that part is highlighted.
>
> The second I make it "proper" like so:
> require (
> test v1
> )
>
> I can hit TAB and it will indent properly (but not anything above it, only that line and anything below).
>
> I would think that checking parent-is for require_directive would be enough but it's not somehow???
> It's instead matching my no-node rule...
Yeah, I seem to remember seeing these \n nodes in the go-mode I made
some time ago. There is no node there, so no-node is the rule that
matches, as there is no parent. I believe you can solve it with
something like
(defun go-backward-up-list ()
(lambda (node parent bol &rest _)
(save-excursion
(backward-up-list 1 nil t)
(back-to-indentation)
(point))))
and use some variant of that. Now you can find a different node without
relying on there being a node where you start.
But I don't remember exactly.
BTW, I tried applying this mode, but it wouldn't apply.
Theo
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Wed, 14 Dec 2022 21:57:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 60025 <at> debbugs.gnu.org (full text, mbox):
On Wednesday, December 14th, 2022 at 16:27, Theodor Thornhill <theo <at> thornhill.no> wrote:
>
> Randy Taylor dev <at> rjt.dev writes:
>
> > On Wednesday, December 14th, 2022 at 14:55, Yuan Fu casouri <at> gmail.com wrote:
> >
> > > > I am having a tiny bit of trouble with a go.mod indentation rule. Using the patch, create a go.mod file anywhere, activate go-mod-ts-mode and add the following:
> > > >
> > > > require ()
> > > >
> > > > Place point inside the parens, and then hit enter. The expectation is that point will end up indented inside that block. If you add the text "test v1.0.0" and hit TAB, it will indent properly (and if you hit enter after that text it will indent properly for the next entry). If you go to the end of the line for the top paren and hit enter, it will not indent (and we want it to). It seems to give us no-node in that circumstance. Is there a simple indent rule that can match exactly that that I'm missing?
> > >
> > > I think you can just test for the parent? In C, if point is at an empty line after a statement in a block, like this:
> > >
> > > int main() {
> > > return 0;
> > > |
> > > }
> > >
> > > The matched rule is (parent-is “compond_statement”), where compound_statement is the block. In your case, I guess you can test if parent is the argument list.
> > >
> > > Yuan
> >
> > I do match for the parent, but it doesn't seem to help.
> > Here's what tree-sitter explorer shows for the following:
> > require (
> >
> > )
> >
> > (require_directive require ( \n ) \n)
> >
> > If I put point on the line right below r and do C-S-a, tree-sitter explorer shows:
> > (require_directive require (*\n ) \n)
> > The * indicates that part is highlighted.
> >
> > The second I make it "proper" like so:
> > require (
> > test v1
> > )
> >
> > I can hit TAB and it will indent properly (but not anything above it, only that line and anything below).
> >
> > I would think that checking parent-is for require_directive would be enough but it's not somehow???
> > It's instead matching my no-node rule...
>
>
> Yeah, I seem to remember seeing these \n nodes in the go-mode I made
> some time ago. There is no node there, so no-node is the rule that
> matches, as there is no parent. I believe you can solve it with
> something like
>
>
> (defun go-backward-up-list ()
> (lambda (node parent bol &rest _)
> (save-excursion
> (backward-up-list 1 nil t)
> (back-to-indentation)
> (point))))
>
> and use some variant of that. Now you can find a different node without
> relying on there being a node where you start.
>
> But I don't remember exactly.
Thanks, I'll give that a try.
>
> BTW, I tried applying this mode, but it wouldn't apply.
Applying the patch? It applies to emacs-29 fine for me, and both modes work as expected when I try them. What issue(s) are you seeing specifically?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 02:17:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 60025 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Wednesday, December 14th, 2022 at 16:27, Theodor Thornhill <theo <at> thornhill.no> wrote:
>
> Yeah, I seem to remember seeing these \n nodes in the go-mode I made
> some time ago. There is no node there, so no-node is the rule that
> matches, as there is no parent. I believe you can solve it with
> something like
>
>
> (defun go-backward-up-list ()
> (lambda (node parent bol &rest _)
> (save-excursion
> (backward-up-list 1 nil t)
> (back-to-indentation)
> (point))))
>
> and use some variant of that. Now you can find a different node without
> relying on there being a node where you start.
Thanks Theo, that worked perfectly. We should consider adding something like this to the documentation somewhere, since I didn't see anything like this anywhere (although maybe I missed it).
New patch attached with the following changes:
- go-mod-ts-mode--indent-rules modified to utilize the new function to check if in a directive, and if so, indent appropriately.
- New function go-mod-ts-mode--in-directive-p that checks if we're in a directive.
- I'm no elisp guru, so there may (probably) be a better way to do what I did. Happy to improve it (and the name and docstring, too).
Otherwise, feel free to install it.
[0001-Add-go-ts-mode-and-go-mod-ts-mode-Bug-60025.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 07:21:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 60025 <at> debbugs.gnu.org (full text, mbox):
Randy Taylor <dev <at> rjt.dev> writes:
> On Wednesday, December 14th, 2022 at 16:27, Theodor Thornhill <theo <at> thornhill.no> wrote:
>>
>> Yeah, I seem to remember seeing these \n nodes in the go-mode I made
>> some time ago. There is no node there, so no-node is the rule that
>> matches, as there is no parent. I believe you can solve it with
>> something like
>>
>>
>> (defun go-backward-up-list ()
>> (lambda (node parent bol &rest _)
>> (save-excursion
>> (backward-up-list 1 nil t)
>> (back-to-indentation)
>> (point))))
>>
>> and use some variant of that. Now you can find a different node without
>> relying on there being a node where you start.
>
> Thanks Theo, that worked perfectly. We should consider adding
> something like this to the documentation somewhere, since I didn't see
> anything like this anywhere (although maybe I missed it).
I'm glad! Could be part of a tips and tricks or something?
[...]
> +(defvar go-ts-mode--indent-rules
> + `((go
> + ((node-is ")") parent-bol 0)
> + ((node-is "]") parent-bol 0)
> + ((node-is "}") parent-bol 0)
> + ((node-is "labeled_statement") no-indent)
> + ((parent-is "argument_list") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "block") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "const_declaration") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "default_case") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "expression_case") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "expression_switch_statement") parent-bol 0)
> + ((parent-is "field_declaration_list") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "import_spec_list") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "labeled_statement") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "literal_value") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "type_spec") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "var_declaration") parent-bol go-ts-mode-indent-offset)
> + (no-node parent-bol 0)))
> + "Tree-sitter indent rules for `go-ts-mode'.")
No rules for comment?
[...]
> +;; go.mod support.
> +
> +(defvar go-mod-ts-mode--syntax-table
> + (let ((table (make-syntax-table)))
> + (modify-syntax-entry ?/ ". 124b" table)
> + (modify-syntax-entry ?\n "> b" table)
> + table)
> + "Syntax table for `go-mod-ts-mode'.")
> +
> +(defvar go-mod-ts-mode--indent-rules
> + `((gomod
> + ((node-is ")") parent-bol 0)
> + ((parent-is "exclude_directive") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "module_directive") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "replace_directive") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "require_directive") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "retract_directive") parent-bol go-ts-mode-indent-offset)
> + ((go-mod-ts-mode--in-directive-p) no-indent go-ts-mode-indent-offset)
> + (no-node no-indent 0)))
> + "Tree-sitter indent rules for `go-mod-ts-mode'.")
No rules for comment here either?
Theo
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 16:42:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 60025 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thursday, December 15th, 2022 at 02:20, Theodor Thornhill <theo <at> thornhill.no> wrote:
>
> Randy Taylor dev <at> rjt.dev writes:
>
> >
> > Thanks Theo, that worked perfectly. We should consider adding
> > something like this to the documentation somewhere, since I didn't see
> > anything like this anywhere (although maybe I missed it).
>
>
> I'm glad! Could be part of a tips and tricks or something?
I think it should probably be part of whatever indentation documentation there is.
>
> No rules for comment?
>
> [...]
>
> No rules for comment here either?
Which rules should I add?
I see these rules in some of the ts modes:
((and (parent-is "comment") comment-end) comment-start -1)
((parent-is "comment") comment-start-skip 0)
What are they matching? When could a comment be a parent?
(BTW attached a new patch with an updated NEWS entry after the recent changes there).
[0001-Add-go-ts-mode-and-go-mod-ts-mode-Bug-60025.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 18:07:01 GMT)
Full text and
rfc822 format available.
Message #44 received at 60025 <at> debbugs.gnu.org (full text, mbox):
On 15 December 2022 17:40:54 CET, Randy Taylor <dev <at> rjt.dev> wrote:
>On Thursday, December 15th, 2022 at 02:20, Theodor Thornhill <theo <at> thornhill.no> wrote:
>>
>> Randy Taylor dev <at> rjt.dev writes:
>>
>> >
>> > Thanks Theo, that worked perfectly. We should consider adding
>> > something like this to the documentation somewhere, since I didn't see
>> > anything like this anywhere (although maybe I missed it).
>>
>>
>> I'm glad! Could be part of a tips and tricks or something?
>
>I think it should probably be part of whatever indentation documentation there is.
>
>>
>> No rules for comment?
>>
>> [...]
>>
>> No rules for comment here either?
>
>Which rules should I add?
>
I like to set no-indent in a comment so that indentation commands don't format. That should be fillings job, imo :)
>I see these rules in some of the ts modes:
>((and (parent-is "comment") comment-end) comment-start -1)
>((parent-is "comment") comment-start-skip 0)
>
>What are they matching? When could a comment be a parent?
In some languages comment has a parent which is a comment. Just use inspect-mode inside of a comment and see what makes sense :)
>
>(BTW attached a new patch with an updated NEWS entry after the recent changes there).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 19:46:02 GMT)
Full text and
rfc822 format available.
Message #47 received at 60025 <at> debbugs.gnu.org (full text, mbox):
On Thursday, December 15th, 2022 at 13:06, Theodor Thornhill <theo <at> thornhill.no> wrote:
>
> On 15 December 2022 17:40:54 CET, Randy Taylor dev <at> rjt.dev wrote:
>
> > Which rules should I add?
>
>
> I like to set no-indent in a comment so that indentation commands don't format. That should be fillings job, imo :)
I don't know if I agree with that since the indentation commands should format comments if they are formatted incorrectly.
Fillings as in auto-fill-mode and the fill commands? I'm not familiar with those, beyond invoking fill-region and whatnot every now and then. I don't think any of that stuff is on by default though, right? It all requires manual invocation?
>
> > I see these rules in some of the ts modes:
> > ((and (parent-is "comment") comment-end) comment-start -1)
> > ((parent-is "comment") comment-start-skip 0)
> >
> > What are they matching? When could a comment be a parent?
>
>
> In some languages comment has a parent which is a comment. Just use inspect-mode inside of a comment and see what makes sense :)
c-ts-mode has those queries and I was never able to get a comment node as a parent so I guess they were either copy-pasted mistakenly or I am missing the magical invocation?
Aside from the aforementioned queries, I don't see any other comment-related indentation queries in any of the modes, and I can't think of any that should be introduced, at least for these modes.
Patch OK to install otherwise?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 20:00:02 GMT)
Full text and
rfc822 format available.
Message #50 received at 60025 <at> debbugs.gnu.org (full text, mbox):
Randy Taylor <dev <at> rjt.dev> writes:
> On Thursday, December 15th, 2022 at 13:06, Theodor Thornhill <theo <at> thornhill.no> wrote:
>>
>> On 15 December 2022 17:40:54 CET, Randy Taylor dev <at> rjt.dev wrote:
>>
>> > Which rules should I add?
>>
>>
>> I like to set no-indent in a comment so that indentation commands don't format. That should be fillings job, imo :)
>
> I don't know if I agree with that since the indentation commands should format comments if they are formatted incorrectly.
>
> Fillings as in auto-fill-mode and the fill commands? I'm not familiar with those, beyond invoking fill-region and whatnot every now and then. I don't think any of that stuff is on by default though, right? It all requires manual invocation?
>
>>
>> > I see these rules in some of the ts modes:
>> > ((and (parent-is "comment") comment-end) comment-start -1)
>> > ((parent-is "comment") comment-start-skip 0)
>> >
>> > What are they matching? When could a comment be a parent?
>>
>>
>> In some languages comment has a parent which is a comment. Just use inspect-mode inside of a comment and see what makes sense :)
>
> c-ts-mode has those queries and I was never able to get a comment node as a parent so I guess they were either copy-pasted mistakenly or I am missing the magical invocation?
>
> Aside from the aforementioned queries, I don't see any other comment-related indentation queries in any of the modes, and I can't think of any that should be introduced, at least for these modes.
>
> Patch OK to install otherwise?
Sure :-)
Theo
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 20:10:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 60025 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thursday, December 15th, 2022 at 14:59, Theodor Thornhill <theo <at> thornhill.no> wrote:
> Randy Taylor dev <at> rjt.dev writes:
>
> > Patch OK to install otherwise?
>
>
> Sure :-)
>
> Theo
Thanks.
Yuan, I've attached the latest and greatest patch (same as the one a few threads up but no need to make you hunt for it ;)). Ready to install whenever, unless anyone has any other comments.
[0001-Add-go-ts-mode-and-go-mod-ts-mode-Bug-60025.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Thu, 15 Dec 2022 22:24:02 GMT)
Full text and
rfc822 format available.
Message #56 received at 60025 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thursday, December 15th, 2022 at 15:09, Randy Taylor <dev <at> rjt.dev> wrote:
>
> On Thursday, December 15th, 2022 at 14:59, Theodor Thornhill theo <at> thornhill.no wrote:
>
> > Randy Taylor dev <at> rjt.dev writes:
> >
> > > Patch OK to install otherwise?
> >
> > Sure :-)
> >
> > Theo
>
>
> Thanks.
>
> Yuan, I've attached the latest and greatest patch (same as the one a few threads up but no need to make you hunt for it ;)). Ready to install whenever, unless anyone has any other comments.
Sorry, THIS attached patch is the latest and greatest patch. build.sh was changed recently renaming namespace to org, so I made that adjustment.
[0001-Add-go-ts-mode-and-go-mod-ts-mode-Bug-60025.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60025
; Package
emacs
.
(Fri, 16 Dec 2022 01:23:02 GMT)
Full text and
rfc822 format available.
Message #59 received at 60025 <at> debbugs.gnu.org (full text, mbox):
Randy Taylor <dev <at> rjt.dev> writes:
> On Thursday, December 15th, 2022 at 15:09, Randy Taylor <dev <at> rjt.dev> wrote:
>>
>> On Thursday, December 15th, 2022 at 14:59, Theodor Thornhill theo <at> thornhill.no wrote:
>>
>> > Randy Taylor dev <at> rjt.dev writes:
>> >
>> > > Patch OK to install otherwise?
>> >
>> > Sure :-)
>> >
>> > Theo
>>
>>
>> Thanks.
>>
>> Yuan, I've attached the latest and greatest patch (same as the one a
>> few threads up but no need to make you hunt for it ;)). Ready to
>> install whenever, unless anyone has any other comments.
>
> Sorry, THIS attached patch is the latest and greatest patch. build.sh was changed recently renaming namespace to org, so I made that adjustment.
Thanks! Great work. I applied the patch. And sorry for the change in
build.sh, I meant to modify your patch to rename namespaces to org but
apparently forgot.
Yuan
Reply sent
to
Randy Taylor <dev <at> rjt.dev>
:
You have taken responsibility.
(Fri, 16 Dec 2022 02:07:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Randy Taylor <dev <at> rjt.dev>
:
bug acknowledged by developer.
(Fri, 16 Dec 2022 02:07:02 GMT)
Full text and
rfc822 format available.
Message #64 received at 60025-done <at> debbugs.gnu.org (full text, mbox):
On Thursday, December 15th, 2022 at 20:22, Yuan Fu <casouri <at> gmail.com> wrote:
>
> Thanks! Great work. I applied the patch. And sorry for the change in
> build.sh, I meant to modify your patch to rename namespaces to org but
> apparently forgot.
>
> Yuan
Thanks! Closing.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 13 Jan 2023 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 215 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.