Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function for running cargo expand #82

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

RadicalZephyr
Copy link

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?

This attempts to expand just the currently visited file by looking at
the base directory it lives in relative to the project root.
@RadicalZephyr RadicalZephyr force-pushed the expand branch 3 times, most recently from 1007a77 to 6a9fc42 Compare February 16, 2019 01:01
@RadicalZephyr
Copy link
Author

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.

@kwrooijen
Copy link
Owner

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.

@mookid
Copy link
Contributor

mookid commented Dec 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants