Fork me on GitHub

(defun mm/cider-jack-in-with-an-alias-from-deps ()
  (if-let* ((root (project-root (project-current t)))
	    (_ (file-exists-p (expand-file-name "deps.edn" root))))
      (let* ((default-directory root)
	       "Cider jack in with alias: "
		 (format "bb -e '%s'" (princ '(->> (slurp "\"deps.edn\"") read-string :aliases keys (map name))))))))
	       cider-clojure-cli-aliases ":" my-alias)))
	(call-interactively #'cider-jack-in-clj))
    (user-error "no deps.edn file in project")))
I can't be the only one who wanted this

👍 1

That could be improved to also take into account the other aliases available (user level for instance).


But that's quite nice already


didn’t the clojure cli add a new option to list all aliases?

Alex Miller (Clojure team)19:06:53

clj -X:deps aliases but it's not very data oriented (if needed, would be open to an edn output option too)


I remembered I had used it but didn’t find it in clj --help so I got a bit confused

Programs provided by :deps alias:
 -X:deps mvn-install       Install a maven jar to the local repository cache
 -X:deps git-resolve-tags  Resolve git coord tags to shas and update deps.edn
 -X:deps find-versions     Find available versions of a library
 -X:deps prep              Prepare all unprepped libs in the dep tree

Alex Miller (Clojure team)19:06:54

yeah, some of the docs are still lagging the newer stuff


I personally just set cider-edit-jack-in-command to true


Yes it was added this week, good point


also, does this elisp code allow selecting multiple?


(just use a prefix when jacking-in will let you edit the command as well). Or stuffing all of the stuff cider wants into a profile (easily copy from the startup command in the top of the repl) and then just use terminal to start your process clj -M:dev:stuff:cider/nrepl and off you go

👀 1

It can be done. Stuff like transient menus come to mind


Also dir-locals can be used


But in my experience cider-edit-jack-in-command is the least intrusive


It's just an extra RET when you don't edit the aliases and otherwise you're free to add whatever

👍 1

.dir-locals.el works fine for my workflow. I don't understand / relate to a use case for this. Are people frequently changing their aliases that it needs some picker? Is it because lots of different projects are being used and they all use different alias names ? Does this approach have to rely on external tools that may not be installed?


for me the use case is when I have build or test aliases and I want to repl. If I have a dev alias it is covered with .dir-locals


Is there a reason the test and build aliases cannot be included in the .dir-locals.el configuration and loaded into the REPL on startup? Do they add significant resource overhead? I typically include the dev and test aliases in .dir-locals.el so I can run the cider-test runner (although I often use kaocha in watch mode in a separate terminal as well) I usually build from the command line (assuming I need to manually build at all - build is mostly done by continuous integration server or docker if its a local complex (AWS) environment) Maybe I am missing something...


you are right putting all dev aliases in dir-locals would fix it


I was curious to know if there were common cases I wasn't aware of. I am aware Calva for VS Code has an alias picker, perhaps because the VS Code doesn't have an equivalent of a .dir-locals.el. Maybe a picker is useful for occasional user level aliases, although I have too many aliases for a checkbox style picker, unless it's coupled with a completion selector - although again it's probably easier to edit the .dir-locals.el


I always use completing-read or completing-read-multiple.


The 2nd one. Usually I use that when working on projects that have different naming conventions for their "dev" profile.


Which is quite rare indeed