(back-indent-for-line tags line current-indent)
Returns the number of spaces the given line should be indented back.
Spec
(clojure.spec.alpha/fspec
:args
(clojure.spec.alpha/cat
:tags
:tag-soup.core/all-tags
:line
clojure.core/integer?
:current-indent
clojure.core/integer?)
:ret
clojure.core/integer?
:fn
nil)
Source
(defn back-indent-for-line
"Returns the number of spaces the given line should be indented back."
[tags line current-indent]
(let [tags-before (get-tags-before-line tags line)]
(loop [tags (reverse tags-before)
max-tab-stop current-indent]
(if-let [tag (first tags)]
(if-let [indent (:indent tag)]
(if (< indent max-tab-stop)
(if (:skip-indent? tag)
(recur (rest tags) (inc indent))
indent)
(recur (rest tags) max-tab-stop))
(recur (rest tags) max-tab-stop))
(- current-indent 2)))))