Skip to content

Commit

Permalink
Merge pull request #197 from non-Jedi/fix-const-regexp
Browse files Browse the repository at this point in the history
Fix const definition regex to match symbols with underscores etc.
  • Loading branch information
tpapp authored Jul 12, 2023
2 parents 89e5e00 + 5370850 commit 7a8c868
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions julia-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,16 @@ var = func(begin
(julia--should-font-lock string 11 nil) ; =
))

(ert-deftest julia--test-const-def-font-lock-underscores ()
(let ((string "@macro const foo_bar = \"bar\""))
(julia--should-font-lock string 8 font-lock-keyword-face) ; const
(julia--should-font-lock string 12 font-lock-keyword-face) ; const
(julia--should-font-lock string 14 font-lock-variable-name-face) ; foo
(julia--should-font-lock string 17 font-lock-variable-name-face) ; _
(julia--should-font-lock string 20 font-lock-variable-name-face) ; bar
(julia--should-font-lock string 22 nil) ; =
))

;;; Movement
(ert-deftest julia--test-beginning-of-defun-assn-1 ()
"Point moves to beginning of single-line assignment function."
Expand Down
8 changes: 4 additions & 4 deletions julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ partial match for LaTeX completion, or `nil' when not applicable."

(defconst julia-const-def-regex
(rx
bol (zero-or-more space)
"const" space
(group (one-or-more alnum)) (zero-or-more space)
"=" (not (any "="))))
symbol-start "const" (1+ space)
(group (minimal-match (seq symbol-start (one-or-more anything) symbol-end)))
(zero-or-more space)
"="))

(defconst julia-type-annotation-regex
(rx "::" (0+ space) (group (1+ (or word (syntax symbol))))))
Expand Down

0 comments on commit 7a8c868

Please sign in to comment.