From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Evgeni Kolev Newsgroups: gmane.emacs.bugs Subject: bug#60805: [PATCH] Extend go-ts-mode with command to add docstring to function Date: Fri, 20 Jan 2023 13:39:21 +0200 Message-ID: References: <83ilh98sln.fsf@gnu.org> <87358dz6hy.fsf@thornhill.no> <83tu0t718s.fsf@gnu.org> <87sfgdtga2.fsf@thornhill.no> <875yd4njdc.fsf@thornhill.no> <87r0vpv7fp.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34343"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dev@rjt.dev, Eli Zaretskii , 60805@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 20 12:40:31 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIpl0-0008nm-DZ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 20 Jan 2023 12:40:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIpka-0000Gf-8g; Fri, 20 Jan 2023 06:40:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIpkY-0000G7-NG for bug-gnu-emacs@gnu.org; Fri, 20 Jan 2023 06:40:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIpkY-0006TS-Dj for bug-gnu-emacs@gnu.org; Fri, 20 Jan 2023 06:40:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pIpkX-0003JV-Nw for bug-gnu-emacs@gnu.org; Fri, 20 Jan 2023 06:40:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Evgeni Kolev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jan 2023 11:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60805 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60805-submit@debbugs.gnu.org id=B60805.167421479512557 (code B ref 60805); Fri, 20 Jan 2023 11:40:01 +0000 Original-Received: (at 60805) by debbugs.gnu.org; 20 Jan 2023 11:39:55 +0000 Original-Received: from localhost ([127.0.0.1]:45759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIpkR-0003GT-64 for submit@debbugs.gnu.org; Fri, 20 Jan 2023 06:39:55 -0500 Original-Received: from mail-qk1-f179.google.com ([209.85.222.179]:46727) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIpkP-0003Fq-CA for 60805@debbugs.gnu.org; Fri, 20 Jan 2023 06:39:54 -0500 Original-Received: by mail-qk1-f179.google.com with SMTP id z9so2718769qkl.13 for <60805@debbugs.gnu.org>; Fri, 20 Jan 2023 03:39:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wLxo96oySMzS0/2ZisEVPv8WU5g1sWFoON6gPGKeM0U=; b=R8LvTETlnZvhYHtNloq7vL8zJ94vozCZJW3Lpb6j2Zqa48MS/FyMUnO8wydzy1gwbB f9LFhYXfnFmvvtjCLcd/XMY9RE0is/SXaN7+DvABOC8hpZIaaK7/lR+NfUL1km32GmPm TG6GmnmWksuCx8BC9YG1m0faXFlY1jQuqTC/K/YOb+MHt5f4F9biB8KTdQ4+Ytuui4AK WrTdQ+xfbe4zg5QT7kp9GWDSluuokg1fAXvZC0ZjtW02/nXUwgGNIk7DKepTFlsnRVPu Gta+E4PZYPhawq93d2P8I2McQ5hntqr9Lo/Wv/FIQbN3t7WWbDypRJu/OVpkeAu3Js5h ys0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wLxo96oySMzS0/2ZisEVPv8WU5g1sWFoON6gPGKeM0U=; b=aA3dAqWN3twLJ/OdlIB0MI1Icvk8aVkvhGkrXoc8vy5d1BNhG7j8isbSwgLHul2IHh an+PPd9D4XT2/VhXMb8NcgEKAQ0y+1CVZx6oLHt4vnyIJ3UFKNBnHc8ZWxW6Qez3TjRu ol1au4wr0Oagi5SIDSxiSVP48Dzys8lJtxE8RVPDckFQpaI4JTDLMLYisj27uHWhP4Mg 5bab0vJAwbeq9mvwxZzmKFq4Gnq6mOAAg3luQBbRlbVr7hFQOq4rV5uDwn9lW7VlZaed ouOeASKz19IFqAbDyktdnVtXVEUkoee28hDVjM+kub2lF1P5LWqr7idboQEfJiUzxs/+ dPyw== X-Gm-Message-State: AFqh2kqKoQgaa79G0ci1I7Qt87qhKVwG/5GN07rx6xAZxchFSt3Toyjt llfgTRsZ2fjqKK5fd8TGL5WnJGKqGuc7NQDWE00= X-Google-Smtp-Source: AMrXdXsGnrfSeCQmaGW+M/53941Q/VOcQAxYqjUTnK6ub/Zu3NS5Sq8y3aKUzu6YgsV+bOX5Qy5ZKVxBWXS/82QzcMI= X-Received: by 2002:a37:8287:0:b0:706:4643:b6fb with SMTP id e129-20020a378287000000b007064643b6fbmr405903qkd.135.1674214787711; Fri, 20 Jan 2023 03:39:47 -0800 (PST) In-Reply-To: <87r0vpv7fp.fsf@thornhill.no> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253766 Archived-At: > 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