unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Augusto Stoffel <arstoffel@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	57884@debbugs.gnu.org, Stefan Kangas <stefankangas@gmail.com>
Subject: bug#57884: [PATCH] Flymake backend using the shellcheck program
Date: Sun, 18 Sep 2022 20:22:33 +0000	[thread overview]
Message-ID: <87h7148mba.fsf@posteo.net> (raw)
In-Reply-To: <878rmgcw2e.fsf@gmail.com> (Augusto Stoffel's message of "Sun, 18 Sep 2022 21:38:17 +0200")

Augusto Stoffel <arstoffel@gmail.com> 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





  reply	other threads:[~2022-09-18 20:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-17 16:48 bug#57884: [PATCH] Flymake backend using the shellcheck program Augusto Stoffel
2022-09-17 17:05 ` Eli Zaretskii
2022-09-17 17:32   ` Augusto Stoffel
2022-09-17 17:52     ` Eli Zaretskii
2022-09-17 18:17       ` Stefan Kangas
2022-09-17 17:55     ` Eli Zaretskii
2022-09-17 18:04     ` Stefan Kangas
2022-09-18  7:52       ` Augusto Stoffel
2022-09-18 11:55     ` Philip Kaludercic
2022-09-18 12:38       ` Augusto Stoffel
2022-09-18 12:50         ` Philip Kaludercic
2022-09-18 13:30           ` Augusto Stoffel
2022-09-18 13:46             ` Philip Kaludercic
2022-09-18 19:38               ` Augusto Stoffel
2022-09-18 20:22                 ` Philip Kaludercic [this message]
2022-09-18 21:18                   ` Philip Kaludercic
2022-09-19  7:33                     ` Augusto Stoffel
2022-09-19  8:03                       ` Philip Kaludercic
2022-09-24  7:05                     ` Augusto Stoffel
2022-09-24  8:01                       ` Philip Kaludercic
2022-11-04 22:56                         ` Philip Kaludercic
2022-09-18 11:58     ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7148mba.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=57884@debbugs.gnu.org \
    --cc=arstoffel@gmail.com \
    --cc=eliz@gnu.org \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).