[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 107940a19e 09/14: Font-lock const definitions w
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 107940a19e 09/14: Font-lock const definitions with font-lock-variable-name-face |
Date: |
Wed, 12 Jul 2023 04:00:17 -0400 (EDT) |
branch: elpa/julia-mode
commit 107940a19ecc227be433a953a74b8f5264d3a12f
Author: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>
Commit: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>
Font-lock const definitions with font-lock-variable-name-face
This commit also adds a test, so all of the regexes used by imenu should
have associated
tests now. Since we're defining this regex for imenu anyway, might as well
use it for
font-locking as well.
---
julia-mode-tests.el | 9 +++++++++
julia-mode.el | 20 ++++++++++++--------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/julia-mode-tests.el b/julia-mode-tests.el
index bafff50f96..06b71cfd19 100644
--- a/julia-mode-tests.el
+++ b/julia-mode-tests.el
@@ -532,6 +532,15 @@ end")
(julia--should-font-lock string 74 font-lock-type-face) ; B
))
+(ert-deftest julia--test-const-def-font-lock ()
+ (let ((string "const foo = \"bar\""))
+ (julia--should-font-lock string 1 font-lock-keyword-face) ; const
+ (julia--should-font-lock string 5 font-lock-keyword-face) ; const
+ (julia--should-font-lock string 7 font-lock-variable-name-face) ; foo
+ (julia--should-font-lock string 9 font-lock-variable-name-face) ; foo
+ (julia--should-font-lock string 11 nil) ; =
+ ))
+
;;; Movement
(ert-deftest julia--test-beginning-of-defun-assn-1 ()
"Point moves to beginning of single-line assignment function."
diff --git a/julia-mode.el b/julia-mode.el
index 24201289f4..b2c6f361a1 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -236,6 +236,13 @@
"abstract type" "primitive type" "struct" "mutable
struct")
(1+ space) (group (1+ (or word (syntax symbol))))))
+(defconst julia-const-def-regex
+ (rx
+ bol (zero-or-more space)
+ "const" space
+ (group (one-or-more alnum)) (zero-or-more space)
+ "=" (not (any "="))))
+
(defconst julia-type-annotation-regex
(rx "::" (0+ space) (group (1+ (or word (syntax symbol))))))
@@ -283,6 +290,10 @@
(list julia-function-regex 1 'font-lock-function-name-face)
(list julia-function-assignment-regex 1 'font-lock-function-name-face)
(list julia-type-regex 1 'font-lock-type-face)
+ ;; Per the elisp manual, font-lock-variable-name-face is for variables
being defined or
+ ;; declared. It is difficult identify this consistently in julia (see issue
#2). For now,
+ ;; we only font-lock constant definitions.
+ (list julia-const-def-regex 1 'font-lock-variable-name-face)
;; font-lock-type-face is for the point of type definition rather
;; than usage, but using for type annotations is an acceptable pun.
(list julia-type-annotation-regex 1 'font-lock-type-face)
@@ -700,19 +711,12 @@ Return nil if point is not in a function, otherwise
point."
(end-of-line)
(point))))
-(defconst julia-imenu-const
- (rx
- bol (zero-or-more space)
- "const" space
- (group (one-or-more alnum)) (zero-or-more space)
- "=" space))
-
;;; IMENU
(defvar julia-imenu-generic-expression
;; don't use syntax classes, screws egrep
`(("Function" ,julia-function-regex 1)
("Function" ,julia-function-assignment-regex 1)
- ("Const" ,julia-imenu-const 1)
+ ("Const" ,julia-const-def-regex 1)
("Struct" ,julia-type-regex 1)
("Require" " *\\(\\brequire\\)(\\([^ \t\n)]*\\)" 2)
("Include" " *\\(\\binclude\\)(\\([^ \t\n)]*\\)" 2)
- [nongnu] elpa/julia-mode updated (c798df5a4e -> 89e5e005b6), ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode a6c87d7bf4 02/14: Support single-line qualified fns, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 7e8947d749 01/14: Add one-line fns to imenu, type -> struct, const requires =, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 6b43ca61ed 05/14: imenu regex -> rx, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode a7caf75c16 04/14: Simplify one-line, support @annotations for all fns, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 1f53a51400 07/14: Use rx macro instead of rx-to-string for imenu regexes, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 180b7fc5b6 10/14: Delete unused and obsolete syntax from imenu comments, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 45fc7039dc 06/14: setq -> defvar, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 260bb21a7d 08/14: Use existing font-lock regexes for imenu instead of rewriting, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 107940a19e 09/14: Font-lock const definitions with font-lock-variable-name-face,
ELPA Syncer <=
- [nongnu] elpa/julia-mode f08a73d6fb 12/14: Change "Struct" label to "Type" for imenu, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode e22debdd96 13/14: Merge pull request #177 from non-Jedi/li1-imenu-fixes, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode 89e5e005b6 14/14: do not test on Emacs master, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode d4077f27a8 03/14: match _one-liners; preserve types; stop at end, ELPA Syncer, 2023/07/12
- [nongnu] elpa/julia-mode f7b8178fbf 11/14: Merge remote-tracking branch 'upstream/master' into li1-imenu-fixes, ELPA Syncer, 2023/07/12