diff options
| author | Rudolf Adamkovič | 2023-10-03 09:07:40 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2024-01-10 14:48:00 +0100 |
| commit | cd0eb055fd4ebc3f7f7f5f5617549f963fe8ecff (patch) | |
| tree | 71915b578d6716d4e078bfc69f611d923b3d4247 | |
| parent | 3d412395246599bf633efd3ecd7f33c2bb97f66b (diff) | |
| download | emacs-cd0eb055fd4ebc3f7f7f5f5617549f963fe8ecff.tar.gz emacs-cd0eb055fd4ebc3f7f7f5f5617549f963fe8ecff.zip | |
Make Compilation mode recognize Lua errors
Emacs comes with built-in support for the Lua programming language in
the form of the Lua mode and now also the Lua Tree-sitter mode. This
patch further improves Lua support in Emacs by making the Compilation
mode recognize Lua errors and stack traces.
* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Add regexps to aid Lua development, namely the 'lua' regexp that
matches Lua errors and the 'lua-stack' regexp that matches Lua stack
frames. (Bug#60830)
* etc/compilation.txt (Lua): Add an example of a Lua error message
with a stack trace.
* test/lisp/progmodes/compile-tests.el (compile-tests--test-regexps-data):
(compile-test-error-regexps): Test the new 'lua' and 'lua-stack'
regexps added to the 'compilation-error-regexp-alist-alist'.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | etc/compilation.txt | 13 | ||||
| -rw-r--r-- | lisp/progmodes/compile.el | 8 | ||||
| -rw-r--r-- | test/lisp/progmodes/compile-tests.el | 31 |
4 files changed, 55 insertions, 2 deletions
| @@ -452,6 +452,11 @@ This is because it partly acts by modifying other rules which may | |||
| 452 | occasionally be surprising. It can be re-enabled by adding 'omake' to | 452 | occasionally be surprising. It can be re-enabled by adding 'omake' to |
| 453 | 'compilation-error-regexp-alist'. | 453 | 'compilation-error-regexp-alist'. |
| 454 | 454 | ||
| 455 | *** Lua errors and stack traces are now recognized. | ||
| 456 | Compilation mode now recognizes Lua language errors and stack traces. | ||
| 457 | Every Lua error is recognized as a compilation error, and every Lua | ||
| 458 | stack frame is recognized as a compilation info. | ||
| 459 | |||
| 455 | ** Project | 460 | ** Project |
| 456 | 461 | ||
| 457 | +++ | 462 | +++ |
diff --git a/etc/compilation.txt b/etc/compilation.txt index c03d30afa79..05f0829864c 100644 --- a/etc/compilation.txt +++ b/etc/compilation.txt | |||
| @@ -344,6 +344,19 @@ In /home/janneke/vc/guile/examples/gud-break.scm: | |||
| 344 | 1033: 0 [stderr "~a:hello world\n" (# # #)] | 344 | 1033: 0 [stderr "~a:hello world\n" (# # #)] |
| 345 | 345 | ||
| 346 | 346 | ||
| 347 | * Lua 5.1, 5.2, 5.3, 5.4, and LuaJIT 2.1 | ||
| 348 | |||
| 349 | /usr/bin/lua: database.lua:31: assertion failed! | ||
| 350 | stack traceback: | ||
| 351 | [C]: in function 'assert' | ||
| 352 | database.lua:31: in field 'statement' | ||
| 353 | database.lua:42: in field 'table' | ||
| 354 | database.lua:55: in field 'row' | ||
| 355 | database.lua:63: in field 'value' | ||
| 356 | io.lua: in main chunk | ||
| 357 | [C]: in ? | ||
| 358 | |||
| 359 | |||
| 347 | * Lucid Compiler, lcc 3.x | 360 | * Lucid Compiler, lcc 3.x |
| 348 | 361 | ||
| 349 | symbol: lcc | 362 | symbol: lcc |
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index e7d4e9966cf..797e594c0c5 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el | |||
| @@ -362,6 +362,14 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1)) | |||
| 362 | (ruby-Test::Unit | 362 | (ruby-Test::Unit |
| 363 | "^ [[ ]?\\([^ (].*\\):\\([1-9][0-9]*\\)\\(\\]\\)?:in " 1 2) | 363 | "^ [[ ]?\\([^ (].*\\):\\([1-9][0-9]*\\)\\(\\]\\)?:in " 1 2) |
| 364 | 364 | ||
| 365 | ;; Tested with Lua 5.1, 5.2, 5.3, 5.4, and LuaJIT 2.1. | ||
| 366 | (lua | ||
| 367 | "^[^\n\t]+?: \\([^\n\t]+?\\):\\([0-9]+?\\): .+\nstack traceback:\n\t" | ||
| 368 | 1 2 nil 2 1) | ||
| 369 | (lua-stack | ||
| 370 | "^\t\\(?:\\[C\\]:\\|\\([^\n\t]+?\\):\\(?:\\([0-9]+?\\):\\)?\\) in " | ||
| 371 | 1 2 nil 0 1) | ||
| 372 | |||
| 365 | (gmake | 373 | (gmake |
| 366 | ;; Set GNU make error messages as INFO level. | 374 | ;; Set GNU make error messages as INFO level. |
| 367 | ;; It starts with the name of the make program which is variable, | 375 | ;; It starts with the name of the make program which is variable, |
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el index f5b5cad9c0b..20beed955d2 100644 --- a/test/lisp/progmodes/compile-tests.el +++ b/test/lisp/progmodes/compile-tests.el | |||
| @@ -206,6 +206,33 @@ | |||
| 206 | 1 0 31 "/usr/include/c++/3.3/backward/iostream.h") | 206 | 1 0 31 "/usr/include/c++/3.3/backward/iostream.h") |
| 207 | (gcc-include " from test_clt.cc:1:" | 207 | (gcc-include " from test_clt.cc:1:" |
| 208 | 1 nil 1 "test_clt.cc") | 208 | 1 nil 1 "test_clt.cc") |
| 209 | ;; Lua | ||
| 210 | (lua "lua: database.lua:10: assertion failed!\nstack traceback:\n\t" | ||
| 211 | 6 nil 10 "database.lua") | ||
| 212 | (lua "lua 5.4: database 2.lua:10: assertion failed!\nstack traceback:\n\t" | ||
| 213 | 10 nil 10 "database 2.lua") | ||
| 214 | (lua "/usr/local/bin/lua: core/database.lua:20: assertion failed!\nstack traceback:\n\t" | ||
| 215 | 21 nil 20 "core/database.lua") | ||
| 216 | (lua "C:\\Lua\\Lua.exe: Core\\Database.lua:20: assertion failed!\nstack traceback:\n\t" | ||
| 217 | 17 nil 20 "Core\\Database.lua") | ||
| 218 | (lua "lua: /tmp/database.lua:20: assertion failed!\nstack traceback:\n\t" | ||
| 219 | 6 nil 20 "/tmp/database.lua") | ||
| 220 | (lua "Lua.exe: C:\\Temp\\Database.lua:20: assertion failed!\nstack traceback:\n\t" | ||
| 221 | 10 nil 20 "C:\\Temp\\Database.lua") | ||
| 222 | (lua-stack " database.lua: in field 'statement'" | ||
| 223 | 2 nil nil "database.lua" 0) | ||
| 224 | (lua-stack " database.lua:10: in field 'statement'" | ||
| 225 | 2 nil 10 "database.lua" 0) | ||
| 226 | (lua-stack " core/database.lua:20: in field 'statement'" | ||
| 227 | 2 nil 20 "core/database.lua" 0) | ||
| 228 | (lua-stack " database 2.lua: in field 'statement'" | ||
| 229 | 2 nil nil "database 2.lua" 0) | ||
| 230 | (lua-stack " Core\\Database.lua:20: in field 'statement'" | ||
| 231 | 2 nil 20 "Core\\Database.lua" 0) | ||
| 232 | (lua-stack " /tmp/database.lua: in field 'statement'" | ||
| 233 | 2 nil nil "/tmp/database.lua" 0) | ||
| 234 | (lua-stack " C:\\Core\\Database.lua: in field 'statement'" | ||
| 235 | 2 nil nil "C:\\Core\\Database.lua" 0) | ||
| 209 | ;; gmake | 236 | ;; gmake |
| 210 | (gmake "make: *** [Makefile:20: all] Error 2" 12 nil 20 "Makefile" 0) | 237 | (gmake "make: *** [Makefile:20: all] Error 2" 12 nil 20 "Makefile" 0) |
| 211 | (gmake "make[4]: *** [sub/make.mk:19: all] Error 127" 15 nil 19 | 238 | (gmake "make[4]: *** [sub/make.mk:19: all] Error 127" 15 nil 19 |
| @@ -507,9 +534,9 @@ The test data is in `compile-tests--test-regexps-data'." | |||
| 507 | 1 15 5 "alpha.c"))) | 534 | 1 15 5 "alpha.c"))) |
| 508 | (compile--test-error-line test)) | 535 | (compile--test-error-line test)) |
| 509 | 536 | ||
| 510 | (should (eq compilation-num-errors-found 100)) | 537 | (should (eq compilation-num-errors-found 106)) |
| 511 | (should (eq compilation-num-warnings-found 35)) | 538 | (should (eq compilation-num-warnings-found 35)) |
| 512 | (should (eq compilation-num-infos-found 28))))) | 539 | (should (eq compilation-num-infos-found 35))))) |
| 513 | 540 | ||
| 514 | (ert-deftest compile-test-grep-regexps () | 541 | (ert-deftest compile-test-grep-regexps () |
| 515 | "Test the `grep-regexp-alist' regexps. | 542 | "Test the `grep-regexp-alist' regexps. |