|
3 | 3 | ;; Copyright (C) 2016–2024 Tamas K. Papp |
4 | 4 | ;; Author: Tamas Papp <[email protected]> |
5 | 5 | ;; Keywords: languages |
6 | | -;; Version: 1.4.0 |
7 | | -;; Package-Requires: ((emacs "25.1")(s "1.12")) |
| 6 | +;; Version: 1.5.0 |
| 7 | +;; Package-Requires: ((emacs "27.1")(s "1.12")) |
8 | 8 | ;; URL: https://github.com/tpapp/julia-repl |
9 | 9 |
|
10 | 10 | ;;; Usage: |
|
47 | 47 | (require 'seq) |
48 | 48 | (require 'subr-x) |
49 | 49 |
|
50 | | - |
51 | 50 | ;; |
52 | 51 | ;; customizations |
53 | 52 | ;; |
@@ -266,30 +265,40 @@ When PASTE-P, “bracketed paste” mode will be used. When RET-P, terminate wit |
266 | 265 | (when ret-p |
267 | 266 | (eat-term-send-string eat-terminal "\^M"))))) |
268 | 267 |
|
| 268 | +(defconst julia-repl--CR-at |
| 269 | + (rx "@" space |
| 270 | + (? (group (one-or-more (or (any "._") alnum))) space) ; group 1: module name |
| 271 | + (group (+ (not (any space ">" "<" "(" ")" "\t" "\n" "," "'" "\"" ";" ":")))) ; group 2: path |
| 272 | + ":" |
| 273 | + (group (+ num)) ; group 3: line number |
| 274 | + ) |
| 275 | + "Matches “@ Foo ~/code/Foo/src/Foo.jl:100”. This is what is used in Julia >= 1.6") |
| 276 | + |
| 277 | +(defconst julia-repl--CR-filename |
| 278 | + (rx (one-or-more (not (any " ><()\t\n,'\";:")))) |
| 279 | + "An attempt to match filenames in error, info, and warning messages printed by Julia.") |
| 280 | + |
| 281 | +(defconst julia-repl--CR-load-error |
| 282 | + (rx |
| 283 | + "while loading " |
| 284 | + (group (regexp julia-repl--CR-filename)) |
| 285 | + ", in expression starting on line " |
| 286 | + (group (one-or-more digit))) |
| 287 | + "Compilation regexp matching “while loading /tmp/Foo.jl, in expression starting on line 2”.") |
| 288 | + |
| 289 | +(defconst julia-repl--CR-around |
| 290 | + (rx |
| 291 | + (or "around" "at" "Revise") |
| 292 | + " " |
| 293 | + (group (regexp julia-repl--CR-filename)) |
| 294 | + ":" |
| 295 | + (group (one-or-more digit))) |
| 296 | + "Compilation regexp matching “around /tmp/Foo.jl:2”, also starting with “at or “Revise”") |
| 297 | + |
269 | 298 | ;; |
270 | 299 | ;; global variables |
271 | 300 | ;; |
272 | 301 |
|
273 | | -(defconst julia-repl--rx-at |
274 | | - (rx (seq "@" (syntax whitespace) |
275 | | - (? (group (+ alnum)) space) ; package name |
276 | | - (group (+ (not (any space ">" "<" "(" ")" "\t" "\n" "," "'" "\"" ";" ":")))) ; path |
277 | | - ":" (group (+ num)))) ; line |
278 | | - "Matches “@ Foo ~/code/Foo/src/Foo.jl:100”") |
279 | | - |
280 | | -(defvar julia-repl--compilation-regexp-alist |
281 | | - `(;; matches "while loading /tmp/Foo.jl, in expression starting on line 2" |
282 | | - (julia-load-error . ("while loading \\([^ ><()\t\n,'\";:]+\\), in expression starting on line \\([0-9]+\\)" 1 2)) |
283 | | - ;; matches "around /tmp/Foo.jl:2", also starting with "at" or "Revise" |
284 | | - (julia-loc . ("\\(around\\|at\\|Revise\\) \\([^ ><()\t\n,'\";:]+\\):\\([0-9]+\\)" 2 3)) |
285 | | - ;; matches "omitting file /tmp/Foo.jl due to parsing error near line 2", from Revise.parse_source! |
286 | | - (julia-warn-revise . ("omitting file \\([^ ><()\t\n,'\";:]+\\) due to parsing error near line \\([0-9]+\\)" 1 2)) |
287 | | - (julia-error-at . (,julia-repl--rx-at 2 3)) |
288 | | - ) |
289 | | - "Specifications for highlighting error locations. |
290 | | -
|
291 | | -Uses function ‘compilation-shell-minor-mode’.") |
292 | | - |
293 | 302 | (defvar julia-repl--terminal-backend |
294 | 303 | (make-julia-repl--buffer-ansi-term) |
295 | 304 | "Terminal backend, for internal use. Set using `julia-repl-set-terminal-backend'.") |
@@ -374,6 +383,20 @@ generate a buffer name.") |
374 | 383 | Valid values are NIL or a string. These take effect the next time |
375 | 384 | a new Julia process is started.") |
376 | 385 |
|
| 386 | +(defvar julia-repl-compilation-location-legacy nil |
| 387 | + "Whether to include recognize various legacy error messages in compilation output. |
| 388 | + Mainly useful if you are using Julia <1.6.") |
| 389 | + |
| 390 | +(defun julia-repl--compilation-regexp-alist () |
| 391 | + "Return an alist suitable for use in `compilation-error-regexp-alist' for recognizing Julia error locations. |
| 392 | +
|
| 393 | + Cf `julia-repl-compilation-location-legacy'." |
| 394 | + (let ((regexp-alist `((,julia-repl--CR-at 2 3)))) |
| 395 | + (if julia-repl-compilation-location-legacy |
| 396 | + (cons regexp-alist |
| 397 | + `((,julia-repl--CR-load-error 1 2) (,julia-repl--CR-around 1 2))) |
| 398 | + regexp-alist))) |
| 399 | + |
377 | 400 | ;; |
378 | 401 | ;; REPL buffer creation and setup |
379 | 402 | ;; |
@@ -446,10 +469,7 @@ prevent further attempts." |
446 | 469 |
|
447 | 470 | BASEDIR is used for resolving relative paths." |
448 | 471 | (with-current-buffer inferior-buffer |
449 | | - (setq-local compilation-error-regexp-alist-alist |
450 | | - julia-repl--compilation-regexp-alist) |
451 | | - (setq-local compilation-error-regexp-alist |
452 | | - (mapcar #'car compilation-error-regexp-alist-alist)) |
| 472 | + (setq-local compilation-error-regexp-alist (julia-repl--compilation-regexp-alist)) |
453 | 473 | (when basedir |
454 | 474 | (setq-local compilation-search-path (list basedir))) |
455 | 475 | (compilation-shell-minor-mode 1))) |
|
0 commit comments