brotzeit/rustic

rustic-cargo-new has a little problem

lushuangning opened this issue · 2 comments

Issue
The funcion rustic-cargo-new in “rustic-cargo.el” has a logical problem.

When I execute the command cargo new --lib mylib in terminal, cargo will automatically create a directory named "mylib" for me, even if the directory does not exist before. But when I execute the rustic-cargo-new function under emacs, emacs will let me choose a directory, and it must be an existing directory, otherwise it will prompt me "match required".
1
2

I checked the source code of the function rustic-cargo-new and found that (interactive "DProject path: ") is used in it, and this D parameter is the cause of the problem. I'm using doomemacs, I don't know if the same is true for other emacs.

Expected behaviour
rustic-cargo-new should create a lib even the directory does not exist before.

Notes
I changed (interactive "DProject path: ") to (interactive "sProject path: ") and then manually entered the path of the directory, the function achieved my purpose, and I can create a new library just like in the terminal

psibi commented

When you use rustic-cargo-new, you can interactively select the existing directory and then type in the new name that you are looking for (appending it with the directory which you have chosen). I tested the workflow and can confirm that I'm able to create both library as well as binary package. Although, I'm not using doomemacs.

chrt commented

I am facing the same issue, with Doom Emacs. I think another possible fix is to mimic how functions like find-file are implemented, i.e. with find-file-read-args.