From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#57884: [PATCH] Flymake backend using the shellcheck program Date: Sun, 18 Sep 2022 20:22:33 +0000 Message-ID: <87h7148mba.fsf@posteo.net> References: <87a66yaqwc.fsf@gmail.com> <83bkre0w4m.fsf@gnu.org> <871qs9c3er.fsf@gmail.com> <87zgewdhhd.fsf@posteo.net> <87fsgoyi0l.fsf@gmail.com> <87sfko4zjq.fsf@posteo.net> <87edw8n71p.fsf@gmail.com> <8735co4wxx.fsf@posteo.net> <878rmgcw2e.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19217"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 57884@debbugs.gnu.org, Stefan Kangas To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 18 22:23:12 2022 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 1oa0oq-0004p6-Co for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 22:23:12 +0200 Original-Received: from localhost ([::1]:59194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oa0op-0002E3-A9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 16:23:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oa0og-0002Dg-To for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 16:23:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oa0og-00042s-Lv for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 16:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oa0og-0002za-8j for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 16:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Sep 2022 20:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57884 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 57884-submit@debbugs.gnu.org id=B57884.166353257511472 (code B ref 57884); Sun, 18 Sep 2022 20:23:02 +0000 Original-Received: (at 57884) by debbugs.gnu.org; 18 Sep 2022 20:22:55 +0000 Original-Received: from localhost ([127.0.0.1]:51380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oa0oZ-0002yy-1N for submit@debbugs.gnu.org; Sun, 18 Sep 2022 16:22:55 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:38905) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oa0oV-0002yg-Vw for 57884@debbugs.gnu.org; Sun, 18 Sep 2022 16:22:54 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8B6F924010B for <57884@debbugs.gnu.org>; Sun, 18 Sep 2022 22:22:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1663532564; bh=YRqjtMhu0fT//y5yqyWbi4RfIV93SYA5GMwiu7SQ86k=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=aKj+NTZfK9xpMMeb5O0Buel8waTUMMfPmAGMZZzR+rDVxbkWPMBy5GWzDYlw27ZzG ChoMb6rMTyDJDOnzm+gGuS+Ug/ctvYlVi/NfgcFWo/sPavxKrIhzBoJ+r959PoYqnh mftt7/tNKdjkcn3fivQDtKJfbpG7wWTRCvK1lmPElnTyrA6/tFJshkhdn9UKUi2G2y aTsOqrvvPR9QCWNpHcZd+17Asbe3fAE2k3wI06dJV4AHNGVOeVqPUL3xShzSVffzzY whpyuRvnLzorqYwCapa+OPJwTPfme5LgiDiJrkZtTup7AyIPx4HRiCFxBopKwuVjG1 yPBI5RS7nw+bw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MVzkd6dZZz9rxW; Sun, 18 Sep 2022 22:22:33 +0200 (CEST) In-Reply-To: <878rmgcw2e.fsf@gmail.com> (Augusto Stoffel's message of "Sun, 18 Sep 2022 21:38:17 +0200") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB 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" Xref: news.gmane.io gmane.emacs.bugs:243017 Archived-At: Augusto Stoffel writes: > On Sun, 18 Sep 2022 at 13:46, Philip Kaludercic wrote: > >>> I like in your backend that you read a JSON output, which presumably >>> provides the start _and end_ of the diagnostic region. How did you >>> convert from line/column to buffer position? >> >> I didn't do that, Flymake takes care of that if you give it the buffer >> position (unless I misunderstood something, but it appears to be working >> for me). > > Okay, perhaps the docstring of `flymake-make-diagnostic' is easy to > misinterpret, but apparently it works fine if one passes a (LINE . COL) > cons for BEG and END, even if LOCUS is a buffer. This would also mean > that the call to `flymake-diag-region` in the example backend of the > Flymake manual is unnecessary, so I'm a bit suspicious here. The example backend in the manual has had issues before so I wouldn't be surprised if this were the case. > Anyway, I rewrote the backend to use the JSON output of shellcheck, > which has the advantage that it provides the end position of each > diagnostic, so Flymake doesn't have to guess it (which is by nature > sometimes inaccurate). Let me know what you think. LGTM, but I haven't tested it yet. > PS: What is the best practice w.r.t. the fact that json-serialize might > not be available? It seems that every library that needs to parse JSON > has to define a new alias similar to sh--json-read here. This is rather > suboptimal... All I can add is this: I've re-implemented the native-json functions in Elisp for Compat[0], and it turns out to be more complicated than I had initially expected -- though not impossible. If anyone has Compat installed these definitions will also be loaded even if the user is running Emacs 27.1+, since the test case it uses to check if the definition should be installed is: (not (condition-case nil (equal (json-serialize '()) "{}") (:success t) (void-function nil) (json-unavailable nil))) As Compat is part of GNU ELPA, we could just copy these definitions as fallback into json.el and replace the tests with (fboundp ...) checks. [0] https://git.sr.ht/~pkal/compat/tree/e827a9f3e2ba585de8b07cd246534a15ec414a8b/item/compat-27.el#L137