cider icon indicating copy to clipboard operation
cider copied to clipboard

Add convenient shortcut to start a build REPL

Open bsless opened this issue 2 years ago • 5 comments

It would be nice to have a cider-jack-in like entrypoint to start a build REPL, imaginecider-jack-in-build

Alternatively, a user could define their own:

;;;###autoload
(defun cider-jack-in-build (params)
  (interactive "P")
  (let ((cider-clojure-cli-aliases "build"))
    (cider-jack-in-clj params)))

A robust solution should probably:

  • let the user specify the alias for a build repl
  • ensure that alias exists in the project's scope with clojure -X:deps aliases
  • let the user specify additional aliases for a build repl

What do you think?

bsless avatar Oct 05 '23 09:10 bsless

I think I've wanted build repls in the past, however I'm not sure they should deserve a special treatment.

Currently, not even :dev and :test aliases get a special treatment (which often trips up users - that's our fault, probably!)

I'd propose the following generalized alternative, based on what we already do for shadow-cljs.edn:

  • parse deps.edn with parseedn
  • extract the available aliases
  • if the user hasn't specified any aliases (via .dir-locals.el or such), propose to the user, before a vanilla jack in is performed, to add a few combinations based on what makes sense (and is available, as parsed)
    • :dev:test
    • :build
    • :dev
    • :test
    • maybe others?

WDYT?

vemv avatar Oct 05 '23 09:10 vemv

That's certainly better, however, what about clojure CLI default aliases? I usually have it set to dev:test, would letting users choose their aliases collide with that? What about global aliases from ~/.clojure? Potential solution: display the current state of aliases for command, and let users accumulate them interactively, or choose DONE However, that takes a long time when starting a REPL, so letting users have predefined combinations would be useful. Solution? Two new entrypoints - one which lets the user construct the sequence of aliases, and one which uses the last defined sequence of aliases in the context of the project Does that solve the problem universally?

bsless avatar Oct 05 '23 18:10 bsless

Something along those lines, but also quite minimalistic, would be to change the type of cider-clojure-cli-aliases from <string> or <nil> to <string> or <list of strings> or <nil>.

So, for a given project:

  • if cider-clojure-cli-aliases is nil, we do exactly as described in https://github.com/clojure-emacs/cider/issues/3497#issuecomment-1748510919
  • if cider-clojure-cli-aliases is a string, cider-jack-in will use that as-is, and the workflow remains as it's always been
  • if cider-clojure-cli-aliases is a list (example: (":dev:test" ":build")), cider-jack-in is interrupted by a completing-read confirming which of the list elements one wants to choose
    • The user can intentfully place ":dev:test" as the first element of the list, so one can hit RET in a very streamlined fashion, given that ~90% of the times one doesn't want the "secondary" (:build) choice.

This way, users can be explicit about which specific projects have more than one choice, but we also don't offer choices where no choice is necessary.

Objections welcome!

vemv avatar Oct 05 '23 20:10 vemv

Hi @bsless, any last input?

vemv avatar Oct 18 '23 18:10 vemv

That sounds like the most ergonomic solution: users can specify their defaults and CIDER will prompt them to choose. Sounds great

bsless avatar Nov 13 '23 09:11 bsless