Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions rustic-babel.el
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ directory DIR."
(insert dependencies))))))

(defun rustic-babel-ensure-main-wrap (body)
"Wrap BODY in a 'fn main' function call if none exists."
"Wrap BODY in a `fn main' function call if none exists."
(if (string-match "^[ \t]*\\(pub \\)?\\(async \\)?[fn]+[ \t\n\r]*main[ \t]*(.*)" body)
body
(format "fn main() {\n%s\n}\n" body)))

(defun rustic-babel-include-blocks (blocks)
"Insert contents of BLOCKS to the 'main block' that is being
"Insert contents of BLOCKS to the `main block' that is being
executed with the parameter `:include'."
(let ((contents ""))
(with-current-buffer (current-buffer)
Expand Down Expand Up @@ -366,9 +366,9 @@ executed with the parameter `:include'."

Only supports three cases:

1. Simple value: A='a' -> &str
2. Simple list: A=('a' 'b') -> &[&str]
3. Nested list (org-table): A=(('a' 'b')) -> &[&[&str]]"
1. Simple value: A=\\='a\\=' -> &str
2. Simple list: A=(\\='a\\=' \\='b\\=') -> &[&str]
3. Nested list (org-table): A=((\\='a\\=' \\='b\\=')) -> &[&[&str]]"
(if (listp var)
(if (listp (car var)) "&[&[&str]]" "&[&str]")
"&str"))
Expand All @@ -394,9 +394,9 @@ to be homogenous."

There are only 3 cases:

1. Simple value: A='a' -> &str
2. Simple list: A=('a' 'b') -> &[&str]
2. Nested list (org-table): A=(('a' 'b')) -> &[&[&str]]"
1. Simple value: A=\\='a\\=' -> &str
2. Simple list: A=(\\='a\\=' \\='b\\=') -> &[&str]
2. Nested list (org-table): A=((\\='a\\=' \\='b\\=')) -> &[&[&str]]"
(string-join
(mapcar
(lambda (pair)
Expand Down
84 changes: 42 additions & 42 deletions rustic-cargo.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
:group 'rustic-cargo)

(defcustom rustic-cargo-check-exec-command "check"
"Execute command to run cargo check."
"Execute command to run `cargo check'."
:type 'string
:group 'rustic-cargo)

(defcustom rustic-cargo-test-exec-command "test"
"Execute command to run cargo test."
"Execute command to run `cargo test'."
:type 'string
:group 'rustic-cargo)

(defcustom rustic-cargo-nextest-exec-command "nextest run"
"Execute command to run nextest."
"Execute command to run `nextest'."
:type 'string
:group 'rustic-cargo)

(defcustom rustic-cargo-run-exec-command "run"
"Execute command to run cargo run."
"Execute command to run `cargo run'."
:type 'string
:group 'rustic-cargo)

(defcustom rustic-cargo-build-exec-command "build"
"Execute command to run cargo build."
"Execute command to run `cargo build'."
:type 'string
:group 'rustic-cargo)

Expand Down Expand Up @@ -95,7 +95,7 @@ If nil then the project is simply created."
:group 'rustic-cargo)

(defcustom rustic-cargo-test-disable-warnings nil
"Don't show warnings when running 'cargo test'."
"Don't show warnings when running `cargo test'."
:type 'boolean
:group 'rustic-cargo)

Expand All @@ -112,29 +112,29 @@ instead of applying the default arguments from `rustic-default-test-arguments'."
:group 'rustic-cargo)

(defcustom rustic-default-test-arguments "--benches --tests --all-features"
"Default arguments when running 'cargo test'."
"Default arguments when running `cargo test'."
:type 'string
:group 'rustic-cargo)

(defcustom rustic-cargo-default-install-arguments '("--path" "." "--locked")
"Default arguments when running 'cargo install'."
"Default arguments when running `cargo install'."
:type '(list string)
:group 'rustic-cargo)

(defcustom rustic-cargo-check-arguments "--benches --tests --all-features"
"Default arguments when running 'cargo check'."
"Default arguments when running `cargo check'."
:type 'string
:group 'rustic-cargo)

(defcustom rustic-cargo-build-arguments ""
"Default arguments when running 'cargo build'."
"Default arguments when running `cargo build'."
:type 'string
:group 'rustic-cargo)

(defcustom rustic-cargo-auto-add-missing-dependencies nil
"Automatically adds dependencies to Cargo.toml.
This way rustic checks new diagnostics for 'unresolved import'
errors and passes the crates to 'cargo add'.
This way rustic checks new diagnostics for `unresolved import'
errors and passes the crates to `cargo add'.
Currently only working with lsp-mode."
:type 'boolean
:group 'rustic-cargo)
Expand Down Expand Up @@ -166,12 +166,12 @@ Currently only working with lsp-mode."
"Buffer name for test buffers.")

(defvar rustic-test-arguments ""
"Holds arguments for 'cargo test', similar to `compilation-arguments`.
"Holds arguments for `cargo test', similar to `compilation-arguments`.
Tests that are executed by `rustic-cargo-current-test' will also be
stored in this variable.")

(defvar rustic-test-history nil
"Holds previous arguments for 'cargo test', similar to `compile-arguments`.")
"Holds previous arguments for `cargo test', similar to `compile-arguments`.")

(defvar rustic-cargo-test-mode-map
(let ((map (make-sparse-keymap)))
Expand Down Expand Up @@ -203,7 +203,7 @@ If ARG is not nil, get input from minibuffer."
(rustic-compilation c (list :buffer buf :process proc :mode mode))))

(defun rustic-cargo-nextest-current-test ()
"Run 'cargo nextest run' for the test near point."
"Run `cargo nextest run' for the test near point."
(interactive)
(rustic-compilation-process-live)
(-if-let (test-to-run (setq rustic-test-arguments
Expand All @@ -215,7 +215,7 @@ If ARG is not nil, get input from minibuffer."

;;;###autoload
(defun rustic-cargo-test-run (&optional test-args)
"Start compilation process for 'cargo test' with optional TEST-ARGS."
"Start compilation process for `cargo test' with optional TEST-ARGS."
(interactive)
(rustic-compilation-process-live)
(let* ((command (list (rustic-cargo-bin) rustic-cargo-test-exec-command))
Expand All @@ -227,7 +227,7 @@ If ARG is not nil, get input from minibuffer."

;;;###autoload
(defun rustic-cargo-test (&optional arg)
"Run 'cargo test'.
"Run `cargo test'.

If ARG is not nil, use value as argument and store it in
`rustic-test-arguments'. When calling this function from
Expand All @@ -253,7 +253,7 @@ If ARG is not nil, use value as argument and store it in

;;;###autoload
(defun rustic-cargo-test-rerun (arg)
"Run 'cargo test' with `rustic-test-arguments'."
"Run `cargo test' with `rustic-test-arguments'."
(interactive "P")
(let ((default-directory (or rustic-compilation-directory default-directory)))
(setq rustic-test-arguments
Expand Down Expand Up @@ -284,7 +284,7 @@ If ARG is not nil, use value as argument and store it in

;;;###autoload
(defun rustic-cargo-current-test ()
"Run 'cargo test' for the test near point."
"Run `cargo test' for the test near point."
(interactive)
(rustic-compilation-process-live)
(-if-let (test-to-run (setq rustic-test-arguments
Expand Down Expand Up @@ -390,7 +390,7 @@ If ARG is not nil, use value as argument and store it in

;;;###autoload
(defun rustic-cargo-outdated (&optional path)
"Use 'cargo outdated' to list outdated packages in `tabulated-list-mode'.
"Use `cargo outdated' to list outdated packages in `tabulated-list-mode'.
Execute process in PATH."
(interactive)
(rustic--inheritenv
Expand Down Expand Up @@ -627,7 +627,7 @@ exist, and the rest. Return a cons cell of the two parts."
(cons existing-dir (apply 'file-name-concat (cons "" components)))))

(defun rustic-create-project (project-path is-new &optional bin)
"Run either 'cargo new' if IS-NEW is non-nil, or 'cargo init' otherwise.
"Run either `cargo new' if IS-NEW is non-nil, or `cargo init' otherwise.
Creates or initializes the directory at the path specified by PROJECT-PATH. If
BIN is not nil, create a binary application, otherwise a library."
(let* ((cmd (if is-new "new" "init"))
Expand Down Expand Up @@ -655,14 +655,14 @@ BIN is not nil, create a binary application, otherwise a library."

;;;###autoload
(defun rustic-cargo-new (project-path &optional bin)
"Run 'cargo new' to start a new package in the path specified by PROJECT-PATH.
"Run `cargo new' to start a new package in the path specified by PROJECT-PATH.
If BIN is not nil, create a binary application, otherwise a library."
(interactive "GProject path: ")
(rustic-create-project project-path t bin))

;;;###autoload
(defun rustic-cargo-init (project-path &optional bin)
"Run 'cargo init' to initialize a directory in the path specified by PROJECT-PATH.
"Run `cargo init' to initialize a directory in the path specified by PROJECT-PATH.
If BIN is not nil, create a binary application, otherwise a library."
(interactive "DProject path: ")
(rustic-create-project project-path nil bin))
Expand All @@ -676,10 +676,10 @@ If BIN is not nil, create a binary application, otherwise a library."
"Buffer name for run buffers.")

(defvar rustic-run-arguments ""
"Holds arguments for 'cargo run', similar to `compilation-arguments`.")
"Holds arguments for `cargo run', similar to `compilation-arguments`.")

(defvar rustic-run-history nil
"Holds previous arguments for 'cargo run', similar to `compile-history`.")
"Holds previous arguments for `cargo run', similar to `compile-history`.")

(defvar rustic-cargo-run-mode-map
(let ((map (make-sparse-keymap)))
Expand All @@ -692,7 +692,7 @@ If BIN is not nil, create a binary application, otherwise a library."

;;;###autoload
(defun rustic-cargo-run-command (&optional run-args)
"Start compilation process for 'cargo run' with optional RUN-ARGS."
"Start compilation process for `cargo run' with optional RUN-ARGS."
(interactive)
(rustic-compilation-process-live)
(let* ((command (list (rustic-cargo-bin) rustic-cargo-run-exec-command))
Expand All @@ -704,7 +704,7 @@ If BIN is not nil, create a binary application, otherwise a library."

;;;###autoload
(defun rustic-cargo-run (&optional arg)
"Run 'cargo run'.
"Run `cargo run'.

If ARG is not nil, use value as argument and store it in `rustic-run-arguments'.
When calling this function from `rustic-popup-mode', always use the value of
Expand All @@ -722,7 +722,7 @@ When calling this function from `rustic-popup-mode', always use the value of

;;;###autoload
(defun rustic-cargo-run-rerun (arg)
"Run 'cargo run' with `rustic-run-arguments'."
"Run `cargo run' with `rustic-run-arguments'."
(interactive "P")
(let ((default-directory (or rustic-compilation-directory default-directory)))
(setq rustic-run-arguments
Expand All @@ -733,13 +733,13 @@ When calling this function from `rustic-popup-mode', always use the value of
(rustic-cargo-run-command rustic-run-arguments)))

(defun rustic--get-run-arguments ()
"Helper utility for getting arguments related to 'examples' directory."
"Helper utility for getting arguments related to `examples' directory."
(let ((example-name (rustic-cargo-run-get-relative-example-name)))
(when example-name
(concat "--example " example-name))))

(defun rustic-cargo-run-get-relative-example-name ()
"Run 'cargo run --example' if current buffer within a 'examples' directory."
"Run `cargo run --example' if current buffer within a `examples' directory."
(let* ((buffer-project-root (rustic-buffer-crate))
(current-filename (if buffer-file-name
buffer-file-name
Expand Down Expand Up @@ -777,7 +777,7 @@ in your project like `pwd'"

;;;###autoload
(defun rustic-cargo-build (&optional arg)
"Run 'cargo build' for the current project, allow configuring
"Run `cargo build' for the current project, allow configuring
`rustic-cargo-build-arguments' when prefix argument (C-u) is enabled."
(interactive "P")
(when arg
Expand All @@ -789,11 +789,11 @@ in your project like `pwd'"
(list :clippy-fix t)))

(defvar rustic-clean-arguments nil
"Holds arguments for 'cargo clean', similar to `compilation-arguments`.")
"Holds arguments for `cargo clean', similar to `compilation-arguments`.")

;;;###autoload
(defun rustic-cargo-clean (&optional arg)
"Run 'cargo clean' for the current project.
"Run `cargo clean' for the current project.

If ARG is not nil, use value as argument and store it in `rustic-clean-arguments'.
When calling this function from `rustic-popup-mode', always use the value of
Expand All @@ -812,7 +812,7 @@ When calling this function from `rustic-popup-mode', always use the value of

;;;###autoload
(defun rustic-cargo-check (&optional arg)
"Run 'cargo check' for the current project, allow configuring
"Run `cargo check' for the current project, allow configuring
`rustic-cargo-check-arguments' when prefix argument (C-u) is enabled."
(interactive "P")
(when arg
Expand All @@ -824,7 +824,7 @@ When calling this function from `rustic-popup-mode', always use the value of

;;;###autoload
(defun rustic-cargo-bench ()
"Run 'cargo bench' for the current project."
"Run `cargo bench' for the current project."
(interactive)
(rustic-run-cargo-command (list (rustic-cargo-bin) "bench")))

Expand All @@ -850,11 +850,11 @@ The documentation is built if necessary."
;;; cargo edit

(defvar rustic-cargo-dependencies "*cargo-add-dependencies*"
"Buffer that is used for adding missing dependencies with 'cargo add'.")
"Buffer that is used for adding missing dependencies with `cargo add'.")

;;;###autoload
(defun rustic-cargo-add (&optional arg)
"Add crate to Cargo.toml using 'cargo add'.
"Add crate to Cargo.toml using `cargo add'.
If running with prefix command `C-u', read whole command from minibuffer."
(interactive "P")
(let* ((base (concat (rustic-cargo-bin) " add "))
Expand Down Expand Up @@ -955,7 +955,7 @@ as string."

;;;###autoload
(defun rustic-cargo-rm (&optional arg)
"Remove crate from Cargo.toml using 'cargo rm'.
"Remove crate from Cargo.toml using `cargo rm'.
If running with prefix command `C-u', read whole command from minibuffer."
(interactive "P")
(let* ((command (if arg
Expand All @@ -967,7 +967,7 @@ If running with prefix command `C-u', read whole command from minibuffer."

;;;###autoload
(defun rustic-cargo-upgrade (&optional arg)
"Upgrade dependencies as specified in the local manifest file using 'cargo upgrade'.
"Upgrade dependencies as specified in the local manifest file using `cargo upgrade'.
If running with prefix command `C-u', read whole command from minibuffer."
(interactive "P")
(let* ((command (if arg
Expand Down Expand Up @@ -1009,7 +1009,7 @@ command from minibuffer."
"Buffer name for install buffers.")

(defvar rustic-install-arguments ""
"Holds arguments for 'cargo install', similar to `compilation-arguments`.
"Holds arguments for `cargo install', similar to `compilation-arguments`.
Installs that are executed by `rustic-cargo-current-install' will also be
stored in this variable.")

Expand All @@ -1028,7 +1028,7 @@ stored in this variable.")

;;;###autoload
(defun rustic-cargo-install-rerun ()
"Run 'cargo install' with `rustic-install-arguments'."
"Run `cargo install' with `rustic-install-arguments'."
(interactive)
(rustic-compilation-start rustic-install-arguments
(list :buffer rustic-install-buffer-name
Expand All @@ -1037,7 +1037,7 @@ stored in this variable.")
:directory rustic-install-project-dir)))
;;;###autoload
(defun rustic-cargo-install (&optional arg)
"Install rust binary using 'cargo install'.
"Install rust binary using `cargo install'.
If running with prefix command `C-u', read whole command from minibuffer."
(interactive "P")
(let* ((command (if arg
Expand Down
Loading