-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
clojure-mode.el (clojure-mode): Force elec. indentation in a docstring #447
Conversation
…ring By default, ‘electric-layout-post-self-insert-function’ prevents indentation in strings and comments. When ‘electric-indent-mode’ is on, we want ‘newline’ to reindent the line when the point is within a docstring, so this patch adds a hook to ‘electric-indent-functions’ to that effect.
It appears to work for me. Thanks! |
clojure-mode.el
Outdated
@@ -524,7 +524,9 @@ replacement for `cljr-expand-let`." | |||
\\{clojure-mode-map}" | |||
(clojure-mode-variables) | |||
(clojure-font-lock-setup) | |||
(add-hook 'paredit-mode-hook #'clojure-paredit-setup)) | |||
(add-hook 'paredit-mode-hook #'clojure-paredit-setup) | |||
(add-hook 'electric-indent-functions |
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.
I'd really add some explanations here, as people are going to be confused by this bit of code for sure.
You might also consider adding some simple unit test verifying the correct behavior when electric indent is enabled.
Apart from my small inline remark - this needs a changelog entry. |
Hi @bbatsov, thanks for the feedback! I've completely the previous commit with an inline comment and a changelog entry. Hopefully I've done it right. Thanks! |
By default, ‘electric-layout-post-self-insert-function’ prevents indentation in strings and comments. When ‘electric-indent-mode’ is on, we want ‘newline’ to reindent the line when the point is within a docstring, so this patch adds a hook to ‘electric-indent-functions’ to that effect.
This commit breaks variable docstrings indentation for me.
Entering a char in the docstring forces an indent by two spaces:
I had to disable |
By default,
electric-layout-post-self-insert-function
prevents indentation in strings and comments. Whenelectric-indent-mode
is on, we wantnewline
to reindent the line when the point is within a docstring, so this patch adds a hook toelectric-indent-functions
to that effect.See #241 (comment) for a discussion about this bug.