unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>
To: "Mattias Engdegård" <mattias.engdegard@gmail.com>, 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: Sun, 5 Feb 2023 21:36:34 +0100	[thread overview]
Message-ID: <12a97d26-90cc-4a25-61a5-5aff33915610@secure.kjonigsen.net> (raw)
In-Reply-To: <792EC2CE-006B-42F1-81C2-453E71C2173C@gmail.com>

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

Hey there and thanks for the valuable feedback!

I'll try to do my best to provide the info I can, so that we can create 
the tightest regexps for this, which still are functional on the level 
users would expect.

On 2/4/23 12:59, Mattias Engdegård wrote:
> First of all, both regexps match arbitrary amounts of horizontal whitespace at the beginning of a line, but neither message example you supplied contains any such leading whitespace. This means that either the set of test cases needs to be extended, or we could safely remove this leading whitespace matcher.

I've gone looking, but I really can't find confirmation that this 
whitespace is required, at least not when building directly through the 
tsc TypeScript compiler.
I can see in the old test-suite for the MELPA package these two variants 
were the only test-cases present as well.

As such I think it's defiintely safe to remove this leading whitespace.

> Similarly the patterns match arbitrary whitespace before the word "error". This seems equally questionable -- would a single space do? If not, please provide actual output demonstrating it that could be added to the test suite, and tell us how it varies (tabs vs spaces, amount of whitespace, etc).
I can't see any real use-case for this either. Let's snip it.
> The following is a minor point that we'll fix but I thought you may want to know:
>
> The use of [[:blank:]] and [[:alnum:]] is very likely more expensive than required since they accept Unicode whitespace and letters which obviously never will occur where matched so if it's all the same to you we'll reduce them to ASCII patterns.
I've given this a try, and it seems to work fine. I'm OK with such a change.
> Similarly, the inclusion of \r in patterns seems to be a misunderstanding: the tail part, "[^\r\n]+$", does not make sense -- normally, carriage returns aren't seen in buffers because line terminator translation convert everything to a single \n, and if a stray CR did occur then that pattern would never match anyway (why?).

Fair enough. I've changed the code to only looks for \n instead.

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.

--
Jostein

[-- Attachment #2: 0001-Optimize-compilation-mode-expressions-for-TypeScript.patch --]
[-- Type: text/x-patch, Size: 1488 bytes --]

From 1c6a71cd1db5b589ff9fc5f4fe76e9357b7bedbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= <jostein@kjonigsen.net>
Date: Sun, 5 Feb 2023 21:34:08 +0100
Subject: [PATCH] Optimize compilation-mode expressions for TypeScript

- lisp/progmodes/compile.el: remove unneeded and expensive checks.
---
 lisp/progmodes/compile.el | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 1e57d0b7bb..7700e5f7b1 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -654,18 +654,16 @@ compilation-error-regexp-alist-alist
     ;; 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]+$")
+      "\\([^(\r\n)]+\\)(\\([0-9]+\\),\\([0-9]+\\)): "
+      "error [A-Z0-9]+: [^\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]+$")
+       "\\([^(\r\n)]+\\):\\([0-9]+\\):\\([0-9]+\\) - "
+       "error [A-Z0-9]+: [^\n]+$")
      1 2 3 2)
     ))
   "Alist of values for `compilation-error-regexp-alist'.")
-- 
2.39.1


  reply	other threads:[~2023-02-05 20:36 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 [this message]
2023-02-06 11:19     ` Mattias Engdegård
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=12a97d26-90cc-4a25-61a5-5aff33915610@secure.kjonigsen.net \
    --to=jostein@secure.kjonigsen.net \
    --cc=61104@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=jostein@kjonigsen.net \
    --cc=mattias.engdegard@gmail.com \
    --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).