Skip to content

Commit 5e7f581

Browse files
committed
[Fix $438] Narrow to doc-strings before fill
1 parent eacd330 commit 5e7f581

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
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+
* [#438](https://github.com/clojure-emacs/clojure-mode/issues/438): Filling within a doc-string doesn't affect surrounding code.
78
* Fix fill-paragraph in multi-line comments.
89
* [#429](https://github.com/clojure-emacs/clojure-mode/issues/429): Fix a bug causing last occurrence of expression sometimes is not replaced when using `move-to-let`.
910
* [#423](https://github.com/clojure-emacs/clojure-mode/issues/423): Make `clojure-match-next-def` more robust against zero-arity def-like forms.

clojure-mode.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ This only takes care of filling docstring correctly."
574574

575575
(defun clojure-fill-paragraph (&optional justify)
576576
"Like `fill-paragraph', but can handle Clojure docstrings.
577-
578577
If JUSTIFY is non-nil, justify as well as fill the paragraph."
579578
(if (clojure-in-docstring-p)
580579
(let ((paragraph-start
@@ -584,7 +583,14 @@ If JUSTIFY is non-nil, justify as well as fill the paragraph."
584583
(concat paragraph-separate "\\|\\s-*\".*[,\\.]$"))
585584
(fill-column (or clojure-docstring-fill-column fill-column))
586585
(fill-prefix (clojure-docstring-fill-prefix)))
587-
(fill-paragraph justify))
586+
(let* ((beg (nth 8 (syntax-ppss)))
587+
(end (save-excursion
588+
(goto-char beg)
589+
(or (ignore-errors (forward-sexp) (point))
590+
(point-max)))))
591+
(save-restriction
592+
(narrow-to-region beg end)
593+
(fill-paragraph justify))))
588594
(let ((paragraph-start (concat paragraph-start
589595
"\\|\\s-*\\([(:\"[]\\|`(\\|#'(\\)"))
590596
(paragraph-separate

0 commit comments

Comments
 (0)