-
Notifications
You must be signed in to change notification settings - Fork 46
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
Indent problems #151
Comments
Yes, I have this problem, too. I just never opened an issue, because reasons. Do you know how to fix it in emacs? Seems like you know more about this problem than I do. |
The only thing I did is turned off autoindent on paste. For spacemacs this can be done via:
|
Well since I don't use spacemacs, I guess I don't have indent on paste enabled. |
I also noticed this problem. It's strange because
|
@vegansk I don't understand your problem yet. what is the expected result? |
@yuutayamada Well I think he pointed it out quite nicely, even though there is a typo ( |
Sorry, I was wondering if you don't want to indent that region, why you use indent-region function. I assume you guys encountered nasty indentation by using nim-mode, but this example didn't get me the picture.
nim-mode inherited some code, but by the time, the indentation logic was replaced by nim-smie.el. (some features were still remaining though)
FYI, I saw python-mode.el little bit, and it seems skipping indentation when the let x = if true:
echo "foo"
elif true:
echo "bar"
else:
echo "buzz" In above code, nim-mode can auto-indent correctly. |
I think the only thing, that really needs to be addressed is, that pastes should be indeted somehow, and I think that should not be too smart. I don't really know the internals of emacs, and how indentation works, but when I cut a block of code that starts on indentation level X, and then I move my cursor to a position with indentation level Y, the code block should be shifted vertically by Y-X to the right, so that newly inserted code blocks are indented correctly. |
@yuutayamada, maybe |
that is an interesting function indeed. Emacs has so many hidden features ... |
Ok, here is another problem. The code: if url =~ parser:
let params = @matches.filterIt(not it.isNil)
case params.len
of 1:# Cursor is here
else:
result = ("Malformed jdbc url: " & url).left(type(result.get)) The comment shows the position of cursor. And when I press enter, the code becomes: if url =~ parser:
let params = @matches.filterIt(not it.isNil)
case params.len
of 1:
# Cursor is here
else:
result = ("Malformed jdbc url: " & url).left(type(result.get)) Look at the |
@vegansk I tested your example, and I can't reproduce it. The else branch is not affectey by the newline. |
Looks like it can be reproduced in spacemacs only |
After some investigations, I found the solution here:
But now case params.len
of 1: |
@krux02, one more comment, |
Well the else branch actually should indent to the same level as the case of branch, because the else brach is mandatory in almost all case of statements. While in your case it might be not what you want, I guess it's not that wrong. And to talk about spacemacs, I have no idea what it actually chages, so I can't really help with your problem. |
@vegansk this may help about indenting previous line: link though nim-mode pre-configure that regarding the ":", you may avoid the behavior following config: (add-hook 'nim-mode-hook
'(lambda () (setq-local electric-indent-chars '(?\s)))) but I'm not sure it really works for you because the ":"s behavior was implemented only for electric-indent-mode. (and you turned off it) |
Why nim-mode doesn't save indent of the expressions? For example, select this code:
then call
indent-region
and you will get:The text was updated successfully, but these errors were encountered: