bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60805: [PATCH] Extend go-ts-mode with command to add docstring to fu


From: Evgeni Kolev
Subject: bug#60805: [PATCH] Extend go-ts-mode with command to add docstring to function
Date: Sat, 21 Jan 2023 16:39:12 +0200

On Fri, Jan 20, 2023 at 10:39 PM Theodor Thornhill <theo@thornhill.no> wrote:
>
> By the way, the patch doesn't apply cleanly on my system, could you
> resend the patch as an attachment, maybe?  And also, have you done the
> paperwork for emacs contributions?
>

Sure, I'll attach it, and attach any future patches. I signed the
paperwork 4-5 years ago when making changes in perl-mode.
https://git.savannah.gnu.org/cgit/emacs.git/log/?qt=author&q=evgeni+kolev&showmsg=1

On Sat, Jan 21, 2023 at 5:30 AM Randy Taylor <dev@rjt.dev> wrote:
>
>
> Otherwise, it looks good to me. Thanks for continuing to work on go-ts-mode, 
> I should probably stop slacking so much ;).

Thank you for starting go-ts-mode - I was pleasantly surprised when I
found out it existed and even better - was part of emacs!

On Sat, Jan 21, 2023 at 8:48 AM Eshel Yaron <me@eshelyaron.com> wrote:
>
>
> A quick thought from someone interested in using this new command:
>
> IMO the current implementation is a bit too opinionated to be really
> useful.  Inserting the function's name at the beginning of the comment
> is not always desired because different teams have different conventions
> for doc comments, and sometimes you just want to add a nolint
> directive[0] which again doesn't start with the function's name.
>
> My suggestion is to add some way for users to customize/extend the
> contents of the inserted doc comment.  One option is to have a variable
> that'll hold a function responsible for determining the text of the
> comment.  This variable can then default to a function that returns the
> current Go function's name.

While I agree users should be able to customize, this particular
example is too much of a corner case.

For example, which Go functions/types need a docstring - all exported
ones, and possibly some unexported; on the other hand, adding linter
directives is so rare, you need to have a very good reason to add such
exceptions. Team-accepted exceptions are stored as accompanying config
files; example https://staticcheck.io/docs/configuration/#configuration-files

We can add a variable holding a function which will take a defun
treesit node as input, and return text. It's simple from
implementation point of view.

However, I don't see how this will make Emacs more useful - let's say
the user wants to enter a linter comment, will they:
1. modify the customization variable to another function, then C-c
C-d, then revert the customization variable; or
2. they can just enter the linter comment

As long as entering linter comments is rare, I believe the user will just do 2.

Attachment: 0001-Extend-go-ts-mode-with-command-to-add-docstring-to-f.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]