From unknown Fri Sep 05 20:37:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79309: lua-mode: minor problems and suggestions Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Aug 2025 14:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 79309 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 79309@debbugs.gnu.org Cc: john muhl , Juergen Hoetzel X-Debbugs-Original-To: Emacs Bug Report Received: via spool by submit@debbugs.gnu.org id=B.175613360012741 (code B ref -1); Mon, 25 Aug 2025 14:54:01 +0000 Received: (at submit) by debbugs.gnu.org; 25 Aug 2025 14:53:20 +0000 Received: from localhost ([127.0.0.1]:50711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uqYZT-0003JR-Qm for submit@debbugs.gnu.org; Mon, 25 Aug 2025 10:53:20 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56304) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uqYZO-0003J8-IJ for submit@debbugs.gnu.org; Mon, 25 Aug 2025 10:53:16 -0400 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 1uqYZH-0005QM-14 for bug-gnu-emacs@gnu.org; Mon, 25 Aug 2025 10:53:07 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uqYZD-0003yR-Rx for bug-gnu-emacs@gnu.org; Mon, 25 Aug 2025 10:53:06 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-3366f66a04cso9582231fa.1 for ; Mon, 25 Aug 2025 07:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756133581; x=1756738381; darn=gnu.org; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Pezu3LK4cfa9oFB8UXApgjS0mMugCzF4Agsf6816/l8=; b=BCO5uqqULM25cPDkCq/q8SUeFMvHU7WeOMZHqMglQcySyycnDEkyrr9AweguU+mcA3 f0xHS9zx40X8BatdnhlOZITfGL9H68F0Yrk7i0b6Kz1qLC0Pg2/qNxjY0nlr4vvuyDEP aZDCPnH0radzMkihBEpIviuB9PPB7pRXYD3EB1FcGsxGH1YvHiryqg6P2tj4sxpvgWd6 ajpBNxk2R0foif4LnfuyIzlIrE0kwGRrF4wegq13k2zImyQrXuiiF5WRWFCkr6J2UDIW 0RaKvB99qZ51o6UFrihWxv5t+vnwCtbufnWwCHGvdwgIMgJA2tSlNDWyM18UP6UTtDuY EtJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756133581; x=1756738381; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pezu3LK4cfa9oFB8UXApgjS0mMugCzF4Agsf6816/l8=; b=FT8xVqT+Gg9ih6fazNwLIkbDDPxWEeB3hlUeWVHS8GTHA44NHtz+WKrBlS5vFuAYqD HPSrt/yrl+B+bM7Goyq22/qzzbDc8Vc+oIDe2iktNcgdLdIJPPRHcuAKRul5sPHwvYg0 1bna+YpXrtRn6bAH2Igtizxv+nRVghZAfzXA0fURMzh3bLTZgW4/Cykhsghwf/wYcVav 4x91/2Hg9WYhwANO86atpdRd/TU7Z5Ll9P1SawlPgChgus6m2FY2H/8CVjQFLG+sDYHc 7OqJU+gJUS8ueyT3YurAUnjTjYdAPFOP8g3XZRsEoXydwi1jtmUNa03DFGxLFCvBpMtC WnRQ== X-Gm-Message-State: AOJu0YwM4MaQV/KgH3zGtr6++n2h+JQJOjMTr31k0/WfhyP0IG7WIMZP aUCnmZoZMaNosxRbQ3ogWJWeEXO+29OzmlYPSmKvAz/5RXYP47ywQMzgKP4CB6Ly X-Gm-Gg: ASbGnct/sbI5jQ57+WROK6yE3hIkbS7ZU6jU/0sikMLlFeS46m+EO1tadjove06QZJm IzNU/1Jjeo66Ev7nno6OsUZCiUmPdaA03f/g4TCTGmkYdK1ifqJHXDWWqueFxQWoUAEy/PUUZO4 uxsm2pu3J2CaDBqag7Ufj3jBjbThiJXkxrgKEHUMc6U7R61LZWor4qQp5X2A8W86oR/KOlYwFau hjqtoEbP0aBmK7thvrS0rCg64cpqXkdZJmOUFKk2oakTdmpYhDUVQkgpAQMBEfsi/h8ApNs6WQy cNccfypVk2xxrb8iMfe8az5xjMvICgv39amdVyMJ1cQOFAI6RgENnv5NJReTobArjmHbYaTzJ0L y/hvgvb7zv8hxjcK6dxzXZzGwn2zFcfV7VQl5Coj+dTi6XqlpAuylRMYG0xA5F7ELJxyQpqVLQ4 K2+UoxhuxJebwwJo/qFTyJvP8= X-Google-Smtp-Source: AGHT+IG2YNl0xGYKoLN7aUtRoBTj7+k968oHgLhL7Q5WfL8kpTbNiA+m0qS5s4ytXK8uLGfLIdLz0A== X-Received: by 2002:a05:651c:1109:10b0:332:1de5:c513 with SMTP id 38308e7fff4ca-33650e380ddmr23739861fa.4.1756133580942; Mon, 25 Aug 2025 07:53:00 -0700 (PDT) Received: from smtpclient.apple (c188-150-186-155.bredband.tele2.se. [188.150.186.155]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3365e2650cdsm15526991fa.33.2025.08.25.07.53.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Aug 2025 07:53:00 -0700 (PDT) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Message-Id: <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> Date: Mon, 25 Aug 2025 16:52:59 +0200 X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=mattias.engdegard@gmail.com; helo=mail-lj1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) 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: -0.0 (/) Some observations about the recently added lua-mode.el: 394 "A regexp that matches Lua builtin functions & variables. 395=20 396 This is a compilation of 5.1, 5.2 and 5.3 builtins taken from the 397 index of respective Lua reference manuals.") Clearly meant as a doc string. Bracket error? 1266 (or This `or` has only a single operand. Simple oversight or indication of = something worse? 1270 (save-excursion 1271 (and (goto-char prev-line) 1272 ;; Check last token of previous nonblank line 1273 (lua-last-token-continues-p))))) `goto-char` never returns nil, but its presence as a condition here = suggest that the author may have thought otherwise. (Line 996 is = similar.) 2099 for type =3D (if (string-match-p "\\`(E" msg) :error = :warning) A regexp is overkill here; `string-prefix-p` is simpler. 1821 (while (re-search-forward "[\"'\\\t\\\n]" nil t) This regexp is a bit muddled; too many backslashes here. You could even rewrite the whole function using = `replace-regexp-in-string`, maybe (concat "'" (replace-regexp-in-string (rx (or ?\" ?' ?\t ?\n ?\\)) (lambda (s) (cdr (assq (aref s 0) '((?\" . "\\\"") (?\\ . "\\\\") (?\n . "\\n") (?\t . "\\t") (?' . "\\'"))))) str t t) "'")) without any need for a temporary buffer. From unknown Fri Sep 05 20:37:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79309: lua-mode: minor problems and suggestions Resent-From: john muhl Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Aug 2025 03:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79309 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 79309@debbugs.gnu.org Received: via spool by 79309-submit@debbugs.gnu.org id=B79309.175626569014963 (code B ref 79309); Wed, 27 Aug 2025 03:35:02 +0000 Received: (at 79309) by debbugs.gnu.org; 27 Aug 2025 03:34:50 +0000 Received: from localhost ([127.0.0.1]:58168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ur6vw-0003tG-Qv for submit@debbugs.gnu.org; Tue, 26 Aug 2025 23:34:50 -0400 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]:45663) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ur6vq-0003sy-Jf for 79309@debbugs.gnu.org; Tue, 26 Aug 2025 23:34:46 -0400 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1C2007A01BC; Tue, 26 Aug 2025 23:34:36 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Tue, 26 Aug 2025 23:34:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :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=1756265675; x=1756352075; bh=hK0at6FY2l Uf1Er3XiMt5cxXPW7p9CG9jd3ZrALWbjk=; b=TlPNvBKliXvU0nQdeKJpMjLbE0 ezc+efBx+SZKKElHsDUpQ5p+7MCfBX3SpkSFWF0SOsPN2kL1NQDIedMmSa8Oo+1t fgyP3cAeyl4rYLL6flzE4BlbEBfSKfJ6SURTQruWX9kJWHzxnva8LmQwtn7S80v3 jqpy+hGztiOeAIZ38hCgItrZcRjw00ecfU0PkAMPR7ljS9D6Xaupz6qSEfhsKcyM XjNIt5uXpiCWS9SpS6wivVilM8JMNUFcgEklrbYDnfRwht7q6wYeb7r3wC5hXmj1 jtM4t5f8m2v6JJil+5ZYhxaC6xcRGbTwNPY/wlE7fA1Hs/ALoT6zsrW5UG4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; t= 1756265675; x=1756352075; bh=hK0at6FY2lUf1Er3XiMt5cxXPW7p9CG9jd3 ZrALWbjk=; b=OTvFRVgWAdhBh0dVwOoD5ARCjfeUZPclA7X805vCn7RXEvn4hWz MfQYwQhZYfNIMAJP+x7Z9z8rSNDyp3RXdkxtRVpWguA0h6F22TCjDI5i3Z82oEWc szetsuNHYx7+Ls9x1N2BvtOY4wvDIUYLl5llyEzpmiJvg9R/tmcEkFCm5h1MnTI6 SAO6MMVBb6sejrMI0ZoOD+bIm61NY83IAJh7+HiY6JKx81mPOYdnuSztp8i/lm1a PBOT46Z+iB++Q7+48EY7/dRts5LtrU8maIJNTZ4FAFOvGrdp3RConrYxFc9IBKtd 50l0BaOvTReU/QPiM29z81/mbOr6rFtiQqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddujeejtdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkfgggtgesmhdtreertderjeenucfhrhhomhepjhhohhhnuchm uhhhlhcuoehjmhesphhusgdrphhinhhkqeenucggtffrrghtthgvrhhnpeeutdffieefue dvvdfhtddvfefgvdffgeduvdffudeggffhueethefggedtteefteenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjmhesphhusgdrphhinhhkpd hnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeejleef tdelseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepmhgrthhtihgrshdrvg hnghguvghgrghrugesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Aug 2025 23:34:35 -0400 (EDT) From: john muhl In-Reply-To: <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> References: <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> Date: Tue, 26 Aug 2025 22:34:24 -0500 Message-ID: <875xe9xwsf.fsf@pub.pink> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) 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/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks for the review. Attached patch fixes these and a few other little things. Mattias Engdeg=C3=A5rd writes: > Some observations about the recently added lua-mode.el: > > 394 "A regexp that matches Lua builtin functions & variables. > 395=20 > 396 This is a compilation of 5.1, 5.2 and 5.3 builtins taken from the > 397 index of respective Lua reference manuals.") > > Clearly meant as a doc string. Bracket error? Fixed. > 1266 (or > > This `or` has only a single operand. Simple oversight or indication of so= mething worse? Looks like there used to be a second part but it got refactored up into the first part and the =E2=80=98or=E2=80=99 just hung around. > 1270 (save-excursion > 1271 (and (goto-char prev-line) > 1272 ;; Check last token of previous nonblank line > 1273 (lua-last-token-continues-p))))) > > `goto-char` never returns nil, but its presence as a condition > here suggest that the author may have thought otherwise. Removed the =E2=80=98and=E2=80=99 here. > (Line 996 is similar.) Wrapped it and the recursive call to lua-find-matching-token-word on the next line in progn to make it clear the goto-char is for side-effect and not return value. > 2099 for type =3D (if (string-match-p "\\`(E" msg) :error :warnin= g) > > A regexp is overkill here; `string-prefix-p` is simpler. The plan is to merge the common parts between the lua modes. The lua-ts-mode flymake backend uses string-prefix-p there so I left this for now and it=E2=80=99ll get replaced with the lua-ts flymake code. > 1821 (while (re-search-forward "[\"'\\\t\\\n]" nil t) > > This regexp is a bit muddled; too many backslashes here. > You could even rewrite the whole function using `replace-regexp-in-string= `, maybe > > (concat "'" > (replace-regexp-in-string > (rx (or ?\" ?' ?\t ?\n ?\\)) > (lambda (s) > (cdr (assq (aref s 0) '((?\" . "\\\"") > (?\\ . "\\\\") > (?\n . "\\n") > (?\t . "\\t") > (?' . "\\'"))))) > str t t) > "'")) > > without any need for a temporary buffer. That works. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Various-code-cleanup-in-lua-mode-Bug-79309.patch >From ae1adfe0936e4b53a978bde6fa851110eac8965d Mon Sep 17 00:00:00 2001 From: john muhl Date: Tue, 26 Aug 2025 15:12:26 -0500 Subject: [PATCH] ; Various code cleanup in 'lua-mode' (Bug#79309) * lisp/progmodes/lua-mode.el (lua-indent-level): Contemporary Lua style guides no longer recommend 3 as default. Change type to 'natnum'. (lua-always-show, lua-get-block-token-info) (lua--backward-up-list-noerror, lua-make-indentation-info-pair) (lua-accumulate-indentation-info) (lua-calculate-indentation-block-modifier): Quote function names. (lua-toggle-electric-state): Re-format to avoid confusion. (lua-is-continuing-statement-p-1): Fix typo. (lua--builtins): Move docstring to correct location. (lua-is-continuing-statement-p-1): Remove unnecessary 'or'. (lua-make-lua-string): Remove excessive backslashes and unnecessary use of a temporary buffer. (lua-find-matching-token-word): Make it clear that 'goto-char' is only used only for its side-effect. --- lisp/progmodes/lua-mode.el | 110 ++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/lisp/progmodes/lua-mode.el b/lisp/progmodes/lua-mode.el index f8d9ed98f1a..2e051d6d552 100644 --- a/lisp/progmodes/lua-mode.el +++ b/lisp/progmodes/lua-mode.el @@ -150,10 +150,10 @@ lua :prefix "lua-" :group 'languages) -(defcustom lua-indent-level 3 +(defcustom lua-indent-level 4 "Amount by which Lua subexpressions are indented." - :type 'integer - :safe #'integerp + :type 'natnum + :safe #'natnump :version "31.1") (defcustom lua-comment-start "-- " @@ -183,7 +183,7 @@ lua-default-command-switches :version "31.1") (defcustom lua-always-show t - "Non-nil means display lua-process-buffer after sending a command." + "Non-nil means display `lua-process-buffer' after sending a command." :type 'boolean :group 'lua) @@ -204,7 +204,6 @@ lua-documentation-url :type 'string :group 'lua) - (defvar lua-process nil "The active Lua process.") @@ -390,11 +389,11 @@ lua-region-end (concat (module-name-re x) (module-members-re x))) modules "\\|") - "\\)")))) - "A regexp that matches Lua builtin functions & variables. + "\\)"))) + "A regexp that matches Lua builtin functions & variables. -This is a compilation of 5.1, 5.2 and 5.3 builtins taken from the -index of respective Lua reference manuals.") +This is a compilation of 5.1-5.4 builtins taken from the index of +respective Lua reference manuals.")) (defvar lua-font-lock-keywords `(;; Highlight the hash-bang line "#!/foo/bar/lua" as comment @@ -917,7 +916,7 @@ lua-indentation-modifier-regexp (any ")]}")))))) (defun lua-get-block-token-info (token) - "Return the block token info entry for TOKEN from lua-block-token-alist." + "Return the block token info entry for TOKEN from `lua-block-token-alist'." (assoc token lua-block-token-alist)) (defun lua-get-token-match-re (token-info direction) @@ -993,9 +992,10 @@ lua-find-matching-token-word (eq match-type 'middle-or-open) (eq found-type 'middle-or-open) (eq match-type found-type)) - (goto-char found-pos) - (lua-find-matching-token-word - found-token search-direction)) + (progn + (goto-char found-pos) + (lua-find-matching-token-word + found-token search-direction))) (when maybe-found-pos (goto-char maybe-found-pos) (throw 'found maybe-found-pos))) @@ -1202,7 +1202,7 @@ lua-first-token-continues-p (match-beginning 2)))))) (defun lua--backward-up-list-noerror () - "Safe version of lua-backward-up-list that does not signal an error." + "Safe version of `lua-backward-up-list' that does not signal an error." (condition-case nil (lua-backward-up-list) (scan-error nil))) @@ -1249,40 +1249,39 @@ lua--continuation-breaking-line-p lua-funcheader))))) (defun lua-is-continuing-statement-p-1 () - "Return non-nil if current lined continues a statement. + "Return non-nil if current line continues a statement. More specifically, return the point in the line that is continued. The criteria for a continuing statement are: -* the last token of the previous line is a continuing op, - OR the first token of the current line is a continuing op +* The last token of the previous line is a continuing op, + OR the first token of the current line is a continuing op. -* the expression is not enclosed by a parentheses/braces/brackets" +* The expression is not enclosed by a parentheses/braces/brackets." (let (prev-line continuation-pos parent-block-opener) (save-excursion (setq prev-line (lua-forward-line-skip-blanks 'back))) (and prev-line (not (lua--continuation-breaking-line-p)) (save-excursion - (or - ;; Binary operator or keyword that implies continuation. - (and (setq continuation-pos - (or (lua-first-token-continues-p) - (save-excursion - (and (goto-char prev-line) - ;; Check last token of previous nonblank line - (lua-last-token-continues-p))))) - (not - ;; Operators/keywords does not create continuation - ;; inside some blocks: - (and (setq parent-block-opener - (car-safe (lua--backward-up-list-noerror))) - (or - ;; Inside parens/brackets - (member parent-block-opener '("(" "[")) - ;; Inside braces if it is a comma - (and (eq (char-after continuation-pos) ?,) - (equal parent-block-opener "{"))))) - continuation-pos)))))) + ;; Binary operator or keyword that implies continuation. + (and (setq continuation-pos + (or (lua-first-token-continues-p) + (save-excursion + (goto-char prev-line) + ;; Check last token of previous nonblank line + (lua-last-token-continues-p)))) + (not + ;; Operators/keywords does not create continuation + ;; inside some blocks: + (and (setq parent-block-opener + (car-safe (lua--backward-up-list-noerror))) + (or + ;; Inside parens/brackets + (member parent-block-opener '("(" "[")) + ;; Inside braces if it is a comma + (and (eq (char-after continuation-pos) ?,) + (equal parent-block-opener "{"))))) + continuation-pos))))) (defun lua-is-continuing-statement-p (&optional parse-start) "Return non-nil if PARSE-START should be indented as continuation line. @@ -1328,7 +1327,7 @@ lua-is-continuing-statement-p (defun lua-make-indentation-info-pair (found-token found-pos) "Create a pair from FOUND-TOKEN and FOUND-POS for indentation calculation. -This is a helper function to lua-calculate-indentation-info. +This is a helper function to `lua-calculate-indentation-info'. Don't use standalone." (cond ;; Functions are a bit tricky to indent right. They can appear in a @@ -1525,7 +1524,7 @@ lua-calculate-indentation-info indentation-info)) (defun lua-accumulate-indentation-info (reversed-indentation-info) - "Accumulate indent information from lua-calculate-indentation-info. + "Accumulate indent information from `lua-calculate-indentation-info'. Returns either the relative indentation shift, or the absolute column to indent to. @@ -1553,8 +1552,8 @@ lua-accumulate-indentation-info (defun lua-calculate-indentation-block-modifier (&optional parse-end) "Return amount by which this line modifies the indentation. -Beginnings of blocks add lua-indent-level once each, and endings of -blocks subtract lua-indent-level once each. This function is used to +Beginnings of blocks add `lua-indent-level' once each, and endings of +blocks subtract `lua-indent-level' once each. This function is used to determine how the indentation of the following line relates to this one. The argument PARSE-END is a buffer position that bounds the calculation." @@ -1814,19 +1813,17 @@ lua-process-init-code (defun lua-make-lua-string (str) "Convert STR to Lua literal." - (save-match-data - (with-temp-buffer - (insert str) - (goto-char (point-min)) - (while (re-search-forward "[\"'\\\t\\\n]" nil t) - (cond - ((string= (match-string 0) "\n") - (replace-match "\\\\n")) - ((string= (match-string 0) "\t") - (replace-match "\\\\t")) - (t - (replace-match "\\\\\\&" t)))) - (concat "'" (buffer-string) "'")))) + (concat "'" + (replace-regexp-in-string + (rx (or ?\" ?' ?\t ?\n ?\\)) + (lambda (s) + (cdr (assq (aref s 0) '((?\" . "\\\"") + (?\\ . "\\\\") + (?\n . "\\n") + (?\t . "\\t") + (?' . "\\'"))))) + str t t) + "'")) ;;;###autoload (defalias 'run-lua #'lua-start-process) @@ -2031,7 +2028,8 @@ lua-toggle-electric-state (interactive "P") (let ((num_arg (prefix-numeric-value arg))) (setq lua-electric-flag (cond ((or (null arg) - (zerop num_arg)) (not lua-electric-flag)) + (zerop num_arg)) + (not lua-electric-flag)) ((< num_arg 0) nil) ((> num_arg 0) t)))) (message "%S" lua-electric-flag)) -- 2.50.1 --=-=-=-- From unknown Fri Sep 05 20:37:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79309: lua-mode: minor problems and suggestions Resent-From: john muhl Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Aug 2025 03:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79309 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 79309@debbugs.gnu.org Received: via spool by 79309-submit@debbugs.gnu.org id=B79309.175626576915466 (code B ref 79309); Wed, 27 Aug 2025 03:37:01 +0000 Received: (at 79309) by debbugs.gnu.org; 27 Aug 2025 03:36:09 +0000 Received: from localhost ([127.0.0.1]:58176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ur6xD-00041N-Up for submit@debbugs.gnu.org; Tue, 26 Aug 2025 23:36:08 -0400 Received: from fout-b2-smtp.messagingengine.com ([202.12.124.145]:42769) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ur6x7-00040k-Ou for 79309@debbugs.gnu.org; Tue, 26 Aug 2025 23:36:03 -0400 Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id AD2191D000F5; Tue, 26 Aug 2025 23:35:55 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Tue, 26 Aug 2025 23:35:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :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=1756265755; x=1756352155; bh=hK0at6FY2l Uf1Er3XiMt5cxXPW7p9CG9jd3ZrALWbjk=; b=L7EKN46f6wMVXOqj0xE0G9eMHR A2MMjFnRELDliQulHZg+nKOMhY/+p324VJgn0FNc1pFcz7ExzjuavAQbbtopLRcL /Cpzz31e23UyvlPs767XQD5dp9bOr2lStxaEkYg4KHUP27fIsFjPYNMZ4LlwO6JE OcaQ7NMgqcDLbwVaOVR47aPad4ofdvF8kwe6hgaovoBcfMx6WhtTzm280xRjcbQ5 +3cD5agOZUsSe80fONu5fHwAPVA4rvU2IPfCc4fLKr/Ec2k+GiSlbcGID9fCJ/t+ 2P71XgczG3Enw2o6lbLlFMUL3Um6ggL851R8/ipNSoSLvR+bO5GW7Y9qF0VA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; t= 1756265755; x=1756352155; bh=hK0at6FY2lUf1Er3XiMt5cxXPW7p9CG9jd3 ZrALWbjk=; b=Pytf/TyppGrKGq62UiSf6+Hj/NAuVhpWDnjSOUsE4IDJp8V2Z8J j4fc1ptQpk38pdnqncofLkI+r/1BpQvv8Bfue0gclai3Dqh0s0lTtlhq2Yz6E5rc UKfpjQ4Rbss92A94i7gRZTTce69M3a5jFqshGNB7iAyEuxLgcItBE/KdWarHKDzY HKc+UiAk5EXZK1eglkBMKiLjHY1uFn6CDBu40R2x2CF6h96U5e5QmyF2std/tyT5 fQKqtbb2V7tkBsGJ/pwOdkLMljq2neW0X2OJB1kCVbkqsUM0zGiJFfdYr3AX4Q/Z zIbYAPmUrsMZJriqiCdIazwI41fEPNBXAfg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddujeejtdekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkfgggtgesmhdtreertderjeenucfhrhhomhepjhhohhhnuchm uhhhlhcuoehjmhesphhusgdrphhinhhkqeenucggtffrrghtthgvrhhnpeeutdffieefue dvvdfhtddvfefgvdffgeduvdffudeggffhueethefggedtteefteenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjmhesphhusgdrphhinhhkpd hnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeejleef tdelseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepmhgrthhtihgrshdrvg hnghguvghgrghrugesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Aug 2025 23:35:54 -0400 (EDT) From: john muhl In-Reply-To: <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> References: <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> Date: Tue, 26 Aug 2025 22:35:43 -0500 Message-ID: <87v7m9wi5s.fsf@pub.pink> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) 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/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks for the review. Attached patch fixes these and a few other little things. Mattias Engdeg=C3=A5rd writes: > Some observations about the recently added lua-mode.el: > > 394 "A regexp that matches Lua builtin functions & variables. > 395=20 > 396 This is a compilation of 5.1, 5.2 and 5.3 builtins taken from the > 397 index of respective Lua reference manuals.") > > Clearly meant as a doc string. Bracket error? Fixed. > 1266 (or > > This `or` has only a single operand. Simple oversight or indication of so= mething worse? Looks like there used to be a second part but it got refactored up into the first part and the =E2=80=98or=E2=80=99 just hung around. > 1270 (save-excursion > 1271 (and (goto-char prev-line) > 1272 ;; Check last token of previous nonblank line > 1273 (lua-last-token-continues-p))))) > > `goto-char` never returns nil, but its presence as a condition > here suggest that the author may have thought otherwise. Removed the =E2=80=98and=E2=80=99 here. > (Line 996 is similar.) Wrapped it and the recursive call to lua-find-matching-token-word on the next line in progn to make it clear the goto-char is for side-effect and not return value. > 2099 for type =3D (if (string-match-p "\\`(E" msg) :error :warnin= g) > > A regexp is overkill here; `string-prefix-p` is simpler. The plan is to merge the common parts between the lua modes. The lua-ts-mode flymake backend uses string-prefix-p there so I left this for now and it=E2=80=99ll get replaced with the lua-ts flymake code. > 1821 (while (re-search-forward "[\"'\\\t\\\n]" nil t) > > This regexp is a bit muddled; too many backslashes here. > You could even rewrite the whole function using `replace-regexp-in-string= `, maybe > > (concat "'" > (replace-regexp-in-string > (rx (or ?\" ?' ?\t ?\n ?\\)) > (lambda (s) > (cdr (assq (aref s 0) '((?\" . "\\\"") > (?\\ . "\\\\") > (?\n . "\\n") > (?\t . "\\t") > (?' . "\\'"))))) > str t t) > "'")) > > without any need for a temporary buffer. That works. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Various-code-cleanup-in-lua-mode-Bug-79309.patch >From ae1adfe0936e4b53a978bde6fa851110eac8965d Mon Sep 17 00:00:00 2001 From: john muhl Date: Tue, 26 Aug 2025 15:12:26 -0500 Subject: [PATCH] ; Various code cleanup in 'lua-mode' (Bug#79309) * lisp/progmodes/lua-mode.el (lua-indent-level): Contemporary Lua style guides no longer recommend 3 as default. Change type to 'natnum'. (lua-always-show, lua-get-block-token-info) (lua--backward-up-list-noerror, lua-make-indentation-info-pair) (lua-accumulate-indentation-info) (lua-calculate-indentation-block-modifier): Quote function names. (lua-toggle-electric-state): Re-format to avoid confusion. (lua-is-continuing-statement-p-1): Fix typo. (lua--builtins): Move docstring to correct location. (lua-is-continuing-statement-p-1): Remove unnecessary 'or'. (lua-make-lua-string): Remove excessive backslashes and unnecessary use of a temporary buffer. (lua-find-matching-token-word): Make it clear that 'goto-char' is only used only for its side-effect. --- lisp/progmodes/lua-mode.el | 110 ++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/lisp/progmodes/lua-mode.el b/lisp/progmodes/lua-mode.el index f8d9ed98f1a..2e051d6d552 100644 --- a/lisp/progmodes/lua-mode.el +++ b/lisp/progmodes/lua-mode.el @@ -150,10 +150,10 @@ lua :prefix "lua-" :group 'languages) -(defcustom lua-indent-level 3 +(defcustom lua-indent-level 4 "Amount by which Lua subexpressions are indented." - :type 'integer - :safe #'integerp + :type 'natnum + :safe #'natnump :version "31.1") (defcustom lua-comment-start "-- " @@ -183,7 +183,7 @@ lua-default-command-switches :version "31.1") (defcustom lua-always-show t - "Non-nil means display lua-process-buffer after sending a command." + "Non-nil means display `lua-process-buffer' after sending a command." :type 'boolean :group 'lua) @@ -204,7 +204,6 @@ lua-documentation-url :type 'string :group 'lua) - (defvar lua-process nil "The active Lua process.") @@ -390,11 +389,11 @@ lua-region-end (concat (module-name-re x) (module-members-re x))) modules "\\|") - "\\)")))) - "A regexp that matches Lua builtin functions & variables. + "\\)"))) + "A regexp that matches Lua builtin functions & variables. -This is a compilation of 5.1, 5.2 and 5.3 builtins taken from the -index of respective Lua reference manuals.") +This is a compilation of 5.1-5.4 builtins taken from the index of +respective Lua reference manuals.")) (defvar lua-font-lock-keywords `(;; Highlight the hash-bang line "#!/foo/bar/lua" as comment @@ -917,7 +916,7 @@ lua-indentation-modifier-regexp (any ")]}")))))) (defun lua-get-block-token-info (token) - "Return the block token info entry for TOKEN from lua-block-token-alist." + "Return the block token info entry for TOKEN from `lua-block-token-alist'." (assoc token lua-block-token-alist)) (defun lua-get-token-match-re (token-info direction) @@ -993,9 +992,10 @@ lua-find-matching-token-word (eq match-type 'middle-or-open) (eq found-type 'middle-or-open) (eq match-type found-type)) - (goto-char found-pos) - (lua-find-matching-token-word - found-token search-direction)) + (progn + (goto-char found-pos) + (lua-find-matching-token-word + found-token search-direction))) (when maybe-found-pos (goto-char maybe-found-pos) (throw 'found maybe-found-pos))) @@ -1202,7 +1202,7 @@ lua-first-token-continues-p (match-beginning 2)))))) (defun lua--backward-up-list-noerror () - "Safe version of lua-backward-up-list that does not signal an error." + "Safe version of `lua-backward-up-list' that does not signal an error." (condition-case nil (lua-backward-up-list) (scan-error nil))) @@ -1249,40 +1249,39 @@ lua--continuation-breaking-line-p lua-funcheader))))) (defun lua-is-continuing-statement-p-1 () - "Return non-nil if current lined continues a statement. + "Return non-nil if current line continues a statement. More specifically, return the point in the line that is continued. The criteria for a continuing statement are: -* the last token of the previous line is a continuing op, - OR the first token of the current line is a continuing op +* The last token of the previous line is a continuing op, + OR the first token of the current line is a continuing op. -* the expression is not enclosed by a parentheses/braces/brackets" +* The expression is not enclosed by a parentheses/braces/brackets." (let (prev-line continuation-pos parent-block-opener) (save-excursion (setq prev-line (lua-forward-line-skip-blanks 'back))) (and prev-line (not (lua--continuation-breaking-line-p)) (save-excursion - (or - ;; Binary operator or keyword that implies continuation. - (and (setq continuation-pos - (or (lua-first-token-continues-p) - (save-excursion - (and (goto-char prev-line) - ;; Check last token of previous nonblank line - (lua-last-token-continues-p))))) - (not - ;; Operators/keywords does not create continuation - ;; inside some blocks: - (and (setq parent-block-opener - (car-safe (lua--backward-up-list-noerror))) - (or - ;; Inside parens/brackets - (member parent-block-opener '("(" "[")) - ;; Inside braces if it is a comma - (and (eq (char-after continuation-pos) ?,) - (equal parent-block-opener "{"))))) - continuation-pos)))))) + ;; Binary operator or keyword that implies continuation. + (and (setq continuation-pos + (or (lua-first-token-continues-p) + (save-excursion + (goto-char prev-line) + ;; Check last token of previous nonblank line + (lua-last-token-continues-p)))) + (not + ;; Operators/keywords does not create continuation + ;; inside some blocks: + (and (setq parent-block-opener + (car-safe (lua--backward-up-list-noerror))) + (or + ;; Inside parens/brackets + (member parent-block-opener '("(" "[")) + ;; Inside braces if it is a comma + (and (eq (char-after continuation-pos) ?,) + (equal parent-block-opener "{"))))) + continuation-pos))))) (defun lua-is-continuing-statement-p (&optional parse-start) "Return non-nil if PARSE-START should be indented as continuation line. @@ -1328,7 +1327,7 @@ lua-is-continuing-statement-p (defun lua-make-indentation-info-pair (found-token found-pos) "Create a pair from FOUND-TOKEN and FOUND-POS for indentation calculation. -This is a helper function to lua-calculate-indentation-info. +This is a helper function to `lua-calculate-indentation-info'. Don't use standalone." (cond ;; Functions are a bit tricky to indent right. They can appear in a @@ -1525,7 +1524,7 @@ lua-calculate-indentation-info indentation-info)) (defun lua-accumulate-indentation-info (reversed-indentation-info) - "Accumulate indent information from lua-calculate-indentation-info. + "Accumulate indent information from `lua-calculate-indentation-info'. Returns either the relative indentation shift, or the absolute column to indent to. @@ -1553,8 +1552,8 @@ lua-accumulate-indentation-info (defun lua-calculate-indentation-block-modifier (&optional parse-end) "Return amount by which this line modifies the indentation. -Beginnings of blocks add lua-indent-level once each, and endings of -blocks subtract lua-indent-level once each. This function is used to +Beginnings of blocks add `lua-indent-level' once each, and endings of +blocks subtract `lua-indent-level' once each. This function is used to determine how the indentation of the following line relates to this one. The argument PARSE-END is a buffer position that bounds the calculation." @@ -1814,19 +1813,17 @@ lua-process-init-code (defun lua-make-lua-string (str) "Convert STR to Lua literal." - (save-match-data - (with-temp-buffer - (insert str) - (goto-char (point-min)) - (while (re-search-forward "[\"'\\\t\\\n]" nil t) - (cond - ((string= (match-string 0) "\n") - (replace-match "\\\\n")) - ((string= (match-string 0) "\t") - (replace-match "\\\\t")) - (t - (replace-match "\\\\\\&" t)))) - (concat "'" (buffer-string) "'")))) + (concat "'" + (replace-regexp-in-string + (rx (or ?\" ?' ?\t ?\n ?\\)) + (lambda (s) + (cdr (assq (aref s 0) '((?\" . "\\\"") + (?\\ . "\\\\") + (?\n . "\\n") + (?\t . "\\t") + (?' . "\\'"))))) + str t t) + "'")) ;;;###autoload (defalias 'run-lua #'lua-start-process) @@ -2031,7 +2028,8 @@ lua-toggle-electric-state (interactive "P") (let ((num_arg (prefix-numeric-value arg))) (setq lua-electric-flag (cond ((or (null arg) - (zerop num_arg)) (not lua-electric-flag)) + (zerop num_arg)) + (not lua-electric-flag)) ((< num_arg 0) nil) ((> num_arg 0) t)))) (message "%S" lua-electric-flag)) -- 2.50.1 --=-=-=-- From unknown Fri Sep 05 20:37:01 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Subject: bug#79309: closed (Re: bug#79309: lua-mode: minor problems and suggestions) Message-ID: References: <2D13E6CB-F9AD-427E-8AFB-EB517B2B8D30@gmail.com> <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> X-Gnu-PR-Message: they-closed 79309 X-Gnu-PR-Package: emacs Reply-To: 79309@debbugs.gnu.org Date: Wed, 27 Aug 2025 08:17:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1756282622-5285-1" This is a multi-part message in MIME format... ------------=_1756282622-5285-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #79309: lua-mode: minor problems and suggestions which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 79309@debbugs.gnu.org. --=20 79309: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D79309 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1756282622-5285-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 79309-done) by debbugs.gnu.org; 27 Aug 2025 08:16:05 +0000 Received: from localhost ([127.0.0.1]:58929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1urBK9-0001Kz-1U for submit@debbugs.gnu.org; Wed, 27 Aug 2025 04:16:05 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:57738) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1urBK5-0001K4-4H for 79309-done@debbugs.gnu.org; Wed, 27 Aug 2025 04:16:02 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-55f3edab4c7so3912424e87.3 for <79309-done@debbugs.gnu.org>; Wed, 27 Aug 2025 01:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756282553; x=1756887353; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=OnBk3uHjocm519gwKpAk9Ys7yCSVoAl0sruLqKCThPM=; b=eOSEOLYIhWidoIbgBm2uWEr9sqhZPKfEPCqbWtsP1wfnUBDiCHxvLnFAPveHm4Q1TC MpvTx0AUUhh1J+n463BCisg3i7ETkC/KB2FKo3E03Wp6uWPGsChJ2x1oVuj8YSWhvA0q 1z2O7l5DIimTVmuXrrZfS379oKUFw22353RJmPJegS1fDneUdbvOaAlD62UtM8fzAXdy 75k2QDnWLCq/UzG0HcVRDO1MXZhOU20pHqSU3w2gxeqXtNGKhQWoOVzMyB9kBM0JOm7U pK2tYXdueoFiFZtj100wHmr0Y2aIDidrEo1kYWMKvg0sPkI1ZMe6ir/NY8ovhluZjbxp 9HyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756282553; x=1756887353; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OnBk3uHjocm519gwKpAk9Ys7yCSVoAl0sruLqKCThPM=; b=kmchzJs6LDOxF+vkKDVDP3QUuyqSy5Sk2hhY9OIqFdNAJm5CD0F856wpYW2aek/X64 Yy60icluoWzK4hyabB+VT1NOGaSIRP2Z+zboSEuaCr8G+jVxnInhX+SIMpO5ETD2Gylu nDaWiY5EWUTI4FkXTkA65zIlWguqSvmvdoAOSrdirk5/NwlZKV+Oh1BCou4PQxQLpbtT DIIsPdd/NA5uVnYDc/UeygWVaKiHjs/yoMjnpr/EEnjbMoyfVYY4fux2iAnO7EjGmQNB Gp3Cfi7Pmfj/a/aIOFRzflTmHAq9wl+0g9coBDDvXhvpZA/gzj9uN3nlLK6aXCsQwazZ kT1Q== X-Gm-Message-State: AOJu0YzDNfhXDSUPtN+zg3hXs5ri09DpnhXCUf9gX/4i3mH6lzsKhTU+ IUUHnTiI65j2PlXBX7rmuo0C1Ok2GuSvPYLqrRP+P3jh2BNqE9JVnb8I1WuLY+cL X-Gm-Gg: ASbGncsmAKpHvYcm9Z+7ZdRXfhRDYT/9QGgaifNPBITjxsRp5XKOt+uCZR34Q5e3dwu i32mNJlcCNPQf0jI+4svADDPegn4SXA6vBkZt08TtochiSIGwpqjnIp94Nv8GhyEb0jlF7CJs29 KGwQXAj/IgYpZEToVVxT0Y53fJHucv6HZAnvIVWCE9zCQU6EIGuSxwZ1SKG/AV3Ir/r5rA9byBt aoWIBq30Z67IfmvhoiPgR2vIgU5RMeTFhAJTjrUK/8Yz2jdP0sQI0FC5MjxKXsB6RTTqdO7LwuP e0tak7I73M8AILWddiL2IdFq+nfORlwrGd4+HPP1GNewuq12MM6Jf+zvwALTtQ3ah8LflPI/epc Gz/tIMuyFzhlPeLNDNOM5PeGLQXYXcMbp+V8kAnnQB53UVQWWH7A/L1axb9jq9fsUbxsTvtJ/q1 w/bA2X3SdW4GVG X-Google-Smtp-Source: AGHT+IGUq1y+zpDgJzcXano+3NNQCPto8yeWlVwtnh4HlQtMgh+SYTAbMguKAJMEY1QnvkYcUj5f+w== X-Received: by 2002:a05:6512:448e:b0:55f:5765:cc9a with SMTP id 2adb3069b0e04-55f5765d544mr131374e87.17.1756282552674; Wed, 27 Aug 2025 01:15:52 -0700 (PDT) Received: from smtpclient.apple (c188-150-186-155.bredband.tele2.se. [188.150.186.155]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-55f528ce570sm406206e87.120.2025.08.27.01.15.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2025 01:15:52 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Subject: Re: bug#79309: lua-mode: minor problems and suggestions From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <87v7m9wi5s.fsf@pub.pink> Date: Wed, 27 Aug 2025 10:15:50 +0200 Content-Transfer-Encoding: 7bit Message-Id: <2D13E6CB-F9AD-427E-8AFB-EB517B2B8D30@gmail.com> References: <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> <87v7m9wi5s.fsf@pub.pink> To: john muhl X-Mailer: Apple Mail (2.3654.120.0.1.15) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79309-done Cc: 79309-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: -1.0 (-) 27 aug. 2025 kl. 05.35 skrev john muhl : > Thanks for the review. Attached patch fixes these and a few other > little things. Looks good, thank you! Pushing to master and closing bug. ------------=_1756282622-5285-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 25 Aug 2025 14:53:20 +0000 Received: from localhost ([127.0.0.1]:50711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uqYZT-0003JR-Qm for submit@debbugs.gnu.org; Mon, 25 Aug 2025 10:53:20 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56304) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uqYZO-0003J8-IJ for submit@debbugs.gnu.org; Mon, 25 Aug 2025 10:53:16 -0400 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 1uqYZH-0005QM-14 for bug-gnu-emacs@gnu.org; Mon, 25 Aug 2025 10:53:07 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uqYZD-0003yR-Rx for bug-gnu-emacs@gnu.org; Mon, 25 Aug 2025 10:53:06 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-3366f66a04cso9582231fa.1 for ; Mon, 25 Aug 2025 07:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756133581; x=1756738381; darn=gnu.org; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Pezu3LK4cfa9oFB8UXApgjS0mMugCzF4Agsf6816/l8=; b=BCO5uqqULM25cPDkCq/q8SUeFMvHU7WeOMZHqMglQcySyycnDEkyrr9AweguU+mcA3 f0xHS9zx40X8BatdnhlOZITfGL9H68F0Yrk7i0b6Kz1qLC0Pg2/qNxjY0nlr4vvuyDEP aZDCPnH0radzMkihBEpIviuB9PPB7pRXYD3EB1FcGsxGH1YvHiryqg6P2tj4sxpvgWd6 ajpBNxk2R0foif4LnfuyIzlIrE0kwGRrF4wegq13k2zImyQrXuiiF5WRWFCkr6J2UDIW 0RaKvB99qZ51o6UFrihWxv5t+vnwCtbufnWwCHGvdwgIMgJA2tSlNDWyM18UP6UTtDuY EtJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756133581; x=1756738381; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pezu3LK4cfa9oFB8UXApgjS0mMugCzF4Agsf6816/l8=; b=FT8xVqT+Gg9ih6fazNwLIkbDDPxWEeB3hlUeWVHS8GTHA44NHtz+WKrBlS5vFuAYqD HPSrt/yrl+B+bM7Goyq22/qzzbDc8Vc+oIDe2iktNcgdLdIJPPRHcuAKRul5sPHwvYg0 1bna+YpXrtRn6bAH2Igtizxv+nRVghZAfzXA0fURMzh3bLTZgW4/Cykhsghwf/wYcVav 4x91/2Hg9WYhwANO86atpdRd/TU7Z5Ll9P1SawlPgChgus6m2FY2H/8CVjQFLG+sDYHc 7OqJU+gJUS8ueyT3YurAUnjTjYdAPFOP8g3XZRsEoXydwi1jtmUNa03DFGxLFCvBpMtC WnRQ== X-Gm-Message-State: AOJu0YwM4MaQV/KgH3zGtr6++n2h+JQJOjMTr31k0/WfhyP0IG7WIMZP aUCnmZoZMaNosxRbQ3ogWJWeEXO+29OzmlYPSmKvAz/5RXYP47ywQMzgKP4CB6Ly X-Gm-Gg: ASbGnct/sbI5jQ57+WROK6yE3hIkbS7ZU6jU/0sikMLlFeS46m+EO1tadjove06QZJm IzNU/1Jjeo66Ev7nno6OsUZCiUmPdaA03f/g4TCTGmkYdK1ifqJHXDWWqueFxQWoUAEy/PUUZO4 uxsm2pu3J2CaDBqag7Ufj3jBjbThiJXkxrgKEHUMc6U7R61LZWor4qQp5X2A8W86oR/KOlYwFau hjqtoEbP0aBmK7thvrS0rCg64cpqXkdZJmOUFKk2oakTdmpYhDUVQkgpAQMBEfsi/h8ApNs6WQy cNccfypVk2xxrb8iMfe8az5xjMvICgv39amdVyMJ1cQOFAI6RgENnv5NJReTobArjmHbYaTzJ0L y/hvgvb7zv8hxjcK6dxzXZzGwn2zFcfV7VQl5Coj+dTi6XqlpAuylRMYG0xA5F7ELJxyQpqVLQ4 K2+UoxhuxJebwwJo/qFTyJvP8= X-Google-Smtp-Source: AGHT+IG2YNl0xGYKoLN7aUtRoBTj7+k968oHgLhL7Q5WfL8kpTbNiA+m0qS5s4ytXK8uLGfLIdLz0A== X-Received: by 2002:a05:651c:1109:10b0:332:1de5:c513 with SMTP id 38308e7fff4ca-33650e380ddmr23739861fa.4.1756133580942; Mon, 25 Aug 2025 07:53:00 -0700 (PDT) Received: from smtpclient.apple (c188-150-186-155.bredband.tele2.se. [188.150.186.155]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3365e2650cdsm15526991fa.33.2025.08.25.07.53.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Aug 2025 07:53:00 -0700 (PDT) From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Subject: lua-mode: minor problems and suggestions Message-Id: <8840C014-8F53-4129-A6C5-BFB551FEE3C8@gmail.com> Date: Mon, 25 Aug 2025 16:52:59 +0200 To: Emacs Bug Report X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=mattias.engdegard@gmail.com; helo=mail-lj1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: john muhl , Juergen Hoetzel 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: -0.0 (/) Some observations about the recently added lua-mode.el: 394 "A regexp that matches Lua builtin functions & variables. 395=20 396 This is a compilation of 5.1, 5.2 and 5.3 builtins taken from the 397 index of respective Lua reference manuals.") Clearly meant as a doc string. Bracket error? 1266 (or This `or` has only a single operand. Simple oversight or indication of = something worse? 1270 (save-excursion 1271 (and (goto-char prev-line) 1272 ;; Check last token of previous nonblank line 1273 (lua-last-token-continues-p))))) `goto-char` never returns nil, but its presence as a condition here = suggest that the author may have thought otherwise. (Line 996 is = similar.) 2099 for type =3D (if (string-match-p "\\`(E" msg) :error = :warning) A regexp is overkill here; `string-prefix-p` is simpler. 1821 (while (re-search-forward "[\"'\\\t\\\n]" nil t) This regexp is a bit muddled; too many backslashes here. You could even rewrite the whole function using = `replace-regexp-in-string`, maybe (concat "'" (replace-regexp-in-string (rx (or ?\" ?' ?\t ?\n ?\\)) (lambda (s) (cdr (assq (aref s 0) '((?\" . "\\\"") (?\\ . "\\\\") (?\n . "\\n") (?\t . "\\t") (?' . "\\'"))))) str t t) "'")) without any need for a temporary buffer. ------------=_1756282622-5285-1--