I am trying to use following code:
(defun rust-save-and-build (mode)
(interactive)
(save-buffer)
(setq tmp (shell-command-to-string (format "cygpath.exe -m %s"
(buffer-file-name)))
(if (locate-dominating-file buffer-file-name "Cargo.toml")
(compile mode)
(compile
(format "rustc %s %s.exe"
tmp
(file-name-sans-extension tmp))))))
(defun rust-cmd-run ()
(interactive)
(rust-save-and-build "cargo run"))
(defun rust-cmd-build ()
(interactive)
(rust-save-and-build "cargo build"))
(defun rust-cmd-test ()
(interactive)
(rust-save-and-build "cargo test"))
(add-hook 'rust-mode-hook
(lambda ()
(define-key rust-mode-map (kbd "<f5>") 'rust-cmd-run)))
(add-hook 'rust-mode-hook
(lambda ()
(define-key rust-mode-map (kbd "<f6>") 'rust-cmd-build)))
(add-hook 'rust-mode-hook
(lambda ()
(define-key rust-mode-map (kbd "<f7>") 'rust-cmd-test)))
but get "Wrong type argument: symbolp" error when use f-keys. The debug message is:
Debugger entered--Lisp error: (wrong-type-argument symbolp (if (locate-dominating-file buffer-file-name "Cargo.toml") (compile mode) (compile (format "rustc %s %s.exe" tmp (file-name-sans-extension tmp)))))
(setq tmp (shell-command-to-string (format "cygpath.exe -m %s" (buffer-file-name))) (if (locate-dominating-file buffer-file-name "Cargo.toml") (compile mode) (compile (format "rustc %s %s.exe" tmp (file-name-sans-extension tmp)))))
rust-save-and-build("cargo run")
rust-cmd-run()
call-interactively(rust-cmd-run nil nil)
command-execute(rust-cmd-run)
NB that rust-save-and-build
function works perfectly without argument.