clojure-mode
clojure-mode copied to clipboard
How to define-clojure-indent on all keywords at once?
It looks like define-clojure-indent (and put-clojure-indent) only allow defining the indentation rules for individual symbols. I wish for all keywords to be indented like this:
(:keyword
map)
Unfortunately, there seems to be no way to do that except by listing every possible keyword explicitly:
(define-clojure-indent
(:import 0)
(:require 0)
... lots more ...
(:use 0))
The problems with that approach are obvious, I think.
Since this isn't a bug report, I don't think environment information will be helpful (although I install the latest versions of my Emacs packages from MELPA). I am happy to report such information if need be, though.
There's a variable for general indentation behaviour. See https://github.com/clojure-emacs/clojure-mode/blob/master/README.md#indentation-of-function-forms
It looks like what you want is to set it to always-indent.
However, the specific define-clojure-indent still take precedence over the generic variable, so you may still need to do the following for every symbol already defined in clojure-mode.el.
(define-clojure-indent
(:import nil))
I actually want clojure-indent-style to be set at :align-arguments. The problem is that keywords don't seem to be recognized as function forms—perhaps intentionally?
I also noticed this just today when someone complained on a PR of mine. The difference I believe @raxod502 is talking about can be seen where :align-arguments is configured, and (for example) this happens:
;; what I expect
(get
{:my-key "some value"} :my-key)
;; what I don't expect
(:my-key
{:my-key "some value"})
;; what I think it should do
(:my-key
{:my-key "some value"})
Is this behaviour intended?
Nope, we just didn't think of this scenario. PRs welcome!