spacemacs

Spacemacs docs: http://develop.spacemacs.org/doc/DOCUMENTATION.html http://develop.spacemacs.org/layers/+lang/clojure/README.html https://practicalli.github.io/spacemacs/
rberger 2020-09-17T19:31:08.059500Z

How do I customize my init.el so that it auto-indents the whole file only for clojure/clojurescript files? I tried:

(defun my--clojure-mode-hook ()
    (make-local-variable 'before-save-hook)
    (add-hook 'before-save-hook
              '(lambda ()
                 (clojure-indent-region (point-min) (point-max)))))
  (add-hook 'clojure-mode-hook 'my--clojure-mode-hook)
But it seems to indent files of all types

zane 2020-09-22T23:17:47.000100Z

Instead of trying to make before-save-hook local you could have your hook always run, but only indent if the current major mode is one of the Clojure major mode (`.clj`, .cljs, or .cljc).

rberger 2020-09-22T23:19:18.000300Z

Any suggestions on how to do that? I’m not an elisper so much

zane 2020-09-23T18:41:37.000800Z

So, perhaps something like this:

(add-hook 'before-save-hook
          '(lambda ()
             (when (derived-mode-p 'clojure-mode)
               (clojure-indent-region (point-min) (point-max)))

zane 2020-09-23T18:42:48.001300Z

Alternatively you could turn on aggressive-indent-mode for Clojure files only.

rberger 2020-10-05T22:29:44.030100Z

Thanks! Giving that a try. Seems to be working.

zane 2020-10-06T18:17:09.030300Z

Glad to hear it!

exit2 2020-09-17T20:34:01.061600Z

Hey all, I used to have this great re-mapping for slurp and barf that an old co-worker gave me but I can't for the life of me figure out how to get it back. I could do "slurp forwards" (`sp-forward-slurp-sexp` ) with shift + > and and "slurp backwards" with shift + <

exit2 2020-09-17T20:34:47.061900Z

any advice on how to achieve this again?

practicalli-john 2020-09-17T20:56:57.066100Z

@njustice I assume you don't want to use the built-in key bindings, SPC k s and SPC k S for those slurp commands. I prefer these over the more awkward custom key bindings I used to use. Edit the .spacemacs file and add one of the following to the dotspaceamcs/user-config section The global approach would be

(define-key global-map (kbd "S->") 'sp-forward-slurp-sexp)
For just Clojure mode, then
(define-key clojure-mode-map (kbd "S->") 'sp-forward-slurp-sexp)
These will over-ride any existing key bindings

exit2 2020-09-17T21:00:34.066400Z

Sweet let me give that a go