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 13:46:34 +0000 Message-ID: <8735co4wxx.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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8303"; 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 15:47:11 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 1oZudb-0001uR-8L for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 15:47:11 +0200 Original-Received: from localhost ([::1]:49042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZuda-00084N-8w for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 09:47:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZudS-00081e-UW for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 09:47:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oZudS-0003ld-ME for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 09:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oZudS-00021l-I3 for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 09:47: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 13:47: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.16635088107766 (code B ref 57884); Sun, 18 Sep 2022 13:47:02 +0000 Original-Received: (at 57884) by debbugs.gnu.org; 18 Sep 2022 13:46:50 +0000 Original-Received: from localhost ([127.0.0.1]:48407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZudF-000216-OW for submit@debbugs.gnu.org; Sun, 18 Sep 2022 09:46:50 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:34103) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZudC-00020W-Al for 57884@debbugs.gnu.org; Sun, 18 Sep 2022 09:46:47 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 80BEC240026 for <57884@debbugs.gnu.org>; Sun, 18 Sep 2022 15:46:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1663508800; bh=XoygVLMfew8f3FS8P2qnszF+EWAzjhGBsbHzkqGPgbk=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=hgK8JThLfCG0DEBEn5YdHZUWMiedZZz6a2fIyMSbz3+WsdAPNKV9wjBTkMY9hBQDS LGsiPfv+MiegxhCzYHbGtly3sgPjWQeYeUr5mEHe0lFHe7uv3dZswTiO4WVTRjnr58 9tAMBN8B3Z7oe3AHtsqdxZ4rSek+nH/lyvh3R8neuypI6jAY0oIp7D+hF70C6tdW03 0VEk2wAHc2rvk87yDk4O7zBNEKaZeXrQ9IwUTik6SdoNdNnnY7Nfso0xSwstGJNKqx SwPfSuGTEgwN2qtnGkBonhwcnHklIHJD6cm4GArIvQQZFXOkyG+aL6sqUThw5eVFEO lf+TZwOnzSghg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MVpxk4B03z6tns; Sun, 18 Sep 2022 15:46:34 +0200 (CEST) In-Reply-To: <87edw8n71p.fsf@gmail.com> (Augusto Stoffel's message of "Sun, 18 Sep 2022 15:30:58 +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:242994 Archived-At: Augusto Stoffel writes: > On Sun, 18 Sep 2022 at 12:50, Philip Kaludercic wrote: > >>>> I don't use `named-let' that much, but calling both the result and the >>>> recursive function `dialect' seems confusing to me. >>>> >>> >>> Welcome to Lisp-2... >> >> It is not so much that they share the same name, but that I don't >> understand why you close to give the function the name "dialect". From >> what I have seen, named-let is usually given a self-referential call >> like "next", "recur", "loop", etc. > > Yeah, I have no strong opinion about the name. > >>>> Wouldn't it be cleaner to pull this lambda out into a separate named function? >>>> >>> >>> That's not possible, it needs to be in that lexical scope. >> >> Not if you use `process-put' and `process-get'. I recently reworked >> flymake-proselint and did the same thing. IMO it doesn't look that bad: >> >> https://git.sr.ht/~manuel-uberti/flymake-proselint/commit/30c4baa08db32e73d956c978c81a9f79062c2e1d > > Honestly, I much prefer to have some state localized in a closure than > in what is effective a global variable... Not quite, you can only access the value if you have access to the process object. I guess you can argue that the process object is stored as a file local variable which sort of makes it global... > 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). > I think it would be nice to extend flymake-diag-region to have signature > > (flymake-diag-region BUFFER LINE &optional COL LINE-END COL-END) > > If you provide LINE-END and COL-END, then those are converted to buffer > positions and there's no guessing as to what they should be. > >>>> Also what happens if someone doesn't have shellcheck installed? >>> >>> Then Flymake logs a warning and disables the backend. The error message >>> will be whatever make-process gives, which I find more than good enough. >> >> But isn't that rather late to detect the error. Couldn't you also check >> if "shellcheck" (or whatever the new option name will be) can be found >> in the path before adding the hook in `shell-mode'? > > I think this is worse than not doing anything. If you don't check and > let the backend fail, it gets displayed as a disabled backend, and the > user has the chance to look at the log buffer and try to figure out why > it's not working. If we did what we suggest, we'd have to reinvent the > wheel to convey that information to the user, I think. On the other hand there might be people who don't care about shellcheck (say they just open a shell script once a year) and any error message would just be an annoyance. The most important part is having the ability to use shellcheck prominently documented, the rest is probably just a matter of taste.