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

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

[nongnu] elpa/julia-mode d96a08c 180/352: Refactoring julia-char-regex a


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode d96a08c 180/352: Refactoring julia-char-regex as an rx form.
Date: Sun, 29 Aug 2021 11:22:40 -0400 (EDT)

branch: elpa/julia-mode
commit d96a08c47aca625439e0d09f4e5dc2bf85edc4b6
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>

    Refactoring julia-char-regex as an rx form.
    
    This regexp has been simplified from the original. The equivalent rx
    form of the original is:
    
    (defconst julia-char-regex
      (rx (submatch (or (any "-" ";" "\\" "^" "!" "|" "?" "*" "\\" "<" "%" "," 
"=" ">" "+" "/" "&" "$" "\\" "~" "\\" ":")
                        (syntax open-parenthesis)
                        (syntax whitespace)
                        bol))
          (submatch "'"
                    (submatch (or (submatch (*\? (not (any "'"))) (not (any 
"\\" "\\")))
                                  (submatch "\\\\")))
                    "'")))
    
    However, the inner groups are unnecessary and there are repeated "\\"
    occurrences.
---
 julia-mode.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/julia-mode.el b/julia-mode.el
index a5b6d94..efbc9df 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -110,7 +110,14 @@ This function provides equivalent functionality, but makes 
no efforts to optimis
   "\"[^\"]*?\\(\\(\\\\\\\\\\)*\\\\\"[^\"]*?\\)*\"")
 
 (defconst julia-char-regex
-  
"\\(\\s(\\|\\s-\\|-\\|[,%=<>\\+*/?&|$!\\^~\\\\;:]\\|^\\)\\('\\(\\([^']*?[^\\\\]\\)\\|\\(\\\\\\\\\\)\\)'\\)")
+  (rx (submatch (or (any "-" ";" "\\" "^" "!" "|" "?" "*" "<" "%" "," "=" ">" 
"+" "/" "&" "$" "~" ":")
+                    (syntax open-parenthesis)
+                    (syntax whitespace)
+                    bol))
+      (submatch "'"
+                (or (*? (not (any "'"))) (not (any "\\"))
+                    "\\\\")
+                "'")))
 
 (defconst julia-unquote-regex
   "\\(\\s(\\|\\s-\\|-\\|[,%=<>\\+*/?&|!\\^~\\\\;:]\\|^\\)\\($[a-zA-Z0-9_]+\\)")



reply via email to

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