From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74461: [PATCH] Add go-work-ts-mode Date: Thu, 21 Nov 2024 21:14:21 +0200 Message-ID: <865xogpfg2.fsf@gnu.org> References: <877c8wvp34.fsf@disroot.org> <86a5dspob9.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31155"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74461@debbugs.gnu.org To: Gabriel Santos Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 21 20:15:20 2024 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 1tECe6-0007wW-Ew for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Nov 2024 20:15:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tECds-0005LQ-IA; Thu, 21 Nov 2024 14:15: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 1tECdr-0005Kk-Gw for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 14:15:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tECdr-0001Qq-5j for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 14:15:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=7R5jWkvo63tCIS8azpEKvWirdB5rDi4ovZC3pTq0e/4=; b=WTQ4XHRRZKurOcqzrhk3IJRBGSBE8pcqQxdXlfE4RUlGEokOe0VXae9PQX0oRiT3fYWAEMxDgK0MuAvs1gxyVBNxSLtUqNCoNYwzwCkusJwE6TE1H1xR/Mi5VC48mA0sMAIktLNPCWWu9dNEKLothvyoNzo7S+GbZZej5qu0lHLB+T4AR3qS+7a2kjvW1Hnw9MzXDFf0+AvLxioYtEw8Tq0wfeDlIK5DmE1IVxGBmSlLcbtlKylv362Vgr6+4FOT/A3fizfJ6vj272cgmtIO/WV5kG9AFEgAeu3uaFYq83u2sxkZ4i+4RLxr7V8BfVmBOVoPYVwzQaI69jykgaVhYQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tECdp-00026B-UL for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 14:15:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Nov 2024 19:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74461 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74461-submit@debbugs.gnu.org id=B74461.17322164738014 (code B ref 74461); Thu, 21 Nov 2024 19:15:01 +0000 Original-Received: (at 74461) by debbugs.gnu.org; 21 Nov 2024 19:14:33 +0000 Original-Received: from localhost ([127.0.0.1]:51739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tECdM-00025C-Uk for submit@debbugs.gnu.org; Thu, 21 Nov 2024 14:14:33 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tECdK-00024t-Ic for 74461@debbugs.gnu.org; Thu, 21 Nov 2024 14:14:31 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tECdE-0001Oe-KF; Thu, 21 Nov 2024 14:14:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=7R5jWkvo63tCIS8azpEKvWirdB5rDi4ovZC3pTq0e/4=; b=gUsKce1TuqcB T43WKXGpnXdqY8mXxXg9Yem8E5O1NfpqIl7nKVGe2mFRVAO3oBbgfXgVPSpvYMvhWjvj7ieIj9aoH zA15rXg71U0B31XnnT+2dNgGFLWrNRA/jrbRV+gUQPFYXFp8q+hVDkGFzNugq2GOrH3cjtX7NI7s4 nso+a2x6t12jYBfAZj8/Yx04foKmLUUj4lSwiVLPoBWVAnrfitoBHv6IA2pbw6YtyPGXTqV0jgJdm 21b3bze26R92z4s/IgEDPqBI0DCtE1c30IYtoz/qKw0qjrNnMpFu3W04euRGnJNx5TTgI5gCmwLOg H4H/CMPFXdmz6u/1V9tVlg==; In-Reply-To: (message from Gabriel Santos on Thu, 21 Nov 2024 14:25:14 -0300) 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:295743 Archived-At: [Please use Reply All to reply, to keep the bug tracker CC'ed.] > Date: Thu, 21 Nov 2024 14:25:14 -0300 > From: Gabriel Santos > > >> Date: Thu, 21 Nov 2024 07:49:35 -0300 > >> From: Gabriel Santos via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" > >> > >> I wrote a tree-sitter mode after founding there wasn't one for Go > >> Workspace files. I'd like to say thanks to Randy Taylor on his work to > >> the Go tree-sitter mode, helped me a lot in this process. > >> > >> Commit message: > >> > >> * admin/notes/tree-sitter/build-module/batch.sh: > >> * admin/notes/tree-sitter/build-module/build.sh: Add go-work support. > >> * etc/NEWS: Mention go-work-ts-mode. > >> * lisp/progmodes/eglot.el (eglot-server-programs): Add go-work-ts-mode. > >> * lisp/progmodes/go-ts-mode: Add go-work-ts-mode for working with > >> workspace files. > >> > >> The parser can be found here: > >> https://github.com/omertuc/tree-sitter-go-work > > > >I think the parser URL should be mentioned in the comments in > >go-ts-mode.el. > > Thanks, got it. I'll also add the links to the other parsers too. This is helpful information for users, as some of > these aren't included in the tree-sitter organization (https://github.com/tree-sitter). > > >> I will mail my copyright assignment to the FSF still today. > > > >Thanks. > > On this, I missed the address of my house by a single number (astonishing how often I do this). To update > the data in my request, can I just send another e-mail? Yes, sure. > >> +--- > >> +** New major mode 'go-work-ts-mode'. > >> +A major mode based on the tree-sitter library for editing "go.work" > >> +files. It is auto-enabled for files which are named "go.work". > > > >The last sentence is factually inaccurate: the user needs to load > >go-ts-mode to have this mode auto-enabled, right? > > I got it from the original commit for the Go tree-sitter mode (fee2efe1b03 by Randy Taylor). I was working > quite late at night on this, so I didn't have time to reflect. You're right, this mode won't be auto-loaded since > tree-sitter modes currently require some user set-up to get working. > > >> +(defun go-work-ts-mode--in-directive-p () > >> + "Return non-nil if point is inside a directive. > > > >"inside a go-work directive", I presume? IOW, the doc string's first > >sentence sounds too general. > > Again, I took this from the original commit. I'm currently viewing the new version of the > `go-mod-ts-mode--in-directive-p' and the docstring is better written. I'll rewrite based on it, and also make > sure to check the current state of files instead. > > >> +(if (treesit-ready-p 'gowork) > >> + (add-to-list 'auto-mode-alist '("/go\\.work\\'" . go-work-ts-mode))) > > > >Wouldn't it be better to have this in the default value of > >auto-mode-alist, just conditioned by (treesit-ready-p 'gowork) ? That > >way, loading go-ts-mode will not change auto-mode-alist. > > > >Stefan, WDYT? > > This change was also included in the file already, so I followed it. Looking at the current values of > auto-mode-alist (lisp/files.el), I don't see any tree-sitter modes here. And other tree-sitter modes (see > list/progmodes/rust-ts-mode) also include the same behaviour. I don't have much knowledge on this matter, > so I'll let you decide on this. Tree-sitter modes are not listed where we have other modes for the same files, to avoid breaking past behavior. I don't think this danger is relevant to go.work files, but let's see what Stefan thinks about that. > Also, this is my first time on an e-mail workflow like this. Updating the patch based on your requests would > only require a rebase + new e-mail, or a rebase + reply to this thread? The latter. Using the same thread keeps all the discussions recorded as part of the same issue number, which is good for future reviewing of the discussion. For the same reason, please don't edit the Subject of the responses, so that they all keep the same Subject. Thanks.