aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/compile.el13
-rw-r--r--test/lisp/progmodes/compile-tests.el27
2 files changed, 35 insertions, 5 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index e4363e11b81..02d1c588589 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1248,11 +1248,14 @@ POS and RES.")
1248 (setq col (match-string-no-properties col)) 1248 (setq col (match-string-no-properties col))
1249 (string-to-number col)))) 1249 (string-to-number col))))
1250 (setq end-col 1250 (setq end-col
1251 (or (if (functionp end-col) (funcall end-col) 1251 (let ((ec (if (functionp end-col)
1252 (and end-col 1252 (funcall end-col)
1253 (setq end-col (match-string-no-properties end-col)) 1253 (and end-col (match-beginning end-col)
1254 (- (string-to-number end-col) -1))) 1254 (string-to-number
1255 (and end-line -1))) 1255 (match-string-no-properties end-col))))))
1256 (if ec
1257 (1+ ec) ; Add one to get an exclusive upper bound.
1258 (and end-line -1))))
1256 (if (consp type) ; not a static type, check what it is. 1259 (if (consp type) ; not a static type, check what it is.
1257 (setq type (or (and (car type) (match-end (car type)) 1) 1260 (setq type (or (and (car type) (match-end (car type)) 1)
1258 (and (cdr type) (match-end (cdr type)) 0) 1261 (and (cdr type) (match-end (cdr type)) 0)
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index 0623cec5285..2a3bb3dafae 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -515,4 +515,31 @@ The test data is in `compile-tests--grep-regexp-testcases'."
515 (compile--test-error-line testcase)) 515 (compile--test-error-line testcase))
516 (should (eq compilation-num-errors-found 8)))) 516 (should (eq compilation-num-errors-found 8))))
517 517
518(ert-deftest compile-test-functions ()
519 "Test rules using functions instead of regexp group numbers."
520 (let* ((file-fun (lambda () '("my-file")))
521 (line-start-fun (lambda () 123))
522 (line-end-fun (lambda () 134))
523 (col-start-fun (lambda () 39))
524 (col-end-fun (lambda () 24))
525 (compilation-error-regexp-alist-alist
526 `((my-rule
527 ,(rx bol "My error message")
528 ,file-fun
529 (,line-start-fun . ,line-end-fun)
530 (,col-start-fun . ,col-end-fun))))
531 (compilation-error-regexp-alist '(my-rule)))
532 (with-temp-buffer
533 (font-lock-mode -1)
534 (let ((compilation-num-errors-found 0)
535 (compilation-num-warnings-found 0)
536 (compilation-num-infos-found 0))
537 (compile--test-error-line
538 '(my-rule
539 "My error message"
540 1 (39 . 24) (123 . 134) "my-file" 2))
541 (should (eq compilation-num-errors-found 1))
542 (should (eq compilation-num-warnings-found 0))
543 (should (eq compilation-num-infos-found 0))))))
544
518;;; compile-tests.el ends here 545;;; compile-tests.el ends here