Subject: bug#61104: 29.0.60; typescript-ts-mode does not provide compilation-mode support

From: Jostein Kjønigsen <[email-masked]>
Date: Sat, 28 Jan 2023 15:28:04 +0100

On 1/28/23 08:23, Eli Zaretskii wrote:
>
> I don't think doing this in the major-mode file will improve locality,
> because we have compilation-minor-mode, which should be able to do its
> thing even if the relevant major mode is not yet loaded.
Fair enough!
>
>> - adding it in compile.el, to improve ability to oversee all
>> expressions, and be able to optimize those?
>>
>> I see csharp-mode.el has the expressions added directly there. Should I
>> go about preparing patches doing
>> the same for typescript-ts-mode too?
> I don't see why not.

Ok. Attached is a patch which adds Typescript tsc-support to compile.el. 
Is this OK to install in emacs-29?

I also see in retrospect that my comment about csharp-mode above may 
been somewhat ambiguous and easy to misunderstand (and seemingly you did).

To be clear: csharp-mode includes the compilation-mode regexps in the 
major-mode, not in compile.el. Is this also something we should aim to 
fix for emacs-29, or should we leave that for master?

--
Jostein
From b60c0686fc925290ff201ed79399e48ebc47d6d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= <[email-masked]>
Date: Sat, 28 Jan 2023 15:23:11 +0100
Subject: [PATCH] Add support for Typescript compilation to compilation-mode

---
 lisp/progmodes/compile.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 5758eadf996..1e57d0b7bb2 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -649,6 +649,24 @@ compilation-error-regexp-alist-alist
     ;; we do not know what lines will follow.
     (guile-file "^In \\(.+\\..+\\):\n" 1 nil nil 0)
     (guile-line "^ *\\([0-9]+\\): *\\([0-9]+\\)" nil 1 2)
+
+    ;; Typescript compilation prior to tsc version 2.7, "plain" format:
+    ;; greeter.ts(30,12): error TS2339: Property 'foo' does not exist.
+    (typescript-tsc-plain
+     ,(concat
+      "^[[:blank:]]*"
+      "\\([^(\r\n)]+\\)(\\([0-9]+\\),\\([0-9]+\\)):[[:blank:]]+"
+      "error [[:alnum:]]+: [^\r\n]+$")
+     1 2 3 2)
+
+    ;; Typescript compilation after tsc version 2.7, "pretty" format:
+    ;; src/resources/document.ts:140:22 - error TS2362: something.
+    (typescript-tsc-pretty
+     ,(concat
+       "^[[:blank:]]*"
+       "\\([^(\r\n)]+\\):\\([0-9]+\\):\\([0-9]+\\) - [[:blank:]]*"
+       "error [[:alnum:]]+: [^\r\n]+$")
+     1 2 3 2)
     ))
   "Alist of values for `compilation-error-regexp-alist'.")
 
-- 
2.39.1