cargo.el
cargo.el copied to clipboard
Add a function for running cargo expand
Expand is really useful for writing macros.
I think it would be neat to have the output buffer be a temporary that was in Rust-mode so that you could get proper syntax highlighting, but I'm not sure of the best way to do that. Any thoughts?
I settled for actually visiting a file with the same name as the current filename + _expanded
. This is pretty unsatisfactory since it pollutes your source files with code that probably doesn't compile. I guess a better solution would be to write these to temporary file and add a command+keybinding to save it into a user-choosable directory if they want to.
You could use Emacs Overlays. This command takes the entire buffer, and expands it? In that case something like..
(setq rust-expand-overlay (make-overlay 1 (point-max))
(overlay-put rust-expand-overlay 'invisible t)
(overlay-put rust-expand-overlay 'before-string expanded-buffer-string)
And then add a key command (typically q
) to remove the overlay.
(delete-overlay rust-expand-overlay)
Not sure if this is a proper solution though.
@RadicalZephyr I actually like what https://github.com/joddie/macrostep does.