From unknown Mon Aug 18 11:16:19 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#74298 <74298@debbugs.gnu.org> To: bug#74298 <74298@debbugs.gnu.org> Subject: Status: [PATCH] ; Improve comment indenting in 'lua-ts-mode' Reply-To: bug#74298 <74298@debbugs.gnu.org> Date: Mon, 18 Aug 2025 18:16:19 +0000 retitle 74298 [PATCH] ; Improve comment indenting in 'lua-ts-mode' reassign 74298 emacs submitter 74298 john muhl severity 74298 normal tag 74298 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 13:58:34 2024 Received: (at submit) by debbugs.gnu.org; 10 Nov 2024 18:58:35 +0000 Received: from localhost ([127.0.0.1]:56614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAD8s-0008Fv-MM for submit@debbugs.gnu.org; Sun, 10 Nov 2024 13:58:34 -0500 Received: from lists.gnu.org ([209.51.188.17]:36480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAD8r-0008Fo-1e for submit@debbugs.gnu.org; Sun, 10 Nov 2024 13:58:34 -0500 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 1tAD8q-0005dR-Fx for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2024 13:58:32 -0500 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAD8n-0001B2-87 for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2024 13:58:30 -0500 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfout.stl.internal (Postfix) with ESMTP id A4395114014B for ; Sun, 10 Nov 2024 13:58:26 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Sun, 10 Nov 2024 13:58:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1731265106; x=1731351506; bh=MC2osc/GQkRUavgJIimeF30YTVqRGns5 bBCgl4JRYFc=; b=FW7gvJX1Uy/S4dgsvnlMDK97N1K4t1G4xhuWlqEu+SCT2P8N DIh2Eyo31okWuPSuyuoBBjbmtpibcEIcxRn7P+NDzr38rOBAFDpvVjVl1lwn9gEj +x3/GGyaAjT2jMjbvA+U63TEEfx5fD4bNDKlQy7uc0/4kNzNuCpShFJLt3pJqUxX uCPD3MsctJeDBDPqUR+mry5X06v2ddFdLB069QW1bA80wQhajxKkLGvAPps3jITu Kv1knVwv4He8enQoMgYGeRxUzDTPQAZ+7KdrZox2ILh2xVFPOTj0iKPZGvHGZyYQ z13/4Lvk0sM4L1B499jkLDBG+nuWMrDL5gFLVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1731265106; x= 1731351506; bh=MC2osc/GQkRUavgJIimeF30YTVqRGns5bBCgl4JRYFc=; b=D WUrF/4/OSqUPU624Xy7VtlrwtZP/oYsXV5hMCHOS5Islp254nQGsAn3iESB96Ut+ 0xfGT3Y41IdenD9Jl1IwkKc3rOazyMcI5mNlA+DoMSLgUP7kc/DWwH/1l9a/oV9g t1opCGVR1KRyclr3D9lgQEVox680iA0JqetAF3/izVKuN+NKfreRkHKZLuZFnJ2/ bCyG15WqZuepftPffabV8e8TZReC1i2DEgkxmvW/J50fD3Uwp2bxi6GRCcL5bF8Z ku2DGO1QurfnXMbiPS2tfG93KHX9a4yB+2/V3F+JwXkzDi+8wRq2fDmmMPgsP2IB 9wKoxdW8ctNalkhTZb5kQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuff fkgggtsehttdertddttddtnecuhfhrohhmpehjohhhnhcumhhuhhhluceojhhmsehpuhgs rdhpihhnkheqnecuggftrfgrthhtvghrnhepgefhudekueehudeugffhgfegfeevhfetje ehhfeuleffgfeguedtffdvteeutedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepjhhmsehpuhgsrdhpihhnkhdpnhgspghrtghpthhtohepud dpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghughdqghhnuhdqvghmrggtshes ghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 10 Nov 2024 13:58:26 -0500 (EST) From: john muhl To: bug-gnu-emacs@gnu.org Subject: [PATCH] ; Improve comment indenting in 'lua-ts-mode' X-Debbugs-Cc: Date: Sun, 10 Nov 2024 12:58:24 -0600 Message-ID: <87v7wu9ar3.fsf@pub.pink> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=202.12.124.146; envelope-from=jm@pub.pink; helo=fout-b3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Tags: patch This improves nested comment indenting such that: local tbl = { one = 1, -- comment two = 2, } becomes: local tbl = { one = 1, -- comment two = 2, } From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 14:00:40 2024 Received: (at 74298) by debbugs.gnu.org; 10 Nov 2024 19:00:40 +0000 Received: from localhost ([127.0.0.1]:56626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tADAu-0008R9-2o for submit@debbugs.gnu.org; Sun, 10 Nov 2024 14:00:40 -0500 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]:50151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tADAs-0008Qx-Hx for 74298@debbugs.gnu.org; Sun, 10 Nov 2024 14:00:39 -0500 Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 2ACF825400FF for <74298@debbugs.gnu.org>; Sun, 10 Nov 2024 14:00:33 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Sun, 10 Nov 2024 14:00:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1731265233; x=1731351633; bh=Px6NElh4I8 aBmxlCKqd6noSiL+x5tplbX0JpwW/LHjs=; b=FqZcnZyhgosGG3pxmUvnMi4pLP 9mEA3GRypprGuArRljqxc8bo30S60UKuEc2qlcKe0qMLZXH3S06JilOK7kdooONr SpfwJEe1kGG4+eBz3qwsYKpnFEw8RdI9mt5UTHyYOtPe7rL9cWNGCsts/BIQtLkg 81Jmb8h8R8FnXy9JsnpofzTKAZi/fZx/EjqWTCOwDRTzNFNi898/2Uii8Gb4OKZB hnzSFBm5ERyJjzy3FTPEh6BSFS3ffQTcv+paUqRzH4bPQoKFKWpj0i1jVJWt3sZI +mXFN9dee3mkoNt4LnGBfptwFjVzojbWYCVP5yQ2HITAda9P63Yv1y3yTwqA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1731265233; x=1731351633; bh=Px6NElh4I8aBmxlCKqd6noSiL+x5tplbX0J pwW/LHjs=; b=h/5AJpckMd0vgmUOZcKqENTEiiDntGloAmKpsiWSgpdctvrRMDL RIxbm8kKAQl5cPrP8b85FvGcEeaTwQIgm+EAmI+HCqQwZhdW4SNnHh8EinST+FxP B0UArzTHjaSoHvA9EBSX5rnaJxmalP1HyYghFIyi55bgRzhWKZaBHVGmcCwOsfGp 247ykBdhayvlMtB8yHG0B7Jr+mZOZ3xUnI+kxIbsRDSafCfb6rv0EGbRuLDKupnC mfRaGMo0uhg9OtpauGcKi40QRXVUZIIPoTITfbSN5+IGXqulEeZBTVScNAmEUIDe 27FxBonvE18rmiZ/DWPmGkPWlSYZsEfStpw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffujg hffgffkfggtgesmhdtreertdertdenucfhrhhomhepjhhohhhnuchmuhhhlhcuoehjmhes phhusgdrphhinhhkqeenucggtffrrghtthgvrhhnpefgleehkeehveevtdefjedtuddvie fhgfekudelveeuheekgeffleeuvdetheetueenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehjmhesphhusgdrphhinhhkpdhnsggprhgtphhtth hopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeejgedvleekseguvggssghu ghhsrdhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for <74298@debbugs.gnu.org>; Sun, 10 Nov 2024 14:00:32 -0500 (EST) From: john muhl To: 74298@debbugs.gnu.org Subject: Re: bug#74298: [PATCH] ; Improve comment indenting in 'lua-ts-mode' In-Reply-To: <87v7wu9ar3.fsf@pub.pink> (john muhl's message of "Sun, 10 Nov 2024 12:58:24 -0600") References: <87v7wu9ar3.fsf@pub.pink> User-Agent: mu4e 1.12.1; emacs 31.0.50 Date: Sun, 10 Nov 2024 13:00:31 -0600 Message-ID: <87ldxq9ank.fsf@pub.pink> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74298 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Improve-comment-indenting-in-lua-ts-mode.patch >From cdcbdeafa2b35a7584b7c4c5a19e999476e3a897 Mon Sep 17 00:00:00 2001 From: john muhl Date: Sun, 10 Nov 2024 11:26:33 -0600 Subject: [PATCH] ; Improve comment indenting in 'lua-ts-mode' * lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules): Align single line comments with the surrounding context. (lua-ts--comment-first-sibling-matcher): Check that comment is the first sibling. (lua-ts--multi-line-comment-start): New function. * test/lisp/progmodes/lua-ts-mode-resources/indent.erts: Add tests. (Bug#74298) --- lisp/progmodes/lua-ts-mode.el | 17 ++++++-- .../lua-ts-mode-resources/indent.erts | 42 +++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index a7763377177..e5a2fafd279 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el @@ -289,7 +289,8 @@ lua-ts--font-lock-settings (defvar lua-ts--simple-indent-rules `((lua - ((or (node-is "comment") + ((or (and (node-is "comment") (parent-is "chunk")) + lua-ts--multi-line-comment-start (parent-is "comment_content") (parent-is "string_content") (node-is "]]")) @@ -473,9 +474,10 @@ lua-ts--nested-function-last-function-matcher (= 1 (length (cadr sparse-tree))))) (defun lua-ts--comment-first-sibling-matcher (node &rest _) - "Matches if NODE if it's previous sibling is a comment." + "Matches NODE if its previous sibling is a comment." (let ((sibling (treesit-node-prev-sibling node))) - (equal "comment" (treesit-node-type sibling)))) + (and (= 0 (treesit-node-index sibling t)) + (equal "comment" (treesit-node-type sibling))))) (defun lua-ts--top-level-function-call-matcher (node &rest _) "Matches if NODE is within a top-level function call." @@ -508,6 +510,15 @@ lua-ts--variable-declaration-continuation-anchor (line-beginning-position)) (point)))) +(defun lua-ts--multi-line-comment-start (node &rest _) + "Matches if NODE is the beginning of a multi-line comment." + (and node + (equal "comment" (treesit-node-type node)) + (save-excursion + (goto-char (treesit-node-start node)) + (forward-char 2) ; Skip the -- part. + (looking-at "\\[\\[")))) + (defvar lua-ts--syntax-table (let ((table (make-syntax-table))) (modify-syntax-entry ?+ "." table) diff --git a/test/lisp/progmodes/lua-ts-mode-resources/indent.erts b/test/lisp/progmodes/lua-ts-mode-resources/indent.erts index ba7bad1b452..b0ece4cc261 100644 --- a/test/lisp/progmodes/lua-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/lua-ts-mode-resources/indent.erts @@ -360,6 +360,10 @@ multi-line ]] return true end + + --[[ +Long comment. + ]] =-= --[[ Multi-line @@ -373,6 +377,44 @@ multi-line ]] return true end + + --[[ +Long comment. + ]] +=-=-= + +Name: Comment Indent + +=-= +local fn1 = function (a, b) +-- comment +return a + b +end + +local tb1 = { + first = 1, +-- comment + second = 2, +} + +local tb9 = { one = 1, +-- comment + two = 2 } +=-= +local fn1 = function (a, b) + -- comment + return a + b +end + +local tb1 = { + first = 1, + -- comment + second = 2, +} + +local tb9 = { one = 1, + -- comment + two = 2 } =-=-= Name: Argument Indent -- 2.47.0 --=-=-= Content-Type: text/plain john muhl writes: > Tags: patch > > This improves nested comment indenting such that: > > local tbl = { > one = 1, > -- comment > two = 2, > } > > becomes: > > local tbl = { > one = 1, > -- comment > two = 2, > } --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 14 03:15:41 2024 Received: (at 74298-done) by debbugs.gnu.org; 14 Nov 2024 08:15:41 +0000 Received: from localhost ([127.0.0.1]:44896 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBV0v-0000MW-6S for submit@debbugs.gnu.org; Thu, 14 Nov 2024 03:15:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBV0s-0000MA-SX for 74298-done@debbugs.gnu.org; Thu, 14 Nov 2024 03:15:39 -0500 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 1tBV0l-0006A4-Nk; Thu, 14 Nov 2024 03:15:32 -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=0tjDHJO7rCSXnZGQSLE4sGs9JCUc+6a/x8ckUm75E58=; b=VLT7qfj5ljhW 9iaoQYA7GEIFwuZpvbZw2uZPOEcTsTWRRh2nwEkhXfIgq7hyJlp0ocupG5UkCGRzDJD73+7pCgij+ R2FPF+1Tg/8jcvzq3RzPE/pZD5jG1MzEYtyKFzeBjS3Vmph+z1UFA0/szWLNIm22XOAq7sj3qkgAh vw6HfuVbvZCi+Vj7WX98ld9tbYtUgwAMcIgWVIXAiwdPf506Fiua3FfgGNRIST+tUTCsRrdBTpmkq WPdFrn2LmvNAWuRUmv7deVTVKtc70CoCrVUPCcyPHvlgqEfle9dn1t/b1x12U6HHCjYOwloQoEy/2 yOTEQNOxVpgSZKi/Ih6hHQ==; Date: Thu, 14 Nov 2024 10:15:28 +0200 Message-Id: <867c96kz8f.fsf@gnu.org> From: Eli Zaretskii To: john muhl In-Reply-To: <87ldxq9ank.fsf@pub.pink> (message from john muhl on Sun, 10 Nov 2024 13:00:31 -0600) Subject: Re: bug#74298: [PATCH] ; Improve comment indenting in 'lua-ts-mode' References: <87v7wu9ar3.fsf@pub.pink> <87ldxq9ank.fsf@pub.pink> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74298-done Cc: 74298-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: john muhl > Date: Sun, 10 Nov 2024 13:00:31 -0600 > > >From cdcbdeafa2b35a7584b7c4c5a19e999476e3a897 Mon Sep 17 00:00:00 2001 > From: john muhl > Date: Sun, 10 Nov 2024 11:26:33 -0600 > Subject: [PATCH] ; Improve comment indenting in 'lua-ts-mode' Thanks, installed on the emacs-30 branch, and closing the bug. From unknown Mon Aug 18 11:16:19 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 12 Dec 2024 12:24:13 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator