Skip to content

Commit dbd0a98

Browse files
committed
Highlight filenames in compilation buffer
#195
1 parent b79f054 commit dbd0a98

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

swift-mode-repl.el

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
(require 'subr-x)
3737
(require 'wid-edit)
3838
(require 'compile)
39+
(require 'rx)
3940

4041
;;;###autoload
4142
(defgroup swift-mode:repl nil
@@ -1057,6 +1058,25 @@ If FILE doesn't exist in the project, return nil."
10571058
swift-mode:compilation-swift-files)))
10581059
(and path (list path)))))
10591060

1061+
(defun swift-mode:resolve-and-highlight-swift-test-file ()
1062+
"Call `swift-mode:resolve-swift-test-file' on match and highlight if needed.
1063+
1064+
When a function is specified as the `file' component of
1065+
`compilation-error-regexp-alist-alist', `compile' does not highlight the
1066+
matching filename. So we have to highlight it here."
1067+
(save-match-data
1068+
(let ((start (match-beginning 2))
1069+
(end (match-end 2))
1070+
(result (funcall swift-mode:resolve-swift-test-file-function
1071+
(match-string 2))))
1072+
(when result
1073+
(put-text-property
1074+
start
1075+
end
1076+
'font-lock-face
1077+
compilation-error-face))
1078+
result)))
1079+
10601080
(defun swift-mode:setup-swift-testing ()
10611081
"Setup `compilation-process-setup-function' for Swift Testing.
10621082
@@ -1083,10 +1103,7 @@ Also add an entry to `compilation-error-regexp-alist-alist'."
10831103
(group (+ digit))))
10841104
": ")
10851105
;; filename
1086-
,(lambda ()
1087-
(save-match-data
1088-
(funcall swift-mode:resolve-swift-test-file-function
1089-
(match-string 2))))
1106+
,#'swift-mode:resolve-and-highlight-swift-test-file
10901107
;; line
10911108
3
10921109
;; column

0 commit comments

Comments
 (0)