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 :always-align
99+ " Indentation style to use for function forms and macro forms.
100+ There are two cases of interest configured by this variable.
101+
102+ - Case (A) is when at least one function argument is on the same
103+ line as the function name.
104+ - Case (B) is the opposite (no arguments are on the same line as
105+ the function name). Note that the body of macros is not
106+ affected by this variable, it is always indented by
107+ `lisp-body-indent' (default 2) spaces.
108+
109+ Note that this variable configures the indentation of function
110+ forms (and function-like macros), it does not affect macros that
111+ already use special indentation rules.
112+
113+ The possible values for this variable are keywords indicating how
114+ to indent function forms.
115+
116+ `:always-align' - Follow the same rules as `lisp-mode' . All
117+ args are vertically aligned with the first arg in case (A),
118+ and vertically aligned with the function name in case (B).
119+ For instance:
120+ (reduce merge
121+ some-coll)
122+ (reduce
123+ merge
124+ some-coll)
125+
126+ `:always-indent' - All args are indented like a macro body.
127+ (reduce merge
128+ some-coll)
129+ (reduce
130+ merge
131+ some-coll)
132+
133+ `:align-arguments' - Case (A) is indented like `lisp' , and
134+ case (B) is indented like a macro body.
135+ (reduce merge
136+ some-coll)
137+ (reduce
138+ merge
139+ some-coll)"
140+ :type '(choice (const :tag " Same as `lisp-mode' " lisp)
141+ (const :tag " Indent like a macro body" always-body)
142+ (const :tag " Indent like a macro body unless first arg is on the same line"
143+ body-unless-same-line))
144+ :package-version '(clojure-mode . " 5.2.0" ))
145+
146+ (define-obsolete-variable-alias 'clojure-defun-style-default-indent
147+ 'clojure-indent-style " 5.2.0" )
103148
104149(defcustom clojure-use-backtracking-indent t
105150 " When non-nil, enable context sensitive indentation."
@@ -954,7 +999,7 @@ spec."
954999 " Return the normal indentation column for a sexp.
9551000Point should be after the open paren of the _enclosing_ sexp, and
9561001LAST-SEXP is the start of the previous sexp (immediately before
957- the sexp being indented). INDENT-MODE is any of the values
1002+ the sexp being indented). INDENT-MODE is any of the values
9581003accepted by `clojure-indent-style' ."
9591004 (goto-char last-sexp)
9601005 (forward-sexp 1 )
@@ -981,13 +1026,13 @@ accepted by `clojure-indent-style'."
9811026 (cond
9821027 ; ; For compatibility with the old `clojure-defun-style-default-indent' , any
9831028 ; ; value other than these 3 is equivalent to `always-body' .
984- ((not (memq indent-mode '(:lisp :body-unless-same-line nil )))
1029+ ((not (memq indent-mode '(:always-align :align-arguments nil )))
9851030 (+ (current-column ) lisp-body-indent -1 ))
9861031 ; ; There's an arg after the function name, so align with it.
9871032 (case-a (goto-char last-sexp-start)
9881033 (current-column ))
9891034 ; ; Not same line.
990- ((eq indent-mode :body-unless-same-line )
1035+ ((eq indent-mode :align-arguments )
9911036 (+ (current-column ) lisp-body-indent -1 ))
9921037 ; ; Finally, just align with the function name.
9931038 (t (current-column )))))))
@@ -1059,7 +1104,7 @@ This function also returns nil meaning don't specify the indentation."
10591104 (+ lisp-body-indent containing-form-column))
10601105 ; ; Further non-special args, align with the arg above.
10611106 ((> pos (1+ method))
1062- (clojure--normal-indent last-sexp :lisp ))
1107+ (clojure--normal-indent last-sexp :always-align ))
10631108 ; ; Special arg. Rigidly indent with a large indentation.
10641109 (t
10651110 (+ (* 2 lisp-body-indent) containing-form-column)))))
@@ -1071,9 +1116,9 @@ This function also returns nil meaning don't specify the indentation."
10711116 (`nil
10721117 (let ((function (thing-at-point 'symbol )))
10731118 (cond
1074- ; ; largely to preserve useful alignment of :require, etc in ns
1119+ ; ; Preserve useful alignment of :require (and friends) in `ns' forms.
10751120 ((and function (string-match " ^:" function))
1076- (clojure--normal-indent last-sexp :body-unless-same-line ))
1121+ (clojure--normal-indent last-sexp :align-arguments ))
10771122 ; ; This is should be identical to the :defn above.
10781123 ((and function
10791124 (string-match " \\ `\\ (?:\\ S +/\\ )?\\ (def[a-z]*\\ |with-\\ )"
@@ -1082,9 +1127,7 @@ This function also returns nil meaning don't specify the indentation."
10821127 (+ lisp-body-indent containing-form-column))
10831128 ; ; Finally, nothing special here, just respect the user's
10841129 ; ; preference.
1085- (t (clojure--normal-indent last-sexp (if clojure-defun-style-default-indent
1086- :always-body
1087- :lisp ))))))))))
1130+ (t (clojure--normal-indent last-sexp clojure-indent-style)))))))))
10881131
10891132; ;; Setting indentation
10901133(defun put-clojure-indent (sym indent )
0 commit comments