@@ -550,7 +550,18 @@ When there is a possible unfinished ansi control sequence,
550
550
(insert-before-markers (cadr ansi-color-context))
551
551
(setq ansi-color-context nil )))
552
552
553
- (defvar cider-repl--root-ns-highlitht-template " \\ <\\ (%s\\ )[^$/: \t\n ]+"
553
+ (defvar-local cider-repl--ns-forms-plist nil
554
+ " Plist holding ns->ns-form mappings within each connection." )
555
+
556
+ (defun cider-repl--ns-form-changed-p (ns-form connection )
557
+ " Return non-nil if NS-FORM for CONNECTION changed since last eval."
558
+ (when-let ((ns (cider-ns-from-form ns-form)))
559
+ (not (string= ns-form
560
+ (lax-plist-get
561
+ (buffer-local-value 'cider-repl--ns-forms-plist connection)
562
+ ns)))))
563
+
564
+ (defvar cider-repl--root-ns-highlight-template " \\ <\\ (%s\\ )[^$/: \t\n ]+"
554
565
" Regexp used to highlight root ns in REPL buffers." )
555
566
556
567
(defvar-local cider-repl--root-ns-regexp nil
@@ -559,19 +570,24 @@ When there is a possible unfinished ansi control sequence,
559
570
(defvar-local cider-repl--ns-roots nil
560
571
" List holding all past root namespaces seen during interactive eval." )
561
572
562
- (defun cider-repl--cache-ns-roots (ns-form connection )
573
+ (defun cider-repl--cache-ns-form (ns-form connection )
563
574
" Given NS-FORM cache root ns in CONNECTION."
564
575
(with-current-buffer connection
565
- (when (string-match " ^[ \t\n ]*\( ns[ \t\n ]+\\ ([^. \t\n ]+\\ )" ns-form)
566
- (let ((root (match-string-no-properties 1 ns-form)))
567
- (unless (member root cider-repl--ns-roots)
568
- (push root cider-repl--ns-roots)
569
- (let ((roots (mapconcat
570
- ; ; Replace _ or - with regexp patter to accommodate "raw" namespaces
571
- (lambda (r ) (replace-regexp-in-string " [_-]+" " [_-]+" r))
572
- cider-repl--ns-roots " \\ |" )))
573
- (setq cider-repl--root-ns-regexp
574
- (format cider-repl--root-ns-highlitht-template roots))))))))
576
+ (when-let ((ns (cider-ns-from-form ns-form)))
577
+ ; ; cache ns-form
578
+ (setq cider-repl--ns-forms-plist
579
+ (lax-plist-put cider-repl--ns-forms-plist ns ns-form))
580
+ ; ; cache ns roots regexp
581
+ (when (string-match " \\ ([^.]+\\ )" ns)
582
+ (let ((root (match-string-no-properties 1 ns)))
583
+ (unless (member root cider-repl--ns-roots)
584
+ (push root cider-repl--ns-roots)
585
+ (let ((roots (mapconcat
586
+ ; ; Replace _ or - with regexp patter to accommodate "raw" namespaces
587
+ (lambda (r ) (replace-regexp-in-string " [_-]+" " [_-]+" r))
588
+ cider-repl--ns-roots " \\ |" )))
589
+ (setq cider-repl--root-ns-regexp
590
+ (format cider-repl--root-ns-highlight-template roots)))))))))
575
591
576
592
(defun cider-repl--apply-current-project-color (string )
577
593
" Fontify project's root namespace to make stacktraces more readable.
0 commit comments