@@ -911,6 +911,31 @@ any number of matches of `clojure--sym-forbidden-rest-chars'.")
911911Matches the rule `clojure--keyword-sym-forbidden-1st-chars' followed by
912912any number of matches of `clojure--sym-forbidden-rest-chars' ." ))
913913
914+ (defun clojure--search-letfn-name (limit )
915+ " Search for function names in letfn bindings up to LIMIT.
916+ This is a font-lock MATCHER function that finds each binding name
917+ in a `letfn' binding vector. For each `(symbol' match, it checks
918+ whether the paren is a direct child of a letfn binding vector."
919+ (let ((binding-re (concat " (\\ (" clojure--sym-regexp " \\ )" ))
920+ found)
921+ (while (and (not found)
922+ (re-search-forward binding-re limit t ))
923+ ; ; `save-match-data' is critical: the verification below uses
924+ ; ; `looking-back' which would overwrite the match data from
925+ ; ; `re-search-forward' that font-lock needs for the highlight.
926+ (save-match-data
927+ (let ((paren-pos (match-beginning 0 )))
928+ (save-excursion
929+ (goto-char paren-pos)
930+ (when (ignore-errors (backward-up-list ) t )
931+ (when (eq (char-after ) ?\[ )
932+ (skip-chars-backward " \t\n\r " )
933+ (when (looking-back
934+ " (\\ (?:clojure\\ .core/\\ )?letfn"
935+ (- (point ) 25 ))
936+ (setq found t ))))))))
937+ found))
938+
914939(defconst clojure-font-lock-keywords
915940 (eval-when-compile
916941 `(; ; Any def form
@@ -993,6 +1018,9 @@ any number of matches of `clojure--sym-forbidden-rest-chars'."))
9931018 ; ; Possibly name
9941019 " \\ (\\ sw+\\ )?" )
9951020 (2 font-lock-function-name-face nil t ))
1021+ ; ; Function names in letfn bindings
1022+ (clojure--search-letfn-name
1023+ (1 font-lock-function-name-face ))
9961024 ; ; Special forms
9971025 (,(concat
9981026 " ("
0 commit comments