Fork me on GitHub
#cider
<
2017-10-19
>
kardan07:10:29

Anyone know why “M-.” & “M-,” does not work automagically (without manually evaluation of namespaces) when connecting to a app running within docker (with docker-compose)? I can get it working if I evaluate the namespace I want to “jump to”, but then if I reset (using Duct) I need to evaluate again. Does this ring a bell for anyone?

benedek11:10:28

@kingcode paredit forward with prefix perhaps?

benedek11:10:53

so basically explore paredit with prefixes

kingcode12:10:50

Thank you @benedek - I will look into it..

benedek14:10:36

@kardan I think the nses you want to be able to jump from etc need to be loaded

benedek14:10:02

if you use one flavor of the reloaded repl they usually are

kardan14:10:13

@benedek we’re using Duct but for some reason when we migrated to an docker-compose setup things stopped working properly.

benedek15:10:35

never used duct @kardan

benedek15:10:59

what is your workflow in terms of cider/repl?

kardan15:10:42

cider-connect to an exposed repl

benedek15:10:59

there is some kind of reloaded repl in duct, right? does it start working if you reset?

benedek15:10:45

that should tnr/refresh eg load all the nses in your repl

kardan15:10:11

Running Cider v 0.15.1-snapshot at the moment (but think I have tried with an older version to)

kardan15:10:53

To answer your earlier question Duct uses reloaded.repl & we call reset from https://github.com/akvo/akvo-lumen/blob/develop/backend/dev/src/dev.clj#L16

kardan15:10:19

Sorry to spam 😳

dominicm16:10:07

@kardan I know why, it's because the paths are set to those inside the docker container

dominicm16:10:25

When you re-eval, you send a new filepath for the namespace, which means you can jump to it.

dominicm16:10:15

I think there might a way to handle this in emacs around re-writing paths, but that's beyond my knowledge, @benedek?

dominicm16:10:03

You can confirm this by looking at the (meta #'symbol) before and after re-eval'ing the namespace

benedek16:10:00

rings a bell dominicm

benedek16:10:16

we had a similar issue in cljr

benedek16:10:06

not solved afaik

gonewest81816:10:08

Given this function, defined in cider-interaction.el

(defun cider-eval-defun-to-comment (loc)
  "Evaluate the \"top-level\" form and insert result as comment at LOC.
With a prefix arg, LOC, insert before the form, otherwise afterwards."
  (interactive "P")
  (let* ((bounds (cider-defun-at-point 'bounds))
         (insertion-point (nth (if loc 0 1) bounds)))
    (cider-interactive-eval nil
                            (cider-eval-print-with-comment-handler
                             (current-buffer) insertion-point ";; => ")
                            bounds)))

gonewest81816:10:54

I can trivially make a variant that evals the last sexp, like so:

(defun cider-eval-last-sexp-to-comment (loc)
  "Evaluate the \"top-level\" form and insert result as comment at LOC.
With a prefix arg, LOC, insert before the form, otherwise afterwards."
  (interactive "P")
  (let* ((bounds (cider-last-sexp 'bounds))
         (insertion-point (nth (if loc 0 1) bounds)))
    (cider-interactive-eval nil
                            (cider-eval-print-with-comment-handler
                             (current-buffer) insertion-point ";; => ")
                            bounds)))

gonewest81816:10:11

where the only change is the let binding for “bounds”.

gonewest81816:10:59

So then, why can’t I also pprint the output like this? If I try this function the output is lost in the void somewhere.

(defun cider-pprint-eval-last-sexp-to-comment (loc)
  "Evaluate the \"top-level\" form and insert result as comment at LOC.
With a prefix arg, LOC, insert before the form, otherwise afterwards."
  (interactive "P")
  (let* ((bounds (cider-last-sexp 'bounds))
         (insertion-point (nth (if loc 0 1) bounds)))
    (cider-interactive-eval nil
                            (cider-eval-print-with-comment-handler
                             (current-buffer) insertion-point ";; => ")
                            bounds
                            (cider--nrepl-pprint-request-plist (cider--pretty-print-width)))))

gonewest81807:10:51

I think this is because pprint typically directs to *out* unless explicitly told otherwise. So the solution is going to involve setting a handler that takes care of that.

kardan17:10:46

Will have to look into my issue more but thanks @dominicm & @benedek . You given me a direction to look at