I'd like to know if there is a way to define the indentation for a custom macro within the clojure source file. It is possible to define the indentation using clojure-mode, but as far as I can tell, it has to be done using elisp as described here.

Is there a way to do this from within a clojure source file? For example, in an elisp source file, one can do something like

(defmacro mac (arg)
  (declare (indent 1))

Does the combination of clojure and clojure-mode support something like this?

  • You might want to use a file-local variable to do this instead.
    – wasamasa
    Commented May 28, 2016 at 9:08
  • 2
    @wasamasa That would work for the file that the macros are defined in, but I'd also like it to work in other Clojure code that requires that file (like the above elisp code does) without having to explicitly set a file local variable each time.
    – Qudit
    Commented May 28, 2016 at 9:15
  • 1
    – wasamasa
    Commented May 28, 2016 at 12:51
  • Perfect! That does exactly what I'd hoped for.
    – Qudit
    Commented May 28, 2016 at 13:47

1 Answer 1


CIDER offers that functionality. Instead of using an extra declaration form, one puts the indentation info into the function's metadata:

(defmacro comment
  "Ignores body, yields nil"
  {:style/indent 1}
  [& body])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.