Skip to content

Commit 87ccc00

Browse files
vspinubbatsov
authored andcommitted
Add cider-repl-highlight-spec-keywords pre-output processor
1 parent 768178e commit 87ccc00

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cider-repl.el

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,25 @@ When there is a possible unfinished ansi control sequence,
589589
(setq cider-repl--root-ns-regexp
590590
(format cider-repl--root-ns-highlight-template roots)))))))))
591591

592+
(defvar cider-repl-spec-keywords-regexp
593+
(concat
594+
(regexp-opt '("In:" " val:"
595+
" at:" "fails at:"
596+
" spec:" "fails spec:"
597+
" predicate:" "fails predicate:"))
598+
"\\|^"
599+
(regexp-opt '(":clojure.spec.alpha/spec"
600+
":clojure.spec.alpha/value")
601+
"\\("))
602+
"Regexp matching clojure.spec `explain` keywords.")
603+
604+
(defun cider-repl-highlight-spec-keywords (string)
605+
"Highlight clojure.spec `explain` keywords in STRING.
606+
Foreground of `clojure-keyword-face' is used for highlight."
607+
(cider-add-face cider-repl-spec-keywords-regexp
608+
'clojure-keyword-face t nil string)
609+
string)
610+
592611
(defun cider-repl-highlight-current-project (string)
593612
"Fontify project's root namespace to make stacktraces more readable.
594613
Foreground of `cider-stacktrace-ns-face' is used to propertize matched
@@ -604,6 +623,7 @@ namespaces. STRING is REPL's output."
604623

605624
(defvar cider-repl-preoutput-hook '(ansi-color-apply
606625
cider-repl-highlight-current-project
626+
cider-repl-highlight-spec-keywords
607627
cider-repl-add-locref-help-echo)
608628
"Hook run on output string before it is inserted into the REPL buffer.
609629
Each functions takes a string and must return a modified string. Also see

0 commit comments

Comments
 (0)