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

Fix "-> Type" on a single line indentation #52

Merged
merged 1 commit into from
Apr 30, 2015
Merged

Fix "-> Type" on a single line indentation #52

merged 1 commit into from
Apr 30, 2015

Conversation

strega-nil
Copy link

Plus a few minor spelling changes in comments

Fixes #8

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@strega-nil
Copy link
Author

Can I just say thank you to the people who wrote this? Incredibly well commented, easy to edit, awesomeness.

@quantheory
Copy link

Ah! This is definitely an improvement. I find that there are a lot of other cases where indentation is at least somewhat strange in rust-mode, which is perhaps an argument for switching to a more "tried and true" way of dealing with indentation, e.g. based on SMIE. (To see what I mean, find a random if statement with a moderately complex condition, where the { is after the condition rather than on a line by itself, and insert a newline between any random pair of tokens, then reindent the block. This will almost certainly shift the indentation of the entire if block to the right. Several other types of expression are similarly fragile to users adding newlines in "unexpected" places.)

Nevertheless, this PR works around one of the most common bad cases, so it is still quite helpful.

@strega-nil
Copy link
Author

Yes, we can work on the rest of the indentation issues later, this is just an issue that I had that was an easy fix.

@strega-nil
Copy link
Author

@quantheory I'm setting up a new repo in order to work on an SMIE grammar for Rust. Would you like to join me? (I've never done any SMIE work before (and in fact, am an Emacs newbie), so I'd like someone who actually knows what they're doing. Check out the repo.

@quantheory
Copy link

@GBGamer I would, but I'm afraid I am really the wrong person to ask. I actually only have a dimly-remembered mental picture of how SMIE works from several years back, and I'm pretty overextended in any case. I really only check in here because I like to whine hope that some of the quirks in the current rust-mode will get ironed out soon.

@strega-nil
Copy link
Author

Pinging @nikomatsakis

@pnkfelix
Copy link
Member

Okay, normally I'd say "please add a test case."

But I want this badly enough that I'm probably going to just merge it. (I just want to quickly double-check myself that it behaves as advertised -- if so, then I'll merge it and then work on a test case myself.)

@pnkfelix pnkfelix assigned pnkfelix and unassigned nikomatsakis Apr 30, 2015
@pnkfelix
Copy link
Member

Yes, awesome, it fixes both of my most important cases:

    fn foo(a: i32)
           -> i32 {
               // whoops
           }

    fn foo<T>(a: i32)
              -> i32 where T:Foo {
                  // bad too
              }

pnkfelix added a commit that referenced this pull request Apr 30, 2015
Fix "-> Type" on a single line indentation
@pnkfelix pnkfelix merged commit 493cc99 into rust-lang:master Apr 30, 2015
pnkfelix added a commit to pnkfelix/rust-mode that referenced this pull request Apr 30, 2015
huonw added a commit that referenced this pull request Apr 30, 2015
@strega-nil
Copy link
Author

@pnkfelix Thanks for the regression test, I didn't even think about that 😝

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.

emacs mode indentation is wrong when function return -> is on its own line
6 participants