cargo.el icon indicating copy to clipboard operation
cargo.el copied to clipboard

Add a function for running cargo expand

Open RadicalZephyr opened this issue 6 years ago • 3 comments

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?

RadicalZephyr avatar Feb 15 '19 11:02 RadicalZephyr

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.

RadicalZephyr avatar Feb 20 '19 00:02 RadicalZephyr

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.

kwrooijen avatar Jun 07 '19 12:06 kwrooijen

@RadicalZephyr I actually like what https://github.com/joddie/macrostep does.

mookid avatar Dec 16 '19 13:12 mookid