Skip to content

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

Merged
merged 3 commits into from
May 7, 2016
Merged

Implement electric characters #1302

merged 3 commits into from
May 7, 2016

Conversation

fice-t
Copy link
Contributor

@fice-t fice-t commented Apr 29, 2016

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

@fice-t fice-t force-pushed the indentation branch 2 times, most recently from 6b3bd31 to 47b681a Compare April 29, 2016 01:57
ind)
(self-insert-command arg)
(when (and at-indent?
haskell-indentation-electric-flag
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@fice-t fice-t force-pushed the indentation branch 2 times, most recently from efd33e8 to 7566120 Compare April 29, 2016 06:03
is non-nil.
4) The point is not in a comment, string, or quasiquote."
(interactive "*p")
(let* ((col (haskell-indentation-current-indentation))
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kill-local-variables should stay here. Reason: minor modes may be switched on and off, this code path is for switching off (although it is executed always).

Copy link
Contributor Author

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.
@gracjan
Copy link
Contributor

gracjan commented May 3, 2016

Code looks good, I plan to run it locally for a couple of days to see how it 'feels'.

@gracjan
Copy link
Contributor

gracjan commented May 3, 2016

We should have a nice documentation page in manual. @fice-t, can you write it in doc/haskell-mode.texi? It is pretty easy.

@fice-t
Copy link
Contributor Author

fice-t commented May 7, 2016

Should that do for documentation?

@gracjan gracjan merged commit db874f5 into haskell:master May 7, 2016
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.

2 participants