all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Evgeni Kolev <evgenysw@gmail.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: dev@rjt.dev, Eli Zaretskii <eliz@gnu.org>, 60805@debbugs.gnu.org
Subject: bug#60805: [PATCH] Extend go-ts-mode with command to add docstring to function
Date: Fri, 20 Jan 2023 13:39:21 +0200	[thread overview]
Message-ID: <CAMCrgaW4Om8mbcOopttnp2qvYCM2RPYwGsEAbCHJpsEi96J2Ew@mail.gmail.com> (raw)
In-Reply-To: <87r0vpv7fp.fsf@thornhill.no>

> In that case, maybe it is even simpler to do something like:
>
> (defun defun-comment-p ()
>   (interactive)
>   (save-restriction
>     (narrow-to-defun t)
>     (goto-char (point-min))
>     (equal
>       (treesit-node-type (treesit-node-at (point)))
>       "comment")))

BTW I've noticed M-x mark-defun doesn't work correctly in some cases
with go-ts-mode (other *-gs-modes might also be affected, I haven't
tested). I wonder if narrow-to-defun could also be affected. For
example, with this Go code:

```
package main

func main() {

}

// some docstring
func main1() {

}
```
With the point in the body of "main1()", running M-x mark-defun marks
the blank line between the two functions instead of main1(). I'll
report this as a separate bug.

> However, now this code would act on code such as:
>
> ```
> //go:generate protoc .........
>
> // some docstring
> func main() {
>
> }
> ```
>
> And return point on the line with go:generate.  Is that desired?

I'd prefer to _not_ add special handling for "//go:..." comments which
are somewhat rare and typically put on the very first line of the
file. For your particular example the point should be put on "// some
docstring" because there's a separating blank line. This is not the
behavior with my patch - I'll try to improve it.


> Should we bind something to the C-c prefix?  I thought this was
> "user-reserved", so a user should bind them themselves.

I believe only "C-c letter" is user-reserved. I've drawn this
conclusion from here
https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html





  reply	other threads:[~2023-01-20 11:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14  6:45 bug#60805: [PATCH] Extend go-ts-mode with command to add docstring to function Evgeni Kolev
2023-01-14  7:48 ` Eli Zaretskii
2023-01-14 11:43   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-14 12:24     ` Eli Zaretskii
2023-01-14 13:08       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-18  6:26         ` Evgeni Kolev
2023-01-18 11:59           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-20  9:41             ` Evgeni Kolev
2023-01-20 10:14               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-20 11:39                 ` Evgeni Kolev [this message]
2023-01-20 14:56                   ` Evgeni Kolev
2023-01-20 20:39                     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-21  3:30                       ` Randy Taylor
2023-01-21  6:48                         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-21  7:34                           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-21 14:39                             ` Evgeni Kolev
2023-01-21 20:37                               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-21 21:26                               ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-18  7:46       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMCrgaW4Om8mbcOopttnp2qvYCM2RPYwGsEAbCHJpsEi96J2Ew@mail.gmail.com \
    --to=evgenysw@gmail.com \
    --cc=60805@debbugs.gnu.org \
    --cc=dev@rjt.dev \
    --cc=eliz@gnu.org \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.