Skip to content

Commit 53d11c8

Browse files
committed
Add clojure-get-indent-spec public API
Returns the modern-format indent spec for a symbol. If only a legacy-format spec exists, it is converted automatically. This provides a clean API for tools that want to inspect indent specs in the modern format.
1 parent feb2e5b commit 53d11c8

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

clojure-mode.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,18 @@ Examples:
21022102
(clojure--indent-spec-to-legacy indent)
21032103
indent)))
21042104

2105+
(defun clojure-get-indent-spec (sym)
2106+
"Return the modern-format indent spec for the symbol SYM.
2107+
SYM is a symbol or a string. Returns nil if no spec is found.
2108+
2109+
If only a legacy-format spec exists, it is converted to modern format."
2110+
(let* ((sym-name (if (stringp sym) sym (symbol-name sym)))
2111+
(sym-obj (intern-soft sym-name)))
2112+
(or (and sym-obj (get sym-obj 'clojure-indent-spec))
2113+
(let ((legacy (and sym-obj (get sym-obj 'clojure-indent-function))))
2114+
(when (and legacy (not (functionp legacy)))
2115+
(clojure--indent-spec-to-modern legacy))))))
2116+
21052117
(defun clojure--maybe-quoted-symbol-p (x)
21062118
"Check that X is either a symbol or a quoted symbol like :foo or \\='foo."
21072119
(or (symbolp x)

0 commit comments

Comments
 (0)