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

emacs mode indendation is wrong for string constants with backslashes #9

Closed
steveklabnik opened this issue Feb 2, 2015 · 6 comments · Fixed by #43
Closed

emacs mode indendation is wrong for string constants with backslashes #9

steveklabnik opened this issue Feb 2, 2015 · 6 comments · Fixed by #43

Comments

@steveklabnik
Copy link
Member

Issue by nikomatsakis
Wednesday Apr 16, 2014 at 22:20 GMT

For earlier discussion, see rust-lang/rust#13568

This issue was labelled with: A-tools in the Rust repository


the following code indents oddly:

pub fn foo() {
    format!("abc \
def")
}

I expect:

pub fn foo() {
    format!("abc \
             def")
}
@MicahChalmer
Copy link
Contributor

I think the current indentation is correct. I wouldn't expect indentation to ever change the inside of a string literal. (None of the other programming modes that I tried out do it either.)

The Scan error: "Unbalanced parentheses" error message is still there, as mentioned in the comments of the old issue, is still there though, and shouldn't be. But the end result would be the same.

@shepmaster
Copy link
Member

I agree that I'd be surprised if a string literal was indented on the second line. I can also confirm I see the Scan error: "Unbalanced parentheses" error.

@nikomatsakis
Copy link
Contributor

I disagree. Most languages don't have backslashes at the end of line which skip all following whitespace. The express purpose of this syntax is to allow you to indent string constants nicely!

@nikomatsakis
Copy link
Contributor

If you look through rustc you'll see where it's useful and also that indenting single-line strings that are spread across multiple lines so that they line up is what we typically do (although now that emacs doesn't handle it correctly, many of them have gotten messed up over time).

@MicahChalmer
Copy link
Contributor

Well I'll be--I didn't know that. Sure enough, this:

fn main() {
    println!("foo\
              bar");
}

prints foobar. As I write this, I can find no reference to that anywhere in either the reference or the book, so I filed rust-lang/rust#22698.

But now I understand the original issue here.

@shepmaster
Copy link
Member

Certainly not how I expected to learn about this feature, either!

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 a pull request may close this issue.

4 participants