Fork me on GitHub
#cider
<
2020-06-17
>
papachan08:06:48

is there a way to unbind the <return> key from cider repl?

papachan08:06:40

From the docs:

(define-key cider-repl-mode-map (kbd "RET") #'cider-repl-newline-and-indent)

bozhidar10:06:44

It’s always nice to see someone reads them. 🙂

😄 1
tianshu09:06:12

Is it possible for a macro to tell cider which string is a docstring? something like :style/indent.

bozhidar10:06:40

@doglooksgood Currently not. What’s your usecase?

tianshu12:06:28

I just curious, the docstring for user macros, can't get a correct highlight. anyway, this is not important.

bozhidar13:06:55

Ah, I think I misunderstood you. clojure-mode has some degree of configurability about this, but I guess it depends on the macro.

manas_marthi19:06:42

I want to remap  M-e to eval last sexp. how to do it? please help. I tried this `(define-key cider-repl-mode-map (kbd "M-e") #'cider-eval-last-sexp )`   but it did not work (edited) This is the error Symbol's value as variable is void: cider-repl-mode-map

dpsutton20:06:49

trying (require 'cider) or (require 'cider-repl) before defining it.

1
manas_marthi22:06:01

thank you.

(require 'cider-eval)
(define-key clojure-mode-map (kbd "M-e") #'cider-eval-last-sexp )

Scott Silver23:06:45

If you’re working in some namespace

(ns some.namespace
  (:require
    [clojure.spec.alpha :as s]))

(s/fdef add-pos-ints
  :args (s/cat :a pos? :b pos?))

(defn add-pos-ints [a b]
  (+ a b))
and then enable spec instrumentation in the repl:
some.namespace> (require '[clojure.spec.test.alpha :as stest])
some.namespace> (stest/instrument)
then spec will give you the errors you’d expect:
some.namespace> (add-pos-ints 1 -1)

-- Spec failed --------------------

Function arguments

  (... -1)
       ^^

should satisfy

  pos?

-------------------------
Detected 1 error
but if you then reevaluate the buffer (say by calling cider-eval-buffer), then instrumentation no longer gives you the errors you’d expect:
some.namespace> (add-pos-ints 1 -1)
=> 0
this makes sense with the way instrumentation works, but it’s a frustrating development experience to have to call (stest/instrument) every time you reevaluate something. is there any way to have spec instrumentation always be “on” in Cider? for instance, is there some way to define a hook that would get called whenever you call cider-eval-buffer , so you could automatically call (stest/instrument) ?