Fork me on GitHub
#cider
<
2019-07-24
>
carkh06:07:53

So I wanted to have cider start with an alias, and was able to do it with (setq cider-clojure-cli-global-options "-A:dev")as explained there https://github.com/clojure-emacs/cider/issues/2396 But @bozhidar on this page mentions using the .dir-locals.el file to make this a project local thing... I wasn't able to make that part work

carkh06:07:23

Here is what's in the file

carkh06:07:52

i think the trouble might be with the mode, i tried clojure-mode and even nil

carkh06:07:05

any idea on what the correct incantation might be ?

tianshu06:07:56

@carkh dir locals will be load when you are opening a file, you can check if it has a correct value by M-x describe-variable.

carkh06:07:34

oh i was using already opened buffers that must be it then, thanks !

tianshu06:07:46

you can do re-open with C-x C-v

carkh06:07:27

i'll unset the global thing and try it, and report back !

carkh06:07:05

and it's working thanks again @doglooksgood

carkh06:07:28

that's some crazy thing, 10 minutes ago i didn't know i've always needed that... emacs is still full of surprises

practicalli-johnny07:07:07

@carkh @doglooksgood you can also use revert-buffer to get .dir-locals.el to load. My experiences in setting this up are here http://jr0cket.co.uk/2019/07/CIDER-jack-in-to-Clojure-CLI-projects-from-Spacemacs.html (only difference for Emacs is the keybindings)

tianshu07:07:35

will cider find correctly pick the repl buffer from clojure(deps.edn) + cljs(figwheel-main). I remember you post a great video guide on using cider for clojure/script development on Emacs. I'm using shadow-cljs, in my case, cider can't get the correct repl buffer to eval s-expr or switch to.

tianshu08:07:16

after checking the issue of cider, I though this bug has been exists for a long time, I don't know if it's a bug only related to shadow-cljs.

tianshu11:07:33

I think there already a issue for this, but it's closed. the problem still exist similar to https://github.com/clojure-emacs/cider/issues/2447 or https://github.com/clojure-emacs/cider/issues/2489 In my case, when you have two repl, both can be seen in sesman, when try C-c C-z or C-c C-e. It will say there's no repl in current session.

tianshu11:07:21

function sesman-current-session won't return the correct session. Assuming you have two repl(clj and cljs), if you open CLJS repl buffer, then jump to a CLJ file, press C-c C-z, sesman-current-session will pick the CLJS session, the result is an error for there's no clj repl.

malabarba15:07:48

https://clojurians.slack.com/archives/C0617A8PQ/p1563829853005500 @cfleming No. When there's no argument on the first line cider indents the special arguments by 4 spaces. It just happens that in the example I used this happened to line up with the function name 😛

malabarba15:07:58

I guess it was a bad example 🙂

bozhidar15:07:46

@malabarba Don’t you mean 2 spaces? 🙂

malabarba15:07:48

Well, it's indented by 2 spaces more than body arguments. Which adds up to 4. (if you count relative to the outside of the expression)

bozhidar16:07:42

Ah, now I get what you mean. Sorry about that!

jaide17:07:41

Hello, I’m running cider-pprint-eval-defun-at-point but it’s not actually pprint’ing the results.

jaide17:07:01

[:div.event-progress [:ul.event-progress__list ([:li.event-progress_item {:class "event-progress__item--is_active"} "Discover"] [:li.event-progress_item {:class "event-progress__item--is_active"} "Find Venues"] [:li.event-progress_item {:class "event-progress__item--is_active"} "Get Quote"] [:li.event-progress_item {:class nil} "Review Proposal"] [:li.event-progress_item {:class nil} "Book Event"])]]

jaide17:07:18

Is what it’s outputting when I would like line breaks and indentation so I can quickly examine it to make sure it’s correct.

dpsutton17:07:53

when it has the parens in it it doesn't work (note ([:li ...) when i switch that to a vector it works. i guess if it throws an error it doesn't pprint?

jaide17:07:16

Interesting! For more context, that data structure is returned by a function. How can I eval the function and have the results pprinted like the right side of your screen?

jaide17:07:51

(ns app.views.ui.event-progress
  (:require [clojure.pprint :refer [pprint]]))

(def order [:discover
            :search
            :expressbook
            :proposal
            :book])

(def labels {:discover "Discover"
             :search "Find Venues"
             :expressbook "Get Quote"
             :proposal "Review Proposal"
             :book "Book Event"})

(defn find-index
  [target list]
  (->> list
       (keep-indexed #(if (= %2 target) %1))
       (first)))

(defn event-progress
  [{:keys [active-item]}]
  (let [active-idx (find-index active-item order)]
    [:div.event-progress
     [:ul.event-progress__list
      (vec (for [i (range 0 (count order))]
             (let [key (get order i)
                   label (get labels key)]
               [:li.event-progress_item
                {:class (if (<= i active-idx) "event-progress__item--is_active")}
                label])))]]))

(comment
  (event-progress {:active-item :expressbook})
  (find-index :proposal order))

jaide17:07:34

I’m trying to eval (event-progress {:active-item :expressbook}) and then see the results pprinted