-
Notifications
You must be signed in to change notification settings - Fork 347
Implement electric characters #1302
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
Conversation
6b3bd31
to
47b681a
Compare
ind) | ||
(self-insert-command arg) | ||
(when (and at-indent? | ||
haskell-indentation-electric-flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to:
(or (equal 'always haskell-indentation-electric-flag)
(bound-and-true-p 'electric-indent-mode))
Then the mode changing hook will not be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I don't know why I didn't think of that. At that point haskell-indentation-electric-flag
might as well just be used as a boolean, so I changed it accordingly.
efd33e8
to
7566120
Compare
is non-nil. | ||
4) The point is not in a comment, string, or quasiquote." | ||
(interactive "*p") | ||
(let* ((col (haskell-indentation-current-indentation)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: please check the (or haskell-indentation-electric-flag electric-indent-mode)
in the beginning of the function. The point is that haskell-indentation-current-indentation
may possibly be buggy, take lots of time or error-out. Therefore it should be invoked only after flag is enabled.
@@ -87,18 +100,13 @@ | |||
It rebinds RET, DEL and BACKSPACE, so that indentations can be | |||
set and deleted as if they were real tabs." | |||
:keymap haskell-indentation-mode-map | |||
(kill-local-variable 'indent-line-function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kill-local-variable
s should stay here. Reason: minor modes may be switched on and off, this code path is for switching off (although it is executed always).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I was thinking that someone would always want either haskell-indent or haskell-indentation. I guess someone might want neither.
This defines various keys that will trigger auto reindentation when appropriate. This approach is somewhat similar to how `cc-mode' implements electric keys. Closes haskell#1133.
Code looks good, I plan to run it locally for a couple of days to see how it 'feels'. |
We should have a nice documentation page in manual. @fice-t, can you write it in |
Should that do for documentation? |
This does it like in `cc-mode'.
Also, I removed a few unnecessary things in the minor mode definition and removed an unused variable (Fixes #1294).
Closes #1133