Fork me on GitHub
#emacs
<
2023-01-23
>
vxe05:01:18

years ago there was a package(s) which allowed helm searching clojars and yanking the version does anyone remember what this was called or have a similar workflow implemented to search clojars and get the mvn coordinates? thx

jumar07:01:09

I don't remember the package but cljr-add-project-dependency seemed to offer similar functionality (and also automatically adding this to your project, even hotloading the dependency when it was working properly)

teodorlu07:01:31

You might also be able to use Neil's Emacs UI: https://github.com/babashka/neil#emacs-integration

šŸ‘€ 2
vxe07:01:12

> I don't remember the package cljr-add-project-dependency seemed to offer similar functionality (and also automatically adding this to your project, even hotloading the dependency when it was working properly) ooh yeah i think this is the one, do you happen to know if it still works?

practicalli-johnny10:01:56

https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-add-project-dependency did work many years ago when I last used clj-refactor package Hotloading the library into the dependence did stop working, although I assume clojars API hasn't changed so the adding of dependency should still work

practicalli-johnny10:01:19

I assume app project dependencies only works for Leiningen projects. Find-versions can be used for Clojure CLI (deps.edn) projects, specifying the library-name to search for

Clojure -X:deps find-versions :lib library-name
Note: Update after misreading docs... sorry https://clojure.org/reference/deps_and_cli#find-versions

vxe07:02:38

following up on this, there is a way to have a similar workflow to the now defunct cljr-refactor-hotload-dependency functionality 1. get cljr-add-project-dependency working with correct version numbers for cider-nrepl and refactor-nrepl, this gives the auto-complete search of clojars from emacs (search only, nothing else) a. for whatever reason when running the above it mangles my deps.edn. if that happens to you, try the following to simply push the mvn coordinate to kill ring

(defun cljr-add-project-dependency-print (force)
  "Add a dependency to the project.clj file.

See: "
  (interactive "P")
  (cljr--ensure-op-supported "artifact-list")
  (when-let ((lib-name (thread-last (cljr--get-artifacts-from-middleware force)
                         (cljr--prompt-user-for "Artifact: ")))
             (version (thread-last (cljr--get-versions-from-middleware lib-name)
                        (cljr--prompt-user-for "Version: "))))
    (kill-new (concat lib-name " {:mvn/version \"" version "\"}"))))
2. Download + Install https://github.com/lambdaisland/classpath which will watch your deps.edn and do the reloading 3. call cljr-add-project-dependency (or the modified one), to update deps.edn 4. Hopefully classpath will download and load the lib into you running repl Additional Steps for Embedded Repl (aka cider-connect vs cider-jack-in) ā€¢ add the following deps
refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}         
        cider/cider-nrepl {:mvn/version "0.30.0"}
ā€¢ redefine cider-nrepl-handler like so
(def cider-nrepl-handler-custom
  "We build our own custom nrepl handler, mimicking CIDER's."
  (apply nrepl.server/default-handler
         (conj cider.nrepl.middleware/cider-middleware 'refactor-nrepl.middleware/wrap-refactor))) 
ā€¢ launch repl as before referencing new handler
(defonce server (start-server :port 42069
                                :host  "0.0.0.0"
                                :bind "0.0.0.0"
                                :handler cider-nrepl-handler-custom
                                ))

ag15:01:30

There's also magit-log-trace-definition - it shows the log of changes for a selected function. There's a caveat though https://twitter.com/iLemming/status/1058507343372021760v You have to set it up to make it work for Clojure.

Jason17:01:22

I just started using ob-clojure and am trying to figure out what's up with result output.

#+begin_src clojure
  (+ 1 1)
#+end_src

#+RESULTS:
nothing is printed in results, but anything printed does.
#+begin_src clojure :results pp
  (+ 1 1)
#+end_src

#+RESULTS:
: 2
I tried this with babashka and clj-cli backends, maybe it has something to do with shell backends? Should it be showing values without explicitly printing?

Jason17:01:39

it looks like it's because it invokes bb sometestfile.clj which doesn't output return values

borkdude17:01:04

@U036QHV2M4Z which bb version is this?

borkdude17:01:33

bb used to print return values before 1.1.171 (released today) but this is now opt-in using the --prn flag

Jason17:01:51

babashka v1.1.171

Benjamin17:01:00

I have the suspicion you get you value when you wrap it in (println ..)

borkdude17:01:15

I think ob-clojure should be updated to account for this new behavior

Jason17:01:21

thanks @U04V15CAJ! sounds like ob-clojure needs an update

borkdude17:01:23

using the --prn flag will work with both the old and new version

ā¤ļø 2
Jason17:01:18

heyy, it works!

borkdude17:01:46

cool - is this built into emacs? can take a long time before it's updated, right?

Jason17:01:46

I'm using GNU Emacs 28.2 (build 2, aarch64-apple-darwin22.1.0, NS appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2023-01-02 and had to pull the latest org to get it. I have no idea how updates or for that matter contributions work

borkdude17:01:07

ok, would be good if somebody did that change ASAP :)

Jason17:01:37

oh man, I'll do this tonight if nobody gets to it first https://orgmode.org/worg/org-contribute.html#first-patch

šŸ‘ 2
borkdude17:01:20

It seems @UFAP0C8KU also contributed to this

dakra18:01:04

Since a few week, I have a patch laying around to solve the different output behaviours. The cider backend was not consistent with the normal bable conventions and babashka and nbb where different with the last return value which apparently is now fixed since today šŸ™‚

dakra18:01:13

@U036QHV2M4Z no need to write a patch as I have the code already. I'm also the current maintainer of ob-clojure so I'm allowed to push to the repo.. i.e. it doesn't take month until the patch gets installed šŸ˜‰

gratitude-thank-you 4
šŸ‘ 4
šŸŽ‰ 2
Jason22:01:20

Btw, just adding --prn isn't enough, it keeps asking if it should execute return values in parens (basically any list return values) as elisp. I imagine there's some 'not elisp!' setting somewhere

vxe07:02:38

following up on this, there is a way to have a similar workflow to the now defunct cljr-refactor-hotload-dependency functionality 1. get cljr-add-project-dependency working with correct version numbers for cider-nrepl and refactor-nrepl, this gives the auto-complete search of clojars from emacs (search only, nothing else) a. for whatever reason when running the above it mangles my deps.edn. if that happens to you, try the following to simply push the mvn coordinate to kill ring

(defun cljr-add-project-dependency-print (force)
  "Add a dependency to the project.clj file.

See: "
  (interactive "P")
  (cljr--ensure-op-supported "artifact-list")
  (when-let ((lib-name (thread-last (cljr--get-artifacts-from-middleware force)
                         (cljr--prompt-user-for "Artifact: ")))
             (version (thread-last (cljr--get-versions-from-middleware lib-name)
                        (cljr--prompt-user-for "Version: "))))
    (kill-new (concat lib-name " {:mvn/version \"" version "\"}"))))
2. Download + Install https://github.com/lambdaisland/classpath which will watch your deps.edn and do the reloading 3. call cljr-add-project-dependency (or the modified one), to update deps.edn 4. Hopefully classpath will download and load the lib into you running repl Additional Steps for Embedded Repl (aka cider-connect vs cider-jack-in) ā€¢ add the following deps
refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}         
        cider/cider-nrepl {:mvn/version "0.30.0"}
ā€¢ redefine cider-nrepl-handler like so
(def cider-nrepl-handler-custom
  "We build our own custom nrepl handler, mimicking CIDER's."
  (apply nrepl.server/default-handler
         (conj cider.nrepl.middleware/cider-middleware 'refactor-nrepl.middleware/wrap-refactor))) 
ā€¢ launch repl as before referencing new handler
(defonce server (start-server :port 42069
                                :host  "0.0.0.0"
                                :bind "0.0.0.0"
                                :handler cider-nrepl-handler-custom
                                ))