Skip to content

Commit 0173237

Browse files
authored
Merge pull request #158 from tpapp/tp/in-expression-starting-at-location
Add new location matching, "in expression starting at ..."
2 parents 5e5e80f + 5b4766d commit 0173237

3 files changed

Lines changed: 51 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
2025-07-19 Tamas Papp <tkpapp@gmail.com>
1+
# Changelog
22

3-
# Unreleased
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## 1.5.2
9+
10+
### Added
11+
12+
- higlight "in expression starting at" locations
13+
14+
# 1.5.1
15+
16+
!!! NOTE
17+
The changelog was not updated between 1.3.0 and 1.5.1, sorry.
418

519
- protect against missing basedir
620

julia-repl-tests.el

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"c:/Users/PK/another.jl")))
1818

1919
(cl-defmacro julia-repl--buffer (contents position &body body)
20-
"Make a temporary buffer with ‘contents’ and point at ‘position’, then run ‘body’."
20+
"Make a temporary buffer with ‘contents’ and point at ‘position’, then run
21+
‘body’."
2122
`(with-temp-buffer
2223
(julia-repl-mode)
2324
(insert ,contents)
@@ -39,11 +40,17 @@
3940
(should (equal (julia-repl--symbol-extraction "Foo.bar.baz.( " 6) symbols))))
4041

4142
(ert-deftest julia-repl-location-rx ()
43+
(let ((str "~/code/Foo/src/Foo.jl"))
44+
(should (string-match julia-repl--CR-path str)))
4245
(let ((str "@ Foo ~/code/Foo/src/Foo.jl:100"))
4346
(should (string-match julia-repl--CR-at str))
4447
(should (equal (match-string 1 str) "Foo"))
4548
(should (equal (match-string 2 str) "~/code/Foo/src/Foo.jl"))
46-
(should (equal (match-string 3 str) "100"))))
49+
(should (equal (match-string 3 str) "100")))
50+
(let ((str "in expression starting at ~/code/Foo/src/Foo.jl:100"))
51+
(should (string-match julia-repl--CR-expression-starting str))
52+
(should (equal (match-string 1 str) "~/code/Foo/src/Foo.jl"))
53+
(should (equal (match-string 2 str) "100"))))
4754

4855
(ert-deftest julia-repl-error-locations ()
4956
;; module name, absolute path

julia-repl.el

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Copyright (C) 2016–2024 Tamas K. Papp
44
;; Author: Tamas Papp <tkpapp@gmail.com>
55
;; Keywords: languages
6-
;; Version: 1.5.1
6+
;; Version: 1.5.2
77
;; Package-Requires: ((emacs "29.1")(s "1.12"))
88
;; URL: https://github.com/tpapp/julia-repl
99

@@ -268,14 +268,29 @@ When PASTE-P, “bracketed paste” mode will be used. When RET-P, terminate wit
268268
(when ret-p
269269
(eat-term-send-string eat-terminal "\^M")))))
270270

271+
;;; compiler output regexps for navigation
272+
273+
(defconst julia-repl--CR-path
274+
(rx (+ (not (any space ">" "<" "(" ")" "\t" "\n" "," "'" "\"" ";" ":"))))
275+
"A regexp matching paths (in Julia stacktraces).")
276+
271277
(defconst julia-repl--CR-at
272-
(rx "@" space
273-
(? (group (one-or-more (or (any "._") alnum))) space) ; group 1: module name
274-
(group (+ (not (any space ">" "<" "(" ")" "\t" "\n" "," "'" "\"" ";" ":")))) ; group 2: path
275-
":"
276-
(group (+ num)) ; group 3: line number
277-
)
278-
"Matches “@ Foo ~/code/Foo/src/Foo.jl:100”. This is what is used in Julia >= 1.6")
278+
(rx "@" space
279+
(? (group (one-or-more (or (any "._") alnum))) space) ; group 1: module name
280+
(group (regexp julia-repl--CR-path)) ; group 2: path
281+
":"
282+
(group (+ num)) ; group 3: line number
283+
)
284+
"Matches “@ Foo ~/code/Foo/src/Foo.jl:100”. This is what is used in Julia >= 1.6")
285+
286+
(defconst julia-repl--CR-expression-starting
287+
(rx "in expression starting at"
288+
(+ space)
289+
(group (regexp julia-repl--CR-path)) ; group 1: path
290+
":"
291+
(group (+ num)) ; group 2: line
292+
)
293+
"Matches “in expression starting at ~/code/Foo/src/Foo.jl:100”.")
279294

280295
(defconst julia-repl--CR-filename
281296
(rx (one-or-more (not (any " ><()\t\n,'\";:"))))
@@ -394,7 +409,8 @@ a new Julia process is started.")
394409
"Return an alist suitable for use in `compilation-error-regexp-alist' for recognizing Julia error locations.
395410
396411
Cf `julia-repl-compilation-location-legacy'."
397-
(let ((regexp-alist `((,julia-repl--CR-at 2 3))))
412+
(let ((regexp-alist `((,julia-repl--CR-at 2 3)
413+
(,julia-repl--CR-expression-starting 1 2))))
398414
(if julia-repl-compilation-location-legacy
399415
(cons regexp-alist
400416
`((,julia-repl--CR-load-error 1 2) (,julia-repl--CR-around 1 2)))
@@ -644,7 +660,7 @@ This is the standard entry point for using this package."
644660
"Switch to the buffer that was active before last call to `julia-repl'."
645661
(interactive)
646662
(when (buffer-live-p julia-repl--script-buffer)
647-
(if julia-repl-pop-to-buffer
663+
(if julia-repl-pop-to-buffer
648664
(switch-to-buffer-other-window julia-repl--script-buffer)
649665
(switch-to-buffer julia-repl--script-buffer))))
650666

0 commit comments

Comments
 (0)