-
Notifications
You must be signed in to change notification settings - Fork 181
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 doctest editing command #218
Conversation
Added support for doctests in crate-level documentation and squashed it down to one commit to make it more manageable. |
This sounds neat. |
Given that it’s been 10 months, I don’t think this PR will be merged, heh. You may be better off opening a new one. |
It is not clear to me why it is taking so long for this PR to be reviewed and possibly merged. It does improve the usability and makes it more convenient to write the docs, which is an important aspect of Rust ecosystem. Could someone take a look at it? |
I’ll try to take a look at this this week |
Not knowing that this PR exists, I replicated almost exactly the thing that this PR does, except for rustdoc comments, also using edit-indirect (I believe this is what @0x3UH4224D asked for?), as a proof of concept: https://gist.github.com/antifuchs/aa9fa4c3d1354ea163bc13e63d32db1a @Aankhen - I would love if we could merge both our work and either get this merged or failing that, release it as a separate package. |
I moved to rustic-mode. It would be a nice candidate for this contribution 🙏 |
@antifuchs: That’s very cool, and yes, it does sound like what @0x3UH4224D was asking for! I’d love to merge them or release them as a separate package. I can’t quite figure out whether @otavio: I don’t know much about |
I think one of the things we could do is to have two different edit commands, so we get pop-ups directly from the rust buffer (I believe nested edit-indirections might work, but popping them down should probably happen in the right order). From my recent experience with rustic (and judging from comments about rust-mode's maintenance situation), I think it might be better to make a separate package - should also make it easier to have dependencies that aren't vital for the rust-mode package. I'll try and merge our two pieces by next weekend into a separate package and will make you a contributor once I have something ready! |
Depends on what exactly you mean by "nested". You cannot have multiple overlapping indirect regions of one buffer at the same time, but you can call If you mean the former, I may add support for overlapping indirect regions if you can show me a use case for which it makes sense, because it would mostly be a matter of relaxing one check. |
@antifuchs: All of that makes sense; separate commands is indeed what I was thinking, and nested @Fanael: Thanks for the clarification! I meant the latter (calling |
Hi Guys, do you plan to merge this function, and make it available for everybody as standard rust-mode feature? It would be great! |
Hey @Aankhen, would you consider working on that PR again? |
Hi @mookid. Sure, I’ve updated it and double-checked that the tests pass. |
So the other day I saw a comment on the gist above that points to https://github.com/twlz0ne/comment-edit.el - a more generic comment-editing mode that handles rust doc comments (and the contained rust examples!) quite well. These days, I'd probably recommend this over solutions custom-built for a single language (: |
hi @Aankhen I completely missed your message. I'll take a look at the whole story as soon as I get some time. |
That looks very cool. Thanks for sharing the link here! I take it you’ve been using it and had no issues with Rust doc comments? |
I’ll assume that’s a yes, so, since this isn’t being merged and there’s a better, more generally applicable alternative, I’m going to close this PR. |
Adds a command
rust-edit-doctest
(bound toC-c C-e
by default) that opens the doctest around point in an indirect buffer and pre– as well as postprocesses it to ease editing. The indirect buffer is placed in a newrust-doctest-mode
that recognizes a leading hash as a comment character. After editing, the code is replaced in the original file and the region is re-indented. Here’s a screenshot:This is all accomplished using edit-indirect. If that package is not loaded, the keybinding is not added. I initially placed the definition of the
rust-edit-doctest
command itself under a conditional, but then I thought it would be more useful to have the command show an explanatory error in case it’s missing.rust-doctest-mode
doesn’t account for escaped hashes. I’m not sure how to implement that. Any suggestions would be welcome!