This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-14
Channels
- # announcements (6)
- # architecture (5)
- # aws (4)
- # beginners (79)
- # boot (3)
- # boot-dev (7)
- # calva (21)
- # cider (17)
- # cljdoc (12)
- # clojure (83)
- # clojure-art (2)
- # clojure-belgium (2)
- # clojure-brasil (1)
- # clojure-estonia (2)
- # clojure-europe (3)
- # clojure-finland (5)
- # clojure-india (2)
- # clojure-italy (49)
- # clojure-losangeles (1)
- # clojure-nl (12)
- # clojure-spec (120)
- # clojure-sweden (2)
- # clojure-switzerland (4)
- # clojure-uk (31)
- # clojurescript (80)
- # data-science (17)
- # datavis (2)
- # datomic (31)
- # emacs (31)
- # figwheel-main (28)
- # fulcro (6)
- # jobs (2)
- # liberator (7)
- # luminus (1)
- # nrepl (2)
- # off-topic (51)
- # overtone (2)
- # pathom (4)
- # re-frame (28)
- # reitit (1)
- # rum (6)
- # shadow-cljs (26)
- # specter (2)
- # tools-deps (33)
- # yada (3)
hi everyone. I’m trying to create a custom indentation in clojure mode, in my spacemacs. basically, I want to indent this
(rum/defc some-component
< rum/static
some/other-thing
[]
...)
like so
(rum/defc some-component
< rum/static
some/other-thing
[]
...)
can’t figure out how to. I keep fiddling with define-clojure-indent
, but I’m not entirely sure how it works
Not familiar with Rum. Could the following...
< rum/static
some/other-thing
hypothetically have this other syntax instead?
[< rum/static
some/other-thing]
Would that make sense?
If so, a version with delimiters would be easier to specify with define-clojure-indent
One doesn't specify delimiters, but forms.
[< rum/static
some/other-thing]
(with "delimiters") is 1 form, while
< rum/static
some/other-thing
is 3 forms, which makes clojure-mode's work harder
So my question is, would it make sense if Rum used []
syntax?ok it doesn't, but does it have those semantics?
I really don't know that <
means in your original snippet
oh its Rum’s syntax. basically you define a component like so
(rum/defc hello-world [] [:div "hi])
and then you can add so called macros to it with this syntax
(rum/defc hello-world < some-macro []
[:div "hi])
Is the following valid?
(rum/defc hello-world < some-macro another-macro awesome-macro cosmic-macro []
[:div "hi])
if not that, perhaps you’d know how I can indent reagent’s with-let
bindings. this is the code
(reagent/with-let [some-variable 1
other 2]
(do-something "Hello world"))
so for this to become
(reagent/with-let [some-variable 1
other 2]
(do-something "Hello world"))
(reagent/with-let [some-variable 1
other 2]
(do-something "Hello world"))
that one is easy, you just have to add "reagent/with-let"
to https://github.com/clojure-emacs/clojure-mode/blob/1ccef7b2b7a063aa42416d1518e8e7228d90a78d/clojure-mode.el#L1109
> yes it is 🙂
so, I advice to create your own defc
macro wrapper, which invokes the original but adds a []
syntax
(bravi/defc hello-world [< some-macro another-macro awesome-macro cosmic-macro []]
[:div "hi])
with that your original goal will become easierthis wouldn’t work, would it?
(defun clojurescript-indentations ()
(append clojure-align-binding-forms
'("reagent/with-let" "r/with-let")))
(add-hook 'clojurescript-mode-hook #'clojurescript-indentations)
it should work
you can also run (append clojure-align-binding-forms '("reagent/with-let" "r/with-let"))
in an elisp repl to ensure that the code has run
check that regular let
is being aligned too, obviously if regular let
isn't, others won't either
seems super neat to keep things organized and given who's the author I suspect it's probably quite cleanly done
I used it mainly from the suggestions of this thread https://sam217pa.github.io/2016/09/02/how-to-build-your-own-spacemacs/ it's used extensively in spacemacs and I used it to follow the guide on my way to my own config
also has the nice side-effect of speeding up Emacs startup 🙂 I don't happen to use it, but I'd say it wraps patterns that advanced Emacs users end up implementing themselves anyway.