Skip to content

Commit 262151b

Browse files
committed
[Fix #362] Define a custom option clojure-indent-style
1 parent 59decee commit 262151b

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

clojure-mode.el

+48-5
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,54 @@
9595
"Face used to font-lock interop method names (camelCase)."
9696
:package-version '(clojure-mode . "3.0.0"))
9797

98-
(defcustom clojure-defun-style-default-indent nil
99-
"When non-nil, use default indenting for functions and macros.
100-
Otherwise check `define-clojure-indent' and `put-clojure-indent'."
101-
:type 'boolean
102-
:safe 'booleanp)
98+
(defcustom clojure-indent-style :lisp
99+
"Indentation style to use for function forms and macro forms.
100+
There are two cases of interest configured by this variable.
101+
Case (A) is when at least one function argument is on the same
102+
line as the function name. Case (B) is the opposite (no arguments
103+
are on the same line as the function name). Note that the body of
104+
macros is not affected by this variable, it is always indented by
105+
`lisp-body-indent' (default 2) spaces.
106+
107+
Note that this variable configures the indentation of function
108+
forms (and function-like macros), it does not affect macros that
109+
already use special indentation rules.
110+
111+
The possible values for this variable are keywords indicating how
112+
to indent function forms.
113+
114+
`:lisp' - Follow the same rules as `lisp-mode'. All args are
115+
vertically aligned with the first arg in case (A), and
116+
vertically aligned with the function name in case (B). For
117+
instance:
118+
(reduce merge
119+
some-coll)
120+
(reduce
121+
merge
122+
some-coll)
123+
124+
`:always-body' - All args are indented like a macro body.
125+
(reduce merge
126+
some-coll)
127+
(reduce
128+
merge
129+
some-coll)
130+
131+
`:body-unless-same-line' - Case (A) is indented like `lisp',
132+
and case (B) is indented like a macro body.
133+
(reduce merge
134+
some-coll)
135+
(reduce
136+
merge
137+
some-coll)"
138+
:type '(choice (const :tag "Same as `lisp-mode'" lisp)
139+
(const :tag "Indent like a macro body" always-body)
140+
(const :tag "Indent like a macro body unless first arg is on the same line"
141+
body-unless-same-line))
142+
:package-version '(clojure-mode . "5.2.0"))
143+
144+
(define-obsolete-variable-alias 'clojure-defun-style-default-indent
145+
'clojure-indent-style "5.2.0")
103146

104147
(defcustom clojure-use-backtracking-indent t
105148
"When non-nil, enable context sensitive indentation."

0 commit comments

Comments
 (0)