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: Eli Zaretskii
Subject: bug#60805: [PATCH] Extend go-ts-mode with command to add docstring to function
Date: Sat, 14 Jan 2023 09:48:04 +0200

> Cc: Randy Taylor <dev@rjt.dev>
> From: Evgeni Kolev <evgenysw@gmail.com>
> Date: Sat, 14 Jan 2023 08:45:31 +0200
> 
> [CC Randy Taylor, author of go-ts-mode]
> 
> This patch extends go-ts-mode with a command to add docstring to
> current function. If a comment already exists, the point is instead
> moved to the top-most comment line.

Thanks.  When accepted, this should go to the master branch, as it's a
new feature.

> First test, with this input, point inside the function body.
> ```
> func test1(a, b int) int {
>     return a + b
> }
> ```
> 
> Pressing C-c C-d results in:
> ```
> // test1
> func test1(a, b int) int {
>     return a + b
> }
> ```

Is this really the best Emacs can do to produce such a comment?  It's
not a very useful comment, is it?  I understand that the user is then
expected to add some more meaningful text to make the comment useful,
but I'm asking whether Emacs could collect more information about the
function, and provide a skeleton of a useful doc comment for the user
to fill.

What do other IDEs do for this kind of functionality?

>     Extend go-ts-mode with command to add docstring to function
> 
>     go-ts-mode is extended with command go-ts-mode-docstring which adds
>     docstring comment to the defun at point. If a comment already exists,
                                             ^^
Please observe our convention of leaving 2 spaces between sentences.

> +(defun go-ts-mode-docstring ()
> +    "Add docstring for the current function if it does not
> +exists. Otherwise, jump to it."

The first line of a doc string should be a complete sentence.

Finally, this change needs a NEWS entry.





reply via email to

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