Fork me on GitHub
#emacs
<
2023-01-29
>
Clojuri0an12:01:29

I would like to define both my clojurescript mode hooks and my clojure mode hooks in one go, as follows

Clojuri0an12:01:34

(add-hook 'clojurescript-mode-hook 'clojure-mode-hook #'paredit-mode)

Zed13:01:11

Just add paredit-mode to clojure-mode-hook. Since clojurescript-mode is derived from clojure-mode, it will inherit everything you add to clojure-mode-hook.

Clojuri0an12:01:39

however this does not work. how to do this?

hifumi12313:01:42

I thought .cljs files already handled by clojure-mode. So one hook should suffice. I assume #’paredit-mode toggles paredit, so adding it to two modes then loading both modes will in effect leave paredit disabled. NOTE: This is just a guess. Someone please correct if I’m wrong

Clojuri0an17:01:27

I am confused. Starting shadow-cljs with cider gives me a stale shadow-cljs warning, telling me that it was not built by this server, and asking me if the watch flag is running

Clojuri0an17:01:34

I am in the correct repl

Clojuri0an17:01:38

cljs.user> (shadow.cljs.devtools.api/watch :frontend)
No available JS runtime.
See 

Clojuri0an17:01:34

Runs fine from command line

Clojuri0an17:01:32

I have selected the correct build

borkdude18:01:06

Can someone explain to me how formatting works in emacs when you have no custom formatter installed and are just using clojure-mode?

borkdude18:01:27

Is there any custom clojure formatting going on, or is it using the same formatting as elisp?

borkdude18:01:41

I'm asking for @U7ERLH6JX since he wants to have the same formatting as I have.

borkdude18:01:20

I'm also fine with going with cljfmt and having lsp-format-buffer do this for me, but I'm not sure if cljfmt is broadly supported in other editors?

ericdallo19:01:25

clojure-mode uses clojure-indent-region setting indent-region-functions

practicalli-johnny20:01:36

I use these settings for CIDER

(setq clojure-indent-style 'align-arguments
        clojure-align-forms-automatically t
        clojure-toplevel-inside-comment-form t  ;; evaluate expressions in comment as top level
        )
And cljfmt seems to do everything else (although I usually run formatting through cljstyle before committing- using this https://github.com/practicalli/clojure-deps-edn/blob/live/.cljstyle

borkdude21:01:15

I was looking through the source and was searching for format but indent makes more sense and comes up with lots more elisp - makes sense now

iarenaza16:01:03

Just to pile on, I have this bit of elisp in my config for Compojure. As clojure-mode and clj-fmt have different ideas on how to indent them (I use clojure-mode to indent while developing, but our CI/CD pipeline uses clj-fmt in strict mode 😅 )

;; Indentation rules for Compojure Macros (they are a bit special)
;; From 
;; using the syntax defined in 
(define-clojure-indent
  (ANY 2)
  (DELETE 2)
  (GET 2)
  (HEAD 2)
  (OPTIONS 0)
  (PATCH 2)
  (POST 2)
  (PUT 2)
  (context 2)
  (defroutes 0)
  (let-routes 1)
  (rfn 0))