Fork me on GitHub
#cider
<
2018-06-28
>
mccraigmccraig09:06:52

is it possible to (deliberately) drop a cider connection without also killing the associated buffer ? i quite often want to keep my session history, but connect to a different vm... cider-quit and cider-connections-close-connection both kill the buffer

bozhidar12:06:38

@mccraigmccraig I think it was possible at some point, but not anymore. Before we had two different buffers - connection buffer and repl buffer and we could attach a connection to any REPL buffer. Now the REPL and the connection are the same. Maybe we can think of something, though. File some ticket on the issue tracker and we can discuss this further there.

dpsutton15:06:53

is there some kind of hook to turn off cider-mode introduced recently? I've found I've had to enable cider-mode in quite a few clj/cljs buffers

richiardiandrea15:06:19

@dpsutton I thought I was crazy but now that you mention it, I have had the same!

dpsutton15:06:49

yeah it keeps asking me for a tags file. and then i cider-mode and then life is good again. super strange

richiardiandrea16:06:23

Uhm haven't seen the tag file thing but cider mode was turned off in some buffers, i have eval in .dir-locals.el and this might mean cider-mode in a switch now..not enable only..maybe?

jjttjj16:06:17

How do I define an indent spec so that the second line is always just indented one space regarless of what's on the first line? I feel like I've tried everything in the indent_spec docs but can't seem to get this to work

(h/div :class "container"
           (h/h1 "title")

jjttjj16:06:10

(define-clojure-indent
  (div '(:defn)))

(define-clojure-indent
  (div 0))
The former does 2 spaces instead of one and the latter aligns with the first arg class

dpsutton16:06:23

@richiardiandrea when you ask to navigate to symbol and cider mode isn't on that's what you'll get. an option to select a tags file

richiardiandrea16:06:40

ah yes I saw that as well

gfredericks17:06:01

I have a clojure function for reformatting a file how can I make a cider keybinding to apply this to a file, presumably by evaling some code in the repl?

bozhidar17:06:39

@gfredericks You just have to put your function in the cider-mode-map.

bozhidar17:06:52

(define-key cider-mode-map ...)

gfredericks17:06:03

an elisp function though, right?

gfredericks17:06:15

I have a clojure function, so I need to know what elisp to write to tie them together

bozhidar17:06:42

You can just call your function with something like cider-interactive-eval.

gfredericks17:06:45

it could either work by supplying the whole contents of the buffer to the clojure function and replacing the buffer with the return value, or by supplying a filename and then running revert

gfredericks18:06:03

any guess which of those is easier?

bozhidar18:06:22

Btw, what does your function do exactly? You do know that cider has integration with cljfmt, right?

bozhidar18:06:47

@dpsutton There are no changes I can think of.

gfredericks18:06:50

it does cljfmt + how-to-ns + normalized end-of-file-newlines

bozhidar18:06:59

If something got broken this was accidental.

gfredericks18:06:30

what function can I use to lookup values in a (dict ...)? I tried get-hash but that didn't work

gfredericks18:06:37

google isn't sure

bozhidar18:06:33

nrepl-dict-get

bozhidar18:06:45

You can see the dict api in nrepl-dict.el.

gfredericks18:06:55

ah cool, thanks

bozhidar18:06:13

> it could either work by supplying the whole contents of the buffer to the clojure function and replacing the buffer with the return value, or by supplying a filename and then running revert

bozhidar18:06:17

You can also extend the code formatting functionality that exists today and just leverage whatever else exists for the code formatting already.

bozhidar18:06:49

The part about the newline in the end can be done by Emacs itself. No need for a clojure function to do this IMO. Every editor can ensure a trailing newline.

gfredericks18:06:08

yes, but I already have a clojure function because this also gets used e.g. in CI and by people who don't use emacs

bozhidar18:06:00

Fair enough.

dpsutton18:06:52

there were functions you could invoke called cider-before-refresh-fn and after but they seem to be gone now. they were strings that were evaled in clojure before and after refreshing. you could see how those are used if you're on an older CIDER

gfredericks18:06:41

I'm having trouble with calling (revert-buffer) in my callback; I guess elisp lambdas aren't closures? (let ((buffer ...)) (lambda (resp) ...))

dpsutton18:06:21

its a dynamic lisp

gfredericks18:06:44

do I need to setq a global or something obnoxious like that?

gfredericks18:06:57

I'd partially apply a 2-arg lambda if I knew how

richiardiandrea18:06:21

you can wrap it in a (lambda () ...)

dpsutton18:06:29

try using a bit more obfuscated var name. callback-buffer

gfredericks18:06:50

still void-variable

gfredericks18:06:58

@richiardiandrea I'm not sure how that helps

dpsutton18:06:17

got a gist anywhere?

gfredericks18:06:17

slack doesn't have an elisp option I guess

dpsutton18:06:47

one thing to try: instead of remembering the buffer, remember the buffer name and then try (with-current-buffer buffer-name.... just to see if your logic is correct. also, do you know how to debug elisp?

dpsutton18:06:41

that also seems to be sending (./lint-fix. I didn't know that was a valid name in clojure. and i don't think it is

gfredericks18:06:34

. is the namespace

gfredericks18:06:43

I use it all the time

dpsutton18:06:50

ah. had no idea you could do that

dpsutton18:06:57

that's an alias name you mean?

dpsutton18:06:16

haha you have (ns .) somewhere?

gfredericks18:06:54

considering the error is void-variable it would be weird if switching to buffer-name worked I tried it anyhow, and it didn't work

gfredericks18:06:02

I'll just try the setq route

dpsutton18:06:30

can you post the error message for me?

gfredericks18:06:02

works fine with the global

bozhidar18:06:38

@dpsutton It’s cider-refresh-before/after-fn, btw.

dpsutton18:06:41

oh of course. ;;; -*- lexical-binding: t -*- should be at the top of your file

dpsutton18:06:15

it's dynamic. and there is no binding callback-buffer when that lambda is run (dynamic). but there is one at definition time if its lexical

gfredericks18:06:17

lexical-binding: t fixes it

dpsutton18:06:53

shakes fist at emacs

dpsutton19:06:23

I had a let binding (let ((comment-start ... and at some point moved sexp forward. this broke emacs because comment-start is a global regex defining what comments look like

gfredericks19:06:35

good ole globals

dpsutton19:06:53

well globals and then no notion of shadowing

gfredericks19:06:31

emacs is the worst editor except for all the others