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

clojure-mode.el (clojure-mode): Force elec. indentation in a docstring #447

Merged
merged 2 commits into from
Oct 7, 2017

Conversation

bzg
Copy link
Contributor

@bzg bzg commented Oct 1, 2017

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.

See #241 (comment) for a discussion about this bug.

…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.
@raxod502
Copy link

raxod502 commented Oct 1, 2017

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
Copy link
Member

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.

@bbatsov
Copy link
Member

bbatsov commented Oct 7, 2017

Apart from my small inline remark - this needs a changelog entry.

@bzg
Copy link
Contributor Author

bzg commented Oct 7, 2017

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!

@bbatsov bbatsov merged commit b901fa7 into clojure-emacs:master Oct 7, 2017
slipset pushed a commit to slipset/clojure-mode that referenced this pull request Nov 1, 2017
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.
@abo-abo
Copy link
Contributor

abo-abo commented Jul 1, 2019

This commit breaks variable docstrings indentation for me.

|(def foo "docstring" 123)

Entering a char in the docstring forces an indent by two spaces:

|  (def foo "docstring1" 123)

I had to disable electric-indent-mode in my config.

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.

4 participants