@@ -638,13 +638,17 @@ point) to check."
638
638
(replace-match (clojure-docstring-fill-prefix))))
639
639
(lisp-indent-line )))
640
640
641
- (defun clojure--symbol-get (function-name property )
641
+ (defun clojure--symbol-get (function-name )
642
642
" Return the symbol PROPERTY for the symbol named FUNCTION-NAME.
643
- FUNCTION-NAME is a string. If it contains a `/' , also try only the part after the `/' ."
644
- (or (get (intern-soft function-name) property)
645
- (and (string-match " /\\ ([^/]+\\ )\\ '" function-name)
646
- (get (intern-soft (match-string 1 function-name))
647
- property))))
643
+ FUNCTION-NAME is a string. If it contains a `/' , also try only
644
+ the part after the `/' ."
645
+ (or (get (intern-soft function-name) 'clojure-indent-function )
646
+ (get (intern-soft function-name) 'clojure-backtracking-indent )
647
+ (when (string-match " /\\ ([^/]+\\ )\\ '" function-name)
648
+ (or (get (intern-soft (match-string 1 function-name))
649
+ 'clojure-indent-function )
650
+ (get (intern-soft (match-string 1 function-name))
651
+ 'clojure-backtracking-indent )))))
648
652
649
653
(defun clojure-indent-function (indent-point state )
650
654
" When indenting a line within a function call, indent properly.
@@ -666,6 +670,7 @@ The property value can be
666
670
- a function to call just as this function was called.
667
671
If that function returns nil, that means it doesn't specify
668
672
the indentation.
673
+ - a list, which is used by `clojure-backtracking-indent' .
669
674
670
675
This function also returns nil meaning don't specify the indentation."
671
676
(let ((normal-indent (current-column )))
@@ -696,7 +701,7 @@ This function also returns nil meaning don't specify the indentation."
696
701
(progn (forward-sexp 1 ) (point ))))
697
702
(open-paren (elt state 1 ))
698
703
(forward-sexp-function #'clojure-forward-logical-sexp )
699
- (method (clojure--symbol-get function 'clojure-indent-function )))
704
+ (method (clojure--symbol-get function)))
700
705
; ; Maps, sets, vectors and reader conditionals.
701
706
(cond ((or (member (char-after open-paren) '(?\[ ?\{ ))
702
707
(ignore-errors
@@ -717,7 +722,7 @@ This function also returns nil meaning don't specify the indentation."
717
722
((integerp method)
718
723
(lisp-indent-specform method state
719
724
indent-point normal-indent))
720
- (method
725
+ (( functionp method)
721
726
(funcall method indent-point state))
722
727
(clojure-use-backtracking-indent
723
728
(clojure-backtracking-indent
@@ -737,7 +742,7 @@ move upwards in an sexp to check for contextual indenting."
737
742
(when (looking-at " \\ sw\\ |\\ s_" )
738
743
(let* ((start (point ))
739
744
(fn (buffer-substring start (progn (forward-sexp 1 ) (point ))))
740
- (meth (clojure--symbol-get fn 'clojure-backtracking-indent )))
745
+ (meth (clojure--symbol-get fn)))
741
746
(let ((n 0 ))
742
747
(when (< (point ) indent-point)
743
748
(condition-case ()
@@ -749,7 +754,8 @@ move upwards in an sexp to check for contextual indenting."
749
754
(forward-sexp 1 )))
750
755
(error nil )))
751
756
(push n path))
752
- (when meth
757
+ (when (and (listp meth)
758
+ (not (functionp meth)))
753
759
(let ((def meth))
754
760
(dolist (p path)
755
761
(if (and (listp def)
@@ -771,17 +777,17 @@ move upwards in an sexp to check for contextual indenting."
771
777
772
778
; ; clojure backtracking indent is experimental and the format for these
773
779
; ; entries are subject to change
774
- (put 'implement 'clojure-backtracking- indent '(4 (2 )))
775
- (put 'letfn 'clojure-backtracking- indent '((2 ) 2 ))
776
- (put 'proxy 'clojure-backtracking- indent '(4 4 (2 )))
777
- (put 'reify 'clojure-backtracking- indent '((2 )))
778
- (put 'deftype 'clojure-backtracking- indent '(4 4 (2 )))
779
- (put 'defrecord 'clojure-backtracking- indent '(4 4 (2 )))
780
- (put 'defprotocol 'clojure-backtracking- indent '(4 (2 )))
781
- (put 'extend-type 'clojure-backtracking- indent '(4 (2 )))
782
- (put 'extend-protocol 'clojure-backtracking- indent '(4 (2 )))
783
- (put 'specify 'clojure-backtracking- indent '(4 (2 )))
784
- (put 'specify! 'clojure-backtracking- indent '(4 (2 )))
780
+ (put 'implement 'clojure-indent-function '(4 (2 )))
781
+ (put 'letfn 'clojure-indent-function '((2 ) 2 ))
782
+ (put 'proxy 'clojure-indent-function '(4 4 (2 )))
783
+ (put 'reify 'clojure-indent-function '((2 )))
784
+ (put 'deftype 'clojure-indent-function '(4 4 (2 )))
785
+ (put 'defrecord 'clojure-indent-function '(4 4 (2 )))
786
+ (put 'defprotocol 'clojure-indent-function '(4 (2 )))
787
+ (put 'extend-type 'clojure-indent-function '(4 (2 )))
788
+ (put 'extend-protocol 'clojure-indent-function '(4 (2 )))
789
+ (put 'specify 'clojure-indent-function '(4 (2 )))
790
+ (put 'specify! 'clojure-indent-function '(4 (2 )))
785
791
786
792
(defun put-clojure-indent (sym indent )
787
793
" Instruct `clojure-indent-function' to indent the body of SYM by INDENT."
0 commit comments