unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: jostein@kjonigsen.net
Cc: casouri@gmail.com, 61104@debbugs.gnu.org,
	Theodor Thornhill <theo@thornhill.no>,
	Eli Zaretskii <eliz@gnu.org>
Subject: bug#61104: 29.0.60; typescript-ts-mode does not provide compilation-mode support
Date: Mon, 6 Feb 2023 12:19:32 +0100	[thread overview]
Message-ID: <2F86FB50-87F7-432D-B87A-1738056907AB@gmail.com> (raw)
In-Reply-To: <12a97d26-90cc-4a25-61a5-5aff33915610@secure.kjonigsen.net>

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

5 feb. 2023 kl. 21.36 skrev Jostein Kjønigsen <jostein@secure.kjonigsen.net>:

> Attached is a patch which codifies all these changes, and from what I can tell, still does the job. You make take it as is, or you may further work on it, if you think that is still needed.

Thank you! I translated the regexps to rx (which I personally find more maintainable and has plenty of precedence in this context) and tightened them up further. They are now anchored at beginning-of-line again, and file names cannot start with whitespace (for disambiguation and speed).

I also removed the part that matches the actual message text since it isn't needed, and it would highlight (with an underline in the standard theme) the whole text which is a bit ungainly to read. If the message is multi-line, which earlier examples in this discussions indicated might be the case, then only the first would be highlighted this way which wasn't ideal either.

Patch attached, please tell me what you think.

Does tsc distinguish between warnings, errors, and 'informational' messages (such as locations of interest that are not errors in their own right)? The examples you supplied all had the word "error" in a prominent place.

It would be possible to join the two tsc rules into a single one which would be slightly faster, but having them separate could also be an advantage since it would allow for them to be disabled individually in case of clashes.


[-- Attachment #2: 0001-Simplify-typescript-compilation-mode-patterns-bug-61.patch --]
[-- Type: application/octet-stream, Size: 3086 bytes --]

From d6d336cfe588dd5d8a5bf647c5beb9e45b47ef3d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 6 Feb 2023 11:45:33 +0100
Subject: [PATCH] Simplify typescript compilation-mode patterns (bug#61104)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Tighten regexps and simplify.  Translate to rx.
* etc/compilation.txt: Add examples.

In collaboration with Jostein Kjønigsen.
---
 etc/compilation.txt       | 14 ++++++++++++++
 lisp/progmodes/compile.el | 28 ++++++++++++++++++++--------
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/etc/compilation.txt b/etc/compilation.txt
index 672cbebafff..5f6ecb09cc2 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -639,6 +639,20 @@ symbol: weblint
 index.html (13:1) Unknown element <fdjsk>
 
 
+* Typescript prior to tsc version 2.7, "plain" format
+
+symbol: typescript-tsc-plain
+
+greeter.ts(30,12): error TS2339: Property 'foo' does not exist.
+
+
+* Typescript after tsc version 2.7, "pretty" format
+
+symbol: typescript-tsc-pretty
+
+src/resources/document.ts:140:22 - error TS2362: something.
+
+
 * Directory tracking
 
 Directories are matched via 'compilation-directory-matcher'.  Files which are
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 1e57d0b7bb2..ccf64fb670b 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -653,19 +653,31 @@ compilation-error-regexp-alist-alist
     ;; 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]+$")
+     ,(rx bol
+          (group (not (in " \t\n()"))   ; 1: file
+                 (* (not (in "\n()"))))
+          "("
+          (group (+ (in "0-9")))        ; 2: line
+          ","
+          (group (+ (in "0-9")))        ; 3: column
+          "): error "
+          (+ (in "0-9A-Z"))             ; error code
+          ": ")
      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]+$")
+     ,(rx bol
+          (group (not (in " \t\n()"))   ; 1: file
+                 (* (not (in "\n()"))))
+          ":"
+          (group (+ (in "0-9")))        ; 2: line
+          ":"
+          (group (+ (in "0-9")))        ; 3: column
+          " - error "
+          (+ (in "0-9A-Z"))             ; error code
+          ": ")
      1 2 3 2)
     ))
   "Alist of values for `compilation-error-regexp-alist'.")
-- 
2.32.0 (Apple Git-132)


  reply	other threads:[~2023-02-06 11:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27 20:14 bug#61104: 29.0.60; typescript-ts-mode does not provide compilation-mode support Jostein Kjønigsen
2023-01-27 20:30 ` Eli Zaretskii
2023-01-27 20:52   ` Jostein Kjønigsen
2023-01-28  7:23     ` Eli Zaretskii
2023-01-28 14:28       ` Jostein Kjønigsen
2023-02-02 21:01         ` Jostein Kjønigsen
2023-02-03  5:30           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-03  7:06             ` Eli Zaretskii
2023-02-03  8:00               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-04  8:24                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-04 11:59 ` Mattias Engdegård
2023-02-05 20:36   ` Jostein Kjønigsen
2023-02-06 11:19     ` Mattias Engdegård [this message]
2023-02-06 17:05       ` Jostein Kjønigsen
2023-02-06 17:34         ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2F86FB50-87F7-432D-B87A-1738056907AB@gmail.com \
    --to=mattias.engdegard@gmail.com \
    --cc=61104@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=jostein@kjonigsen.net \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).