This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-24
Channels
- # announcements (6)
- # architecture (9)
- # aws (2)
- # babashka (49)
- # beginners (160)
- # boot (19)
- # calva (9)
- # cider (16)
- # clj-kondo (17)
- # cljfx (9)
- # clojure (143)
- # clojure-australia (5)
- # clojure-berlin (1)
- # clojure-czech (3)
- # clojure-europe (64)
- # clojure-france (1)
- # clojure-italy (12)
- # clojure-nl (4)
- # clojure-spec (6)
- # clojure-uk (47)
- # clojurescript (27)
- # code-reviews (5)
- # conjure (45)
- # cursive (47)
- # datascript (2)
- # datomic (21)
- # events (1)
- # fulcro (9)
- # graalvm (4)
- # graphql (2)
- # jackdaw (22)
- # jobs (3)
- # kaocha (6)
- # london-clojurians (1)
- # luminus (4)
- # malli (19)
- # meander (136)
- # pathom (4)
- # pedestal (2)
- # re-frame (15)
- # reitit (2)
- # remote-jobs (2)
- # rum (12)
- # sci (1)
- # shadow-cljs (100)
- # spacemacs (10)
- # sql (1)
- # tools-deps (30)
- # vrac (1)
- # xtdb (30)
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
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.
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.
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?