Skip to content

v4.0.0

Latest

Choose a tag to compare

@bbatsov bbatsov released this 16 Jul 15:46
  • (Breaking) Require Emacs 28.1+.

  • (Breaking) Require CIDER 2.0+ (and drop the small compat shims for the pre-2.0 API names).

  • Use refactor-nrepl's namespaced op names (refactor/find-symbol, refactor/clean-ns, …) when the middleware advertises them (refactor-nrepl 3.13.0+, the injected version is now 3.14.0), falling back to the bare names on older versions. refactor-nrepl treats the namespaced forms as canonical and plans to drop the bare names, and namespacing avoids op-name collisions with other middleware.

  • Don't error out of cider-connected-hook when the refactor-nrepl middleware is missing: the connect-time version probe now degrades to the existing "out of sync" warning instead of aborting the startup checks with a cryptic error (visible with CIDER 2.0, whose senders reject unsupported ops client-side).

  • Fix the offline ns-form sort (cljr-clean-ns and cljr-auto-sort-ns without a REPL) silently doing nothing in clojure-ts-mode buffers, where the tree-sitter forward-sexp-function broke clojure-sort-ns.

  • cljr-rename-symbol, cljr-find-usages, cljr-inline-symbol and cljr-change-function-signature now send an explicit ignore-errors value that matches cljr-ignore-analyzer-errors, instead of a nil value that was dropped on the wire. With the default (nil) this means the strict behavior the option documents actually takes effect - a project with an unanalyzable namespace now surfaces a warning rather than silently skipping it.

  • cljr-slash no longer sends the obsolete language-context parameter to the suggest-libspecs op (superseded by buffer-language-context/input-language-context in refactor-nrepl 3.7.0).

  • The asynchronous refactorings (cljr-rename-symbol, cljr-change-function-signature, cljr-rename-file-or-dir) now show a mode-line spinner while the middleware is working, so it's clear the operation is still running. Uses CIDER's spinner, so it honors cider-show-spinner and friends.

  • cljr-rename-symbol and cljr-change-function-signature now find their occurrences asynchronously. Locating every occurrence analyses the whole project, which on a cold cache or a large project could freeze Emacs for a long time; now the command returns immediately and the rename (or the change-signature edit buffer) happens once the search finishes, so Emacs stays responsive meanwhile. As a side effect they now also honor cljr-middleware-ignored-paths.

  • cljr-rename-file-or-dir now runs asynchronously. Renaming a file rewrites references to it across the whole project, which can take a while; instead of freezing Emacs on a synchronous round-trip, the command returns immediately and finishes (renaming the file, revisiting affected buffers) once the middleware responds.

  • Preview project-wide refactorings before they touch disk. cljr-rename-symbol, cljr-change-function-signature and cljr-inline-symbol now gather all their edits first and show them as a diff, and nothing is written until you confirm. Controlled by the new cljr-preview-refactorings (default on); set it to nil for the old apply-immediately behavior.

  • New cljr-undo-last-refactoring reverts every file changed by the last applied rename or change-signature in one step (bound to ur, and in clj-refactor-menu).

  • cljr-change-function-signature can now add and remove parameters, not just reorder and rename them. In the edit buffer, a adds a parameter (you're prompted for its name and a placeholder to insert at call sites) and k/d marks one for removal. Added parameters get their placeholder inserted at every call site; removals are never auto-deleted (an argument might have side effects) - the affected call sites are routed to the manual-intervention buffer for review.

  • cljr-change-function-signature now handles multi-arity functions. It asks which arity to change, then updates only that arity's definition and the call sites whose argument count matches (call sites of other arities are left alone). Run it once per arity to change several.

  • Fix cljr-change-function-signature erroring with "Can't do work on functions of multiple arities" on ordinary single-arity functions. It parsed the middleware's arglists-str assuming an outer-paren format that current CIDER no longer sends, which had broken even the existing reorder/rename against a live REPL.

  • cljr-clean-ns degrades gracefully without a REPL. When the clean-ns middleware op isn't available it falls back to sorting the ns form with clojure-mode's clojure-sort-ns instead of erroring - pruning unused libspecs still needs the middleware and is skipped. Auto-sort after ns changes (cljr-auto-sort-ns) now works offline too.

  • Fix cljr-slash and cljr-add-missing-libspec erroring with "No linked CIDER sessions" when used without a connected REPL, instead of falling back to their offline behavior. cljr--op-supported-p now returns nil when disconnected rather than signaling.

  • Performance: the background artifact-list warming (on REPL connect, per cljr-populate-artifact-cache-on-startup) now populates the Emacs-side cache, not just refactor-nrepl's server-side one. Previously the first cljr-add-project-dependency/cljr-update-project-dependency still blocked on the full artifact-list transfer even though a warmer had already run; now that common case is served from cache without a middleware round-trip.

  • (Breaking) Remove the deprecated namespace-aliases code path from cljr-slash, along with the cljr-slash-uses-suggest-libspec, cljr-suggest-namespace-aliases and cljr-assume-language-context defcustoms. cljr-slash has used the language-context-aware suggest-libspecs op (with an offline fallback) by default for a while now; the old path and its options are gone.

  • cljr-promote-function: promoting a #(...) literal to (fn ...) now works without a REPL - it delegates to clojure-mode's clojure-promote-fn-literal instead of a home-grown, less robust converter. Only the fn -> defn promotion (which needs captured-locals analysis) still requires the middleware, and it no longer shows the "the project will be evaluated" warning for the pure literal case.

  • cljr-remove-let now works without a REPL. It inlines the let's bindings locally - in reverse order, so a binding that refers to an earlier one still resolves - and removes the let, instead of driving cljr-inline-symbol (which required the middleware and showed the "the project will be evaluated" warning once per binding).

  • Fix cljr-add-declaration treating a name as "already declared" when it merely contains, or is contained by, another symbol - names with regexp specials like *db* or valid? were matched incorrectly.

  • cljr-describe-refactoring now opens the refactoring's wiki page in your browser. The previous in-Emacs rendering scraped the wiki's HTML, which broke when GitHub changed its markup and 404'd for the clojure-mode commands in the menu; the candidate list is now limited to the cljr-* commands that actually have wiki pages. This also drops the sgml-mode dependency.

  • cljr-add-project-dependency/cljr-update-project-dependency: give a clear error instead of a raw "search failed" when the project file has no :deps/:dependencies, and drop a stray, no-op middleware check after hotloading.

  • (Deprecation) cljr-introduce-let and cljr-move-to-let are now obsolete aliases for clojure-mode's clojure-introduce-let / clojure-move-to-let (they were already thin wrappers). The keybindings and menu now point at the clojure-* commands directly.

  • cljr-move-form now picks the target file with read-file-name (honoring your completion framework) instead of hardcoding ido-find-file.

  • cljr-cycle-thread now reports a clear error when point isn't inside a threading macro, instead of silently doing nothing.

  • Surface cljr-reify-to-defrecord in clj-refactor-menu (it had no keybinding or menu entry, so it was effectively undiscoverable).

  • cljr-add-missing-libspec degrades gracefully without a REPL. For an aliased symbol like str/join, when refactor-nrepl's resolve-missing op isn't available (or finds nothing) it now falls back to cljr-magic-require-namespaces - so common aliases still work offline, and a missing library can be added and hotloaded (see cljr-slash-add-missing-libs). Previously it errored without a connected REPL.

  • cljr-slash now works without a running REPL. When refactor-nrepl's suggest-libspecs op isn't available, it falls back to the static cljr-magic-require-namespaces table (honoring each entry's :only language context) instead of erroring, so common aliases like str/io still get required before you jack in.

  • cljr-slash can add and hotload a missing library. Entries in cljr-magic-require-namespaces may now carry an :artifact coordinate (e.g. ("json" "cheshire.core" :artifact "cheshire/cheshire")); when the namespace isn't on the classpath, cljr-slash offers to add that artifact as a project dependency and hotload it. Controlled by the new cljr-slash-add-missing-libs (default on).

  • Add clj-refactor-menu, a transient menu of all commands grouped by category (bound to hh under your keybinding prefix, e.g. C-c C-m hh). It mirrors the two-letter keybindings, so it doubles as a way to learn them, and its Options section toggles common settings for the session.

  • Surface clojure-mode's collection-type conversions (clojure-convert-collection-to-list/-map/-vector/-set/-quoted-list) in clj-refactor-menu under "Convert collection to", so they're discoverable from clj-refactor.

  • Performance: project-wide refactorings (rename symbol, inline symbol, change function signature) no longer leave behind buffers they had to open, which previously slowed Emacs down on large renames.

  • cljr-project-clean now shows a progress reporter instead of freezing Emacs silently.

  • Performance: cache the artifact and version lists fetched by the dependency commands, so they aren't re-requested on every invocation. The TTL is configurable via cljr-artifact-cache-ttl (default 300s; set to nil to disable).

  • Performance: cljr-slash caches libspec suggestions per alias (also governed by cljr-artifact-cache-ttl), so repeatedly typing an unresolved alias like str/ no longer does a middleware round-trip on every /.

  • (Breaking) Drop the multiple-cursors, hydra and inflections dependencies.

    • The hydra menus are replaced by the new clj-refactor-menu transient (see above).
    • The multiple-cursors integration is gone; let/extract/promote refactorings now always prompt for names. The cljr-use-multiple-cursors option is removed.
    • Parameter-name guessing in cljr-create-fn-from-example now uses a small built-in inflector instead of inflections.
  • (Breaking) Remove the cljr-thread, cljr-thread-first-all, cljr-thread-last-all, cljr-unwind, cljr-unwind-all, cljr-cycle-privacy, cljr-cycle-if, cljr-cycle-coll, cljr-thread-all-but-last, cljr-use-metadata-for-privacy and cljr-find-usages-ignore-analyzer-errors aliases, all deprecated back in 2.3.0. Use the clojure-* equivalents (now in clojure-mode) and cljr-ignore-analyzer-errors.

  • Use CIDER 1.23's renamed nREPL API (cider-nrepl-sync-request, cider-ensure-session) when available, while staying compatible with older CIDER releases. Fixes byte-compilation warnings against recent CIDER.

  • Re-enable cljr-hotload-dependency, now that refactor-nrepl hotloads dependencies on top of clojure.tools.deps (refactor-nrepl #231). It also accepts deps.edn-style coordinate maps in addition to Leiningen vectors.

  • Upgrade refactor-nrepl.