From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: john muhl Newsgroups: gmane.emacs.bugs Subject: bug#70167: [PATCH] Mark Flymake regions more accurately in lua-ts-mode Date: Thu, 04 Apr 2024 11:45:05 -0500 Message-ID: <875xwwq5o4.fsf@pub.pink> References: <87sf02baay.fsf@pub.pink> <878r1ub9q1.fsf@pub.pink> <87il0xek76.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8483"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.8; emacs 30.0.50 Cc: 70167@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 04 21:40:29 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 1rsSwm-0001sN-DH for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Apr 2024 21:40:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsSwN-0004z0-O6; Thu, 04 Apr 2024 15:40:03 -0400 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 1rsSwK-0004yi-E9 for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2024 15:40:00 -0400 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 1rsSwJ-0002jV-PI for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2024 15:40:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rsSwO-00049h-KD for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2024 15:40:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: john muhl Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Apr 2024 19:40:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70167 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70167-submit@debbugs.gnu.org id=B70167.171225955115672 (code B ref 70167); Thu, 04 Apr 2024 19:40:04 +0000 Original-Received: (at 70167) by debbugs.gnu.org; 4 Apr 2024 19:39:11 +0000 Original-Received: from localhost ([127.0.0.1]:34729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsSvW-00044h-Ch for submit@debbugs.gnu.org; Thu, 04 Apr 2024 15:39:10 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:56241) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsSvQ-00043B-Mn for 70167@debbugs.gnu.org; Thu, 04 Apr 2024 15:39:08 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2D0FC5C008B; Thu, 4 Apr 2024 15:38:54 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 04 Apr 2024 15:38:54 -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=fm2; t=1712259534; x=1712345934; bh=KfXh9Kgcew uM1cpqDKr7fN4j2Rbw9mkalC5td/uLBRU=; b=Q7Xj22favnGU7cZ8fe4vgNM4Vm TA8nsvue9veQRG7P3vJU0WcL91cXOPUMDkEo9ApDLbEvwA7jeTUwXp2fNhmdL/wM 8YeJw3jRMEuSb35TlDwSKYWJ94ziXZda9FD4+KbbHOXsnPMg5udClLOqQBwlNnj2 c3yMvVsR8jkraTz5Ihy5+2NqmAMaURfvYEj3YKWHhN/w7IE9gjgVLX6gtGmlYoIW +seLrtvgCOswd052chhZsGVX5/nug1xIhxWUGWi2GjtyIVQ/q3UW//kleMA4L7ZR C2uDq5oA23tAu16BUO9gtge3pMznoENJDeNs0RaKQc/bm+fwC2tAoSQ09S/Q== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712259534; x=1712345934; bh=KfXh9KgcewuM1cpqDKr7fN4j2Rbw 9mkalC5td/uLBRU=; b=q8IN0fH3QiTC2wyO7QszcZU0f9cJDO18razgLxIbEZ/a za+PbR8eYXQXnScr0PC35RcIpNz4Lxw9stq5bqNjCqnnk/1Ow7uxEuSrbPZolfgw US2yafxUv9kTeykV+U+dBJ1R7ih8Pt+J4Cp1Atl6OS1YlcvCi4OyH3PIYMfEM1g1 /rxxCNO87/ub3i/QjpCijHGgAREuzGw3XdVk/YXyU1OQla6fVdJ+Xu2WI1o2OXn6 byqa2uNp+NME1lg89BMH+dLwyoQJOCTrmu6Ghrapu4GxiUEFsbUbsPBr9KHVY4vh 5w0jq6n2sn4W9LQR6ZRyls1c5LRJ9On5mkX4Y2Upog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefkedgudegtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffjgfkgggtsehmtderredtreejnecuhfhrohhmpehjohhh nhcumhhuhhhluceojhhmsehpuhgsrdhpihhnkheqnecuggftrfgrthhtvghrnhepgfejve eflefhleelheeiieevueduhfevvdfhteegffehffekudekteeujeffuefhnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhmsehpuhgsrdhpih hnkh X-ME-Proxy: Feedback-ID: i74194916:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Apr 2024 15:38:53 -0400 (EDT) In-reply-to: <87il0xek76.fsf@posteo.net> 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:282677 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Philip Kaludercic writes: > john muhl writes: > >> + (let (beg end msg type diags) >> + (while > > Why do you declare these variables outside of the loop? Should the > values persist between iterations? If not, you could avoid the setq > soup below, by declaring and binding the variables at once. Only the list of diagnostics is used outside the loop. I=E2=80=99ve moved the others inside the while. >> + (search-forward-regexp >> + (rx (: bol (0+ alnum) ":" > ^ > this is not necessary, since > the rx body has an implicit ":". Fixed. >> + (setq msg (match-string 4)) >> + (setq type (if (string-match "^(W" msg) = :warning > ^ > You can avoid a > regular expression > here using `string-pref= ix-p'. Fixed. >> + :error)) >> + (when (and beg end) >> + (setq diags >> + (nconc diags >> + (list (flymake-make-diagn= ostic >> + source beg end type msg)))))) >> + (funcall report-fn diags))) > > If I see this correctly, then you are appending each element to the end > of the list? If so, it would be more efficient to just construct the > list in reverse using `push' and then `nreverse'ing it before passing it > to REPORT-FN. Changed to use push. It doesn=E2=80=99t look like the order matters or did I misunderstand something? Thanks for the review. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Mark-Flymake-regions-more-accurately-in-lua-ts-mode.patch >From 910e88cf83415ae1e077fbc36560cb29fd39b666 Mon Sep 17 00:00:00 2001 From: john muhl Date: Wed, 13 Mar 2024 08:35:08 -0500 Subject: [PATCH] Mark Flymake regions more accurately in lua-ts-mode * lisp/progmodes/lua-ts-mode.el (lua-ts-flymake-luacheck): Use the end position provided by Luacheck rather than relying on 'thing-at-point' to guess where the end should be. (bug#70167) --- lisp/progmodes/lua-ts-mode.el | 53 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index 407ef230c32..45ea8ec9a81 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el @@ -35,7 +35,6 @@ (require 'treesit) (eval-when-compile - (require 'cl-lib) (require 'rx)) (declare-function treesit-induce-sparse-tree "treesit.c") @@ -544,32 +543,32 @@ lua-ts-flymake-luacheck (eq proc lua-ts--flymake-process)) (with-current-buffer (process-buffer proc) (goto-char (point-min)) - (cl-loop - while (search-forward-regexp - (rx (seq bol - (0+ alnum) ":" - (group (1+ digit)) ":" - (group (1+ digit)) "-" - (group (1+ digit)) ": " - (group (0+ nonl)) - eol)) - nil t) - for (beg . end) = (flymake-diag-region - source - (string-to-number (match-string 1)) - (string-to-number (match-string 2))) - for msg = (match-string 4) - for type = (if (string-match "^(W" msg) - :warning - :error) - when (and beg end) - collect (flymake-make-diagnostic source - beg - end - type - msg) - into diags - finally (funcall report-fn diags))) + (let (diags) + (while (search-forward-regexp + (rx bol (0+ alnum) ":" + (group (1+ digit)) ":" + (group (1+ digit)) "-" + (group (1+ digit)) ": " + (group (0+ nonl)) eol) + nil t) + (let* ((beg + (car (flymake-diag-region + source + (string-to-number (match-string 1)) + (string-to-number (match-string 2))))) + (end + (cdr (flymake-diag-region + source + (string-to-number (match-string 1)) + (string-to-number (match-string 3))))) + (msg (match-string 4)) + (type (if (string-prefix-p "(W" msg) + :warning + :error))) + (push (flymake-make-diagnostic + source beg end type msg) + diags))) + (funcall report-fn diags))) (flymake-log :warning "Canceling obsolete check %s" proc)) (kill-buffer (process-buffer proc))))))) (process-send-region lua-ts--flymake-process (point-min) (point-max)) -- 2.41.0 --=-=-=--