emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/julia-mode e22debdd96 13/14: Merge pull request #177 from


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode e22debdd96 13/14: Merge pull request #177 from non-Jedi/li1-imenu-fixes
Date: Wed, 12 Jul 2023 04:00:22 -0400 (EDT)

branch: elpa/julia-mode
commit e22debdd96709f115a1bd643aa3584fb0b37455f
Merge: c798df5a4e f08a73d6fb
Author: Tamas K. Papp <tkpapp@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #177 from non-Jedi/li1-imenu-fixes
    
    @li1 imenu fixes now tested
---
 julia-mode-tests.el |  9 +++++++++
 julia-mode.el       | 33 +++++++++++++++++----------------
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/julia-mode-tests.el b/julia-mode-tests.el
index e77cf03818..5c4d8832f9 100644
--- a/julia-mode-tests.el
+++ b/julia-mode-tests.el
@@ -749,6 +749,15 @@ var = func(begin
         (julia--should-font-lock c (- (length c) 1) font-lock-string-face)
         (julia--should-font-lock c (length c) nil)))))
 
+(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 7f8f7c171a..47c325e2d4 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -288,6 +288,13 @@ partial match for LaTeX completion, or `nil' when not 
applicable."
                        "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))))))
 
@@ -337,6 +344,10 @@ partial match for LaTeX completion, or `nil' when not 
applicable."
    (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)
@@ -791,22 +802,12 @@ Return nil if point is not in a function, otherwise 
point."
 ;;; IMENU
 (defvar julia-imenu-generic-expression
   ;; don't use syntax classes, screws egrep
-  '(("Function (_)" "[ \t]*function[ \t]+\\(_[^ \t\n]*\\)" 1)
-    ("Function" "^[ \t]*function[ \t]+\\([^_][^\t\n]*\\)" 1)
-    ("Const" "[ \t]*const \\([^ \t\n]*\\)" 1)
-    ("Type"  "^[ \t]*[a-zA-Z0-9_]*type[a-zA-Z0-9_]* \\([^ \t\n]*\\)" 1)
-    ("Require"      " *\\(\\brequire\\)(\\([^ \t\n)]*\\)" 2)
-    ("Include"      " *\\(\\binclude\\)(\\([^ \t\n)]*\\)" 2)
-    ;; ("Classes" "^.*setClass(\\(.*\\)," 1)
-    ;; ("Coercions" "^.*setAs(\\([^,]+,[^,]*\\)," 1) ; show from and to
-    ;; ("Generics" "^.*setGeneric(\\([^,]*\\)," 1)
-    ;; ("Methods" "^.*set\\(Group\\|Replace\\)?Method(\"\\(.+\\)\"," 2)
-    ;; ;;[ ]*\\(signature=\\)?(\\(.*,?\\)*\\)," 1)
-    ;; ;;
-    ;; ;;("Other" "^\\(.+\\)\\s-*<-[ 
\t\n]*[^\\(function\\|read\\|.*data\.frame\\)]" 1)
-    ;; ("Package" "^.*\\(library\\|require\\)(\\(.*\\)," 2)
-    ;; ("Data" "^\\(.+\\)\\s-*<-[ \t\n]*\\(read\\|.*data\.frame\\).*(" 1)))
-    ))
+  `(("Function" ,julia-function-regex 1)
+    ("Function" ,julia-function-assignment-regex 1)
+    ("Const" ,julia-const-def-regex 1)
+    ("Type" ,julia-type-regex 1)
+    ("Require" " *\\(\\brequire\\)(\\([^ \t\n)]*\\)" 2)
+    ("Include" " *\\(\\binclude\\)(\\([^ \t\n)]*\\)" 2)))
 
 ;;;###autoload
 (define-derived-mode julia-mode prog-mode "Julia"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]