@@ -589,38 +589,41 @@ 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- (defun cider-repl--apply- current-project-color (string )
592+ (defun cider-repl-highlight- current-project (string )
593593 " Fontify project's root namespace to make stacktraces more readable.
594594Foreground of `cider-stacktrace-ns-face' is used to propertize matched
595595namespaces. STRING is REPL's output."
596- (if cider-repl--root-ns-regexp
597- (let ((start 0 )
598- (end 0 ))
599- (while (setq start (string-match cider-repl--root-ns-regexp string end))
600- (setq end (match-end 0 ))
601- (let ((face-spec (list (cons 'foreground-color
602- (face-attribute 'cider-stacktrace-ns-face :foreground nil t )))))
603- (font-lock-prepend-text-property start end 'face face-spec string)))
604- string)
605- string))
596+ (cider-add-face cider-repl--root-ns-regexp 'cider-stacktrace-ns-face
597+ t nil string)
598+ string)
599+
600+ (defun cider-repl-add-locref-help-echo (string )
601+ " Set help-echo property of STRING to `cider-locref-help-echo' ."
602+ (put-text-property 0 (length string) 'help-echo 'cider-locref-help-echo string)
603+ string)
604+
605+ (defvar cider-repl-preoutput-hook '(ansi-color-apply
606+ cider-repl-highlight-current-project
607+ cider-repl-add-locref-help-echo)
608+ " Hook run on output string before it is inserted into the REPL buffer.
609+ Each functions takes a string and must return a modified string. Also see
610+ `cider-run-chained-hook' ." )
606611
607612(defun cider-repl--emit-output-at-pos (buffer string output-face position &optional bol )
608613 " Using BUFFER, insert STRING (applying to it OUTPUT-FACE) at POSITION.
609- If BOL is non-nil insert at the beginning of line."
614+ If BOL is non-nil insert at the beginning of line. Run
615+ `cider-repl-preoutput-hook' on STRING."
610616 (with-current-buffer buffer
611617 (save-excursion
612618 (cider-save-marker cider-repl-output-start
613619 (cider-save-marker cider-repl-output-end
614620 (goto-char position)
615621 ; ; TODO: Review the need for bol
616622 (when (and bol (not (bolp ))) (insert-before-markers " \n " ))
617- (setq string
618- (thread-first string
619- (propertize 'font-lock-face output-face
620- 'rear-nonsticky '(font-lock-face))
621- (ansi-color-apply )
622- (cider-repl--apply-current-project-color)
623- (propertize 'help-echo 'cider-locref-help-echo )))
623+ (setq string (propertize string
624+ 'font-lock-face output-face
625+ 'rear-nonsticky '(font-lock-face)))
626+ (setq string (cider-run-chained-hook 'cider-repl-preoutput-hook string))
624627 (insert-before-markers string)
625628 (cider-repl--flush-ansi-color-context)
626629 (when (and (= (point ) cider-repl-prompt-start-mark)
0 commit comments