JoeKazama · 2022-02-18 18:35
This is a general question but my specific problem is actually a Rust related one.
By default rustic mode provides a function rustic-cargo-run which calls cargo run without any arguments. I am testing a CLI I created and would like to provide arguments to my run command. I found a function called rustic-run-cargo-command, which has this as it's description: "Start compilation process for 'cargo run' with optional RUN-ARGS".
But i cannot seem to find a way to provide these optional arguments. Can anyone guide me on this issue? For example If I want to run 'cargo run -n test', I would try calling M-x rustic-run-cargo-command -n test but this will not work.
The function definition can be found [here](https://github.com/brotzeit/rustic/blob/master/rustic-cargo.el#L596).
Thank you for your help.
Edit:
/u/Ok-Nefariousness776 's reply down below works. Basically call M-: which will evaluate an expression and passing (rustic-cargo-run-command "-- -n test") adds the necessary arguments to my function.
[deleted] · 2022-02-18 18:39
[deleted]
n-i-c-l-a-s · 2022-02-18 18:48
I am not at all sure if this is the only or the best way to do this, but I use "eval-expression" for this. The shortcut is M-: (meta-colon)
It is similar to M-x , but you have the option to provide parameters to the function you're calling with the "downside" that you have to put your expression in parentheses, eg
```
(org-agenda-month-view 01)
```
nv-elisp · 2022-02-18 19:13
The function you linked to is not a command (it does not have an interactive spec). This means it was not intended to be called via `M-x`. You could write an interactive command which wraps that function if the package has not already provided one.
JoeKazama · 2022-02-18 19:27
Ah ok interesting, I will try creating my own function then.
JoeKazama · 2022-02-18 19:29
Ty for the reply, unfortunately no luck with M-:, typing anything after the function gets me a void-variable error. /u/nv-elisp mentioned down below to create my own function that does accept arguments and wraps around the rustic-run-cargo-command so i will try that.
amareshjoshi · 2022-02-18 21:05
see [https://www.emacswiki.org/emacs/PrefixArgument](https://www.emacswiki.org/emacs/PrefixArgument)
tl;dr
C-u argument(s) M-x command-name
Ok-Nefariousness776 · 2022-02-18 22:13
How are you providing arguments to the function? When using `eval-expression` you'll be dealing with lisp expressions. So if you need do send some textual content to the command, it will need be be wrapped in double quotes. A void variable issue is not a problem with eval-expression or the function you're trying to call. My guess is you either didn't wrap the whole expression in parentheses, or didn't wrap string arguments in double quotes.
a lisp expression will be something like `(my-function "foo" "bar")` not `my-function foo bar`
JoeKazama · 2022-02-19 03:20
Sorry for the late reply but you are completely correct. I wasn't wrapping the args in quotes and now doing (rustic-cargo-run-command "-- -n Hi") actually works!.
Thank you very much /u/Ok-Nefariousness776 <3
JoeKazama · 2022-02-19 03:23
Hey thanks for the reply, I couldn't get it working with C-u but /u/Ok-Nefariousness776 suggested to use M-: and that works for me.