Hi folks,
I'd like to share a snippet of Elisp, which activates Emacs'
flymake-mode whenever rust-mode is activated. Flymake is a minor mode
for background-compiling the current source file, and highlighting
errors in the buffer, with a pop-up (invoked by C-c C-d, in this case)
to show the error message.
It works well enough for small toy programs (the kind of stuff I'm
doing). It might need some adjustments for crates, or larger-scale
applications (for example, it just calls "rustc --no-trans" on the
current buffer, it doesn't hunt for Makefiles etc.).
If anyone has a better flymake configuration, I'd love to have it!
Cheers,
Graham
;; flymake-rust.el
(require 'flymake)
(require 'rust-mode)
(defun flymake-rust-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "/usr/local/bin/rustc" (list "--no-trans" local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'(".+\\.r[cs]$" flymake-rust-init
flymake-simple-cleanup flymake-get-real-file-name))
(defun flymake-rust-load ()
(flymake-mode t)
;; change these bindings as you see fit
(local-set-key (kbd "C-c C-d") 'flymake-display-err-menu-for-current-line)
(local-set-key (kbd "C-c C-n") 'flymake-goto-next-error)
(local-set-key (kbd "C-c C-p") 'flymake-goto-prev-error))
(add-hook 'rust-mode-hook 'flymake-rust-load)
(provide 'flymake-rust)
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev