Skip to content

Commit b901fa7

Browse files
bzgbbatsov
authored andcommitted
Force elec. indentation in a docstring (#447)
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.
1 parent a6f0592 commit b901fa7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Bugs fixed
66

7+
* [#447](https://github.com/clojure-emacs/clojure-mode/issues/241): When `electric-indent-mode` is on, force indentation from within docstrings.
78
* [#438](https://github.com/clojure-emacs/clojure-mode/issues/438): Filling within a doc-string doesn't affect surrounding code.
89
* Fix fill-paragraph in multi-line comments.
910
* [#443](https://github.com/clojure-emacs/clojure-mode/issues/443): Fix behavior of `clojure-forward-logical-sexp` and `clojure-backward-logical-sexp` with conditional macros.

clojure-mode.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,11 @@ replacement for `cljr-expand-let`."
524524
\\{clojure-mode-map}"
525525
(clojure-mode-variables)
526526
(clojure-font-lock-setup)
527-
(add-hook 'paredit-mode-hook #'clojure-paredit-setup))
527+
(add-hook 'paredit-mode-hook #'clojure-paredit-setup)
528+
;; `electric-layout-post-self-insert-function' prevents indentation in strings
529+
;; and comments, force indentation in docstrings:
530+
(add-hook 'electric-indent-functions
531+
(lambda (char) (if (clojure-in-docstring-p) 'do-indent))))
528532

529533
(defcustom clojure-verify-major-mode t
530534
"If non-nil, warn when activating the wrong `major-mode'."

0 commit comments

Comments
 (0)