~mgmarlow/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH flymake-clippy] Allow passing arguments to the clippy command

Jens Östlund <hi@iensu.me>
Details
Message ID
<20231101121017.23250-1-hi@iensu.me>
DKIM signature
missing
Download raw message
Patch: +7 -1
---
Hi! I added a variable to be able to pass arguments to the clippy command and I thought it might be useful for others as well :)

 flymake-clippy.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/flymake-clippy.el b/flymake-clippy.el
index e9dfffc..1599896 100644
--- a/flymake-clippy.el
+++ b/flymake-clippy.el
@@ -65,6 +65,11 @@
(defvar-local flymake-clippy--proc nil
  "Clippy subprocess object, used to ensure obsolete processes aren't reused.")

(defvar flymake-clippy-clippy-args nil
  "A list of arguments to be passed to the `cargo clippy' command.

For example, a value of `(\"-W\" \"clippy::pedantic\")' will result in the command `cargo clippy -- -W clippy::pedantic'.")

(defun flymake-clippy-backend (report-fn &rest _args)
  "Flymake backend for Clippy, the Rust linter.

@@ -84,7 +89,8 @@ with the appropriate Flymake hook."
            (make-process
             :name "flymake-clippy" :noquery t :connection-type 'pipe
             :buffer (generate-new-buffer "*flymake-clippy*")
             :command '("cargo" "clippy")
             :command '("cargo" "clippy" ,@(when flymake-clippy-clippy-args
                                             (cons "--" flymake-clippy-clippy-args)))
             :sentinel
             (lambda (proc _event)
               (when (memq (process-status proc) '(exit signal))
--
2.42.0
Details
Message ID
<91f616cb-b10a-486f-8655-afc833ea0a97@mgmarlow.com>
In-Reply-To
<20231101121017.23250-1-hi@iensu.me> (view parent)
DKIM signature
missing
Download raw message
> Hi! I added a variable to be able to pass arguments to the clippy command and I thought it might be useful for others as well :)

Hello! Thanks for the contribution. I think this is a great feature.

>   flymake-clippy.el | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/flymake-clippy.el b/flymake-clippy.el
> index e9dfffc..1599896 100644
> --- a/flymake-clippy.el
> +++ b/flymake-clippy.el
> @@ -65,6 +65,11 @@
>   (defvar-local flymake-clippy--proc nil
>     "Clippy subprocess object, used to ensure obsolete processes aren't reused.")
> 
> +(defvar flymake-clippy-clippy-args nil
> +  "A list of arguments to be passed to the `cargo clippy' command.
> +
> +For example, a value of `(\"-W\" \"clippy::pedantic\")' will result in the command `cargo clippy -- -W clippy::pedantic'.")
> +

Since we expect users to edit this variable I think it should be a 
defcustom. That way it shows up in their customize UI as well.

>   (defun flymake-clippy-backend (report-fn &rest _args)
>     "Flymake backend for Clippy, the Rust linter.
> 
> @@ -84,7 +89,8 @@ with the appropriate Flymake hook."
>               (make-process
>                :name "flymake-clippy" :noquery t :connection-type 'pipe
>                :buffer (generate-new-buffer "*flymake-clippy*")
> -             :command '("cargo" "clippy")
> +             :command '("cargo" "clippy" ,@(when flymake-clippy-clippy-args
> +                                             (cons "--" flymake-clippy-clippy-args)))
>                :sentinel
>                (lambda (proc _event)
>                  (when (memq (process-status proc) '(exit signal))
> --
> 2.42.0

I think I might clean this up a bit by extracting the command to a 
function. That way we can bring in your new defcustom a little easier 
without needing the quoted splice operator. Something like this example: 
https://github.com/purcell/flymake-ruby/blob/master/flymake-ruby.el#L42-L44.
Details
Message ID
<m21qd8lj66.fsf@fabriken.lan>
In-Reply-To
<91f616cb-b10a-486f-8655-afc833ea0a97@mgmarlow.com> (view parent)
DKIM signature
missing
Download raw message
Graham Marlow <graham@mgmarlow.com> writes:

>> Hi! I added a variable to be able to pass arguments to the clippy command and I thought it might be useful for others as well :)
>
> Hello! Thanks for the contribution. I think this is a great feature.
>
>>   flymake-clippy.el | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>> diff --git a/flymake-clippy.el b/flymake-clippy.el
>> index e9dfffc..1599896 100644
>> --- a/flymake-clippy.el
>> +++ b/flymake-clippy.el
>> @@ -65,6 +65,11 @@
>>   (defvar-local flymake-clippy--proc nil
>>     "Clippy subprocess object, used to ensure obsolete processes aren't reused.")
>> +(defvar flymake-clippy-clippy-args nil
>> +  "A list of arguments to be passed to the `cargo clippy' command.
>> +
>> +For example, a value of `(\"-W\" \"clippy::pedantic\")' will result in the command `cargo clippy -- -W clippy::pedantic'.")
>> +
>
> Since we expect users to edit this variable I think it should be a defcustom. That way it shows up in their customize UI as well.
>

That's true!

>>   (defun flymake-clippy-backend (report-fn &rest _args)
>>     "Flymake backend for Clippy, the Rust linter.
>> @@ -84,7 +89,8 @@ with the appropriate Flymake hook."
>>               (make-process
>>                :name "flymake-clippy" :noquery t :connection-type 'pipe
>>                :buffer (generate-new-buffer "*flymake-clippy*")
>> -             :command '("cargo" "clippy")
>> +             :command '("cargo" "clippy" ,@(when flymake-clippy-clippy-args
>> +                                             (cons "--" flymake-clippy-clippy-args)))
>>                :sentinel
>>                (lambda (proc _event)
>>                  (when (memq (process-status proc) '(exit signal))
>> --
>> 2.42.0
>
> I think I might clean this up a bit by extracting the command to a function. That way we can bring in your new defcustom a little
> easier without needing the quoted splice operator. Something like this example:
> https://github.com/purcell/flymake-ruby/blob/master/flymake-ruby.el#L42-L44.

Yes, that sounds like a cleaner way to go about it. Do you want me to make any changes to this patch? When you extract the command to a function argument support comes for free so there'll be no need for it.
Reply to thread Export thread (mbox)