@@ -73,18 +73,22 @@ NTH defaults to 1."
7373(defun clojure-test--check-faces (content face-specs )
7474 " Fontify CONTENT and check all FACE-SPECS.
7575Each spec is either (START END FACE) for positional checks or
76- \( SUBSTRING FACE) or (SUBSTRING FACE :nth N) for substring-based checks."
76+ \( SUBSTRING FACE) for substring-based checks.
77+
78+ Substring specs are matched sequentially through the buffer so
79+ that repeated substrings resolve naturally in document order
80+ without any special annotation."
7781 (with-fontified-clojure-buffer content
7882 (dolist (spec face-specs)
7983 (pcase spec
80- (`(,(and (pred stringp) substr) , face . , rest )
81- (let ((nth ( or ( plist-get rest :nth ) 1 )))
82- (goto-char ( point-min ) )
83- (dotimes (_ nth )
84- (search-forward substr ))
85- ( let* ((end ( 1 - (point )))
86- (start ( - ( point ) ( length substr))) )
87- (expect (clojure-test--uniform-face start end) :to-equal face))))
84+ (`(,(and (pred stringp) substr) , face )
85+ (let ((found ( search-forward substr nil t )))
86+ (expect found :not :to-be nil )
87+ (when found
88+ (let* ((end ( 1- ( point ) ))
89+ (start ( - (point ) ( length substr) )))
90+ (expect (clojure-test--uniform-face start end )
91+ :to-equal face) ))))
8892 (`(,(and (pred numberp) start) , end , face )
8993 (expect (clojure-test--uniform-face start end) :to-equal face))))))
9094
@@ -101,8 +105,9 @@ its index.")
101105 " Return a buttercup spec.
102106
103107TESTS are lists of the form (content face-spec*) where each face-spec is either
104- \( start end expected-face) for positional checks or (substring expected-face) or
105- \( substring expected-face :nth N) for substring-based checks.
108+ \( start end expected-face) for positional checks or (substring expected-face)
109+ for substring-based checks. Substring specs are matched sequentially
110+ through the buffer so repeated substrings resolve in document order.
106111
107112DESCRIPTION is the description of the spec."
108113 (declare (indent 1 ))
@@ -269,7 +274,7 @@ DESCRIPTION is the description of the spec."
269274 (" (oneword/oneword)"
270275 (" oneword" font-lock-type-face )
271276 (" /" nil )
272- (" oneword" nil :nth 2 ))
277+ (" oneword" nil ))
273278
274279 (" (oneword/seg.mnt)"
275280 (" oneword" font-lock-type-face )
@@ -330,7 +335,7 @@ DESCRIPTION is the description of the spec."
330335 (" (seg.mnt/seg.mnt)"
331336 (" seg.mnt" font-lock-type-face )
332337 (" /" nil )
333- (" seg.mnt" nil :nth 2 ))
338+ (" seg.mnt" nil ))
334339
335340 (" (seg.mnt/mxdCase)"
336341 (" seg.mnt" font-lock-type-face )
@@ -389,7 +394,7 @@ DESCRIPTION is the description of the spec."
389394 (" (CmlCase/CmlCase)"
390395 (" CmlCase" font-lock-type-face )
391396 (" /" nil )
392- (" CmlCase" nil :nth 2 ))
397+ (" CmlCase" nil ))
393398
394399 (" (CmlCase/ve/yCom|pLex.stu-ff)"
395400 (" CmlCase" font-lock-type-face )
@@ -433,7 +438,7 @@ DESCRIPTION is the description of the spec."
433438 (" (mxdCase/mxdCase)"
434439 (" mxdCase" font-lock-type-face )
435440 (" /" nil )
436- (" mxdCase" nil :nth 2 ))
441+ (" mxdCase" nil ))
437442
438443 (" (mxdCase/CmlCase)"
439444 (" mxdCase" font-lock-type-face )
@@ -538,7 +543,7 @@ DESCRIPTION is the description of the spec."
538543 (" {:oneword/oneword 0}"
539544 (" oneword" font-lock-type-face )
540545 (" /" default )
541- (" oneword" clojure-keyword-face :nth 2 ))
546+ (" oneword" clojure-keyword-face))
542547
543548 (" {:oneword/seg.mnt 0}"
544549 (" oneword" font-lock-type-face )
@@ -638,7 +643,7 @@ DESCRIPTION is the description of the spec."
638643 (" {:seg.mnt/seg.mnt 0}"
639644 (" seg.mnt" font-lock-type-face )
640645 (" /" default )
641- (" seg.mnt" clojure-keyword-face :nth 2 ))
646+ (" seg.mnt" clojure-keyword-face))
642647
643648 (" {:seg.mnt/CmlCase 0}"
644649 (" seg.mnt" font-lock-type-face )
@@ -686,7 +691,7 @@ DESCRIPTION is the description of the spec."
686691 (" {:CmlCase/CmlCase 0}"
687692 (" CmlCase" font-lock-type-face )
688693 (" /" default )
689- (" CmlCase" clojure-keyword-face :nth 2 ))
694+ (" CmlCase" clojure-keyword-face))
690695
691696 (" {:CmlCase/mxdCase 0}"
692697 (" CmlCase" font-lock-type-face )
@@ -734,7 +739,7 @@ DESCRIPTION is the description of the spec."
734739 (" {:mxdCase/mxdCase 0}"
735740 (" mxdCase" font-lock-type-face )
736741 (" /" default )
737- (" mxdCase" clojure-keyword-face :nth 2 ))
742+ (" mxdCase" clojure-keyword-face))
738743
739744 (" {:mxdCase/ve/yCom|pLex.stu-ff 0}"
740745 (" mxdCase" font-lock-type-face )
0 commit comments