Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move entries pairwise in case, cond and similar functions (clojure-ls…
…p#780) Some functions are known to take a set of clauses which are binary expressions. For example, `case` has clauses made up of pairs of a test-constant and a result-expr. These clauses should move together. ```clojure (case a 1 :one |2 :two) ;; should become (case a |2 :two 1 :one) ``` This patch makes clauses move together in `assoc`, `assoc!`, `case`, `cond`, `condp`, `cond->`, and `cond->>`. It's common to find `assoc`, `assoc!`, `cond->`, `cond->>`, and `case` within threading macros, and so this patch handles those situations too. It also handles the optional default clause in `case` and `condp`. And it handles the ternary expression syntax of `condp`. I believe that usage is rare in the wild, but this code understands it. This patch also includes a general fix for move-coll-entry, to treat unevals as comments when moving entries. clj-rewrite calls the #_ reader macro and its contents an "uneval" node. This commit duplicates several zipper movement operators, changing them to treat uneval nodes as comments. This fixes what would otherwise be invalid movements in forms that use `#_=>` to visually separate long lines without adding blank lines.
- Loading branch information