i often get error in process filter: nrepl-send-sync-request: Sync nREPL request timed out (op eval code (require 'figwheel.main))
when running cider-jack-in-cljs
in this project https://github.com/athomasoriginal/demo-clojurescript-app
but not every time. sometimes it works, opens a browser, opens a repl connected to it, does all the good things
i think i got it. need to set nrepl-syn-request-timeout
to a higher value. was 10
, is 20
. has worked the last few times i've tested it. this is a big improvement over the prior success rate.
I've define a macro which I'd like to indent the same as case. Is there a way to tell cider (and hopefully also tell cursive) that I want it to use case
rules for indenting?
(rte-case '(1 2 3)
(:* String) 0
(:* Number) 1
(:* Long) 2)))
currently it indents as follows:
(rte-case '(1 2 3)
(:* String) 0
(:* Number) 1
(:* Long) 2)))
Since some of the users of my library use cursive, it would be nice if it indents the same for both.
I'm a little surprised that it doesn't just work because the lambda list of case
is [e & clauses]
and the lambda list of rte-case
is [sequence & clauses]
.@jimka.issy Don't know about Cursive, but clojure-mode
(which is what CIDER relies on for indentation[1]) uses a list of builtin forms/macros and their associated indentation specifications. You can change them and add your own specs to that list, using define-clojure-indent
macro. CIDER also supports indentation specification via metadata[2], which could be a way to share indentation specifications with Cursive. But I don't use Cursive, so I don't know if it supports that metadata specification.
[1] https://docs.cider.mx/cider/0.26/config/indentation.html
[2] https://docs.cider.mx/cider/0.26/indent_spec.html
As I said, CIDER isn't in charge of indentation, clojure-mode
is. And clojure-mode
only deals with text buffers, so it doesn't "eval code" (as CIDER does) and thus doesn't know if a given form is a function or a macro (as stated in the first link I provided), or what the "macro lambda list" is . Of course clojure-mode
knows about the core Clojure macros (like case
) and thus it can indent them the way you would expect. But for unknown ones (like yours) it can only guess. And I suspect the safe guess is "assume it's a function" (as opposed to "assume it's a macro"), so it applies the default indentation for functions.
So you need to tell clojure-mode
that you want some form(s) to be indented a particular way (using one of the two methods documented in the first link).
In your case you can have a look at the indent specification for case
in clojure-mode
(see https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L1569-L1644) and use put-clojure-indent
or define-clojure-indent
as suggested in the first link:
(put-clojure-indent 'rte-case 1)
(define-clojure-indent (rte-case 1))
Or you can programmatically get the indentation spec for case
with clojure--get-indent-method
and use that to define the rte-case
indentation spec:
(put-clojure-indent 'rte-case (clojure--get-indent-method "case"))
(define-clojure-indent (rte-case (clojure--get-indent-method "case")))
OK, that's interesting. Slime (the predecessor of cider) asks the running lisp for hint on indentation if available.
so indentation might change/improve as you develop your code.
I saw those docs, already. Thanks. But I didn't see how I could say I want my macro to indent like case
.
Do I have to re-engineer what case
did?
Is it strange that cider doesn't just notice that the macro lambda list is [x & y]
?
Common lisp has &rest
and &body
which have the same evaluation semantics, but notifiy the human reading the code, and also the IDE/editor that what folows &body
is the body of a function, usually in a macro call-site.
hi, I have a question related to orchard
, I noticed that xref/fn-deps
cannot find macros used inside a function. there are ways around it?
Probably not. I imagine it can only contemplate the expanded form?