Skip to content

Commit dc1bbc8

Browse files
Pass :always-return-ns-form true to clean-ns (#558)
This allows for cleaning up whitespace even if there are no structural changes.
1 parent fa3efe1 commit dc1bbc8

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
## 3.12.0
6+
7+
- `clean-ns` will now also reformat the `ns` form for whitespace-only changes, if needed.
8+
- Previously, this wasn't possible since refactor-nrepl generally only works at the structural level.
9+
- Use refactor-nrepl [3.10.0](https://github.com/clojure-emacs/refactor-nrepl/blob/v3.10.0/CHANGELOG.md#3100).
10+
511
## 3.11.3
612

713
- Fix incorrectly serialized values for `cljr-slash` when using `cljr-suggest-libspecs`.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Either in your project's `project.clj` or in the `:user`
5858
profile found at `~/.lein/profiles.clj`:
5959

6060
```clojure
61-
:plugins [[refactor-nrepl "3.9.1"]
61+
:plugins [[refactor-nrepl "3.10.0"]
6262
[cider/cider-nrepl "0.45.0"]]
6363
```
6464

clj-refactor.el

+10-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
;; Lars Andersen <[email protected]>
88
;; Benedek Fazekas <[email protected]>
99
;; Bozhidar Batsov <[email protected]>
10-
;; Version: 3.11.3
10+
;; Version: 3.12.0
1111
;; Keywords: convenience, clojure, cider
1212

1313
;; Package-Requires: ((emacs "26.1") (seq "2.19") (yasnippet "0.6.1") (paredit "24") (multiple-cursors "1.2.2") (clojure-mode "5.18.0") (cider "1.11.1") (parseedn "1.2.0") (inflections "2.6") (hydra "0.13.2"))
@@ -2951,9 +2951,13 @@ in the namespace."
29512951
(defun cljr--replace-ns (new-ns)
29522952
(save-excursion
29532953
(cljr--goto-ns)
2954-
(clojure-delete-and-extract-sexp)
2955-
(insert new-ns)
2956-
(cljr--just-one-blank-line)))
2954+
(let ((begin (point)))
2955+
(forward-sexp)
2956+
(let ((old-ns (buffer-substring begin (point))))
2957+
(when (not (string-equal old-ns (string-trim-right new-ns)))
2958+
(delete-region begin (point))
2959+
(insert new-ns)
2960+
(cljr--just-one-blank-line))))))
29572961

29582962
(defun cljr--clean-ns (&optional path no-prune?)
29592963
"If PATH is passed use, that instead of the path to the current buffer.
@@ -2970,6 +2974,7 @@ removed."
29702974
(cljr--create-msg "clean-ns"
29712975
"path" path
29722976
"relative-path" relative-path
2977+
"always-return-ns-form" "true"
29732978
"libspec-whitelist" cljr-libspec-whitelist
29742979
"print-right-margin" cljr-print-right-margin
29752980
"print-miser-width" cljr-print-miser-width
@@ -3500,7 +3505,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-inline-symbol"
35003505
;; We used to derive the version out of `(cljr--version)`,
35013506
;; but now prefer a fixed version to fully decouple things and prevent unforeseen behavior.
35023507
;; This suits better our current pace of development.
3503-
(defcustom cljr-injected-middleware-version "3.9.1"
3508+
(defcustom cljr-injected-middleware-version "3.10.0"
35043509
"The refactor-nrepl version to be injected.
35053510
35063511
You can customize this in order to try out new releases.

0 commit comments

Comments
 (0)