Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

### Bugs fixed

* [#619](https://github.com/clojure-emacs/clojure-mode/issues/619): Fix `clojure-thread-last-all` breaking forms containing line comments by absorbing closing parens into comments.
* Fix typos in `clojure-mode-extra-font-locking`: `halt-when?` -> `halt-when`, `simple-indent?` -> `simple-ident?`.
* Fix `doc` and `find-doc` misplaced under `clojure.core` instead of `clojure.repl` in extra font-locking.

Expand Down
8 changes: 7 additions & 1 deletion clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,13 @@ With universal argument \\[universal-argument], fully unwind thread."
(clojure--remove-superfluous-parens)
;; cljr #255 Fix dangling parens
(forward-sexp)
(when (looking-back "^\\s-*\\()+\\)\\s-*" (line-beginning-position))
(when (and (looking-back "^\\s-*\\()+\\)\\s-*" (line-beginning-position))
;; Don't join if previous line ends in a comment,
;; as that would absorb the parens into the comment.
(not (save-excursion
(forward-line -1)
(end-of-line)
(nth 4 (syntax-ppss)))))
(let ((pos (match-beginning 1)))
(put-text-property pos (1+ pos) 'clojure-thread-line-joined t))
(join-line))
Expand Down
12 changes: 12 additions & 0 deletions test/clojure-mode-refactor-threading-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,18 @@
(comp (serve))
(deftask dev []))"

(beginning-of-buffer)
(clojure-thread-last-all nil))

(when-refactoring-it "should preserve line comments"
"(foo x ;; grobble
(bar y))"

"(->> y
bar
(foo x ;; grobble
))"

(beginning-of-buffer)
(clojure-thread-last-all nil)))

Expand Down