branch: elpa/julia-mode commit ac7431c4a943903ffb179c248dbc4f049e74d6d1 Author: Wilfred Hughes <m...@wilfred.me.uk> Commit: Yichao Yu <yyc1...@gmail.com>
Mark @ and ! as a symbol constituents, as suggested by @Clemens-H. Generally only [a-zA-Z0-9] should be word constituents, and everything else should be a symbol constituent. See http://emacs.stackexchange.com/q/1075/304 for a discussion. This also enables us to simplify our regexps. --- julia-mode.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/julia-mode.el b/julia-mode.el index d5e9ad2..c4e3522 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -49,8 +49,9 @@ (defvar julia-mode-syntax-table (let ((table (make-syntax-table))) - (modify-syntax-entry ?_ "w" table) ; underscores in words - (modify-syntax-entry ?@ "w" table) + (modify-syntax-entry ?_ "_" table) + (modify-syntax-entry ?@ "_" table) + (modify-syntax-entry ?! "_" table) (modify-syntax-entry ?# "< 14" table) ; # single-line and multiline start (modify-syntax-entry ?= ". 23bn" table) (modify-syntax-entry ?\n ">" table) ; \n single-line comment end @@ -106,16 +107,16 @@ ].* \\(in\\)\\(\\s-\\|$\\)+") (defconst julia-function-regex - (rx symbol-start "function" + (rx line-start symbol-start "function" (1+ space) ;; Don't highlight module names in function declarations: - (* (seq (1+ (or word ?_)) ".")) + (* (seq (1+ (or word (syntax symbol))) ".")) ;; The function name itself - (group (1+ (or word ?_ ?!))))) + (group (1+ (or word (syntax symbol)))))) (defconst julia-function-assignment-regex (rx line-start symbol-start - (group (1+ (or word ?_ ?!))) + (group (1+ (or word (syntax symbol)))) (* space) (? "{" (* (not (any "}"))) "}") (* space) @@ -124,19 +125,19 @@ "=")) (defconst julia-type-regex - (rx symbol-start (or "immutable" "type" "abstract") (1+ space) (group (1+ (or word ?_))))) + (rx symbol-start (or "immutable" "type" "abstract") (1+ space) (group (1+ (or word (syntax symbol)))))) (defconst julia-type-annotation-regex - (rx "::" (group (1+ (or word ?_))))) + (rx "::" (group (1+ (or word (syntax symbol)))))) ;;(defconst julia-type-parameter-regex -;; (rx symbol-start (1+ (or word ?_)) "{" (group (1+ (or word ?_))) "}")) +;; (rx symbol-start (1+ (or (or word (syntax symbol)) ?_)) "{" (group (1+ (or (or word (syntax symbol)) ?_))) "}")) (defconst julia-subtype-regex - (rx "<:" (1+ space) (group (1+ (or word ?_))) (0+ space) (or "\n" "{" "end"))) + (rx "<:" (1+ space) (group (1+ (or word (syntax symbol)))) (0+ space) (or "\n" "{" "end"))) (defconst julia-macro-regex - (rx symbol-start (group "@" (1+ (or word ?_ ?!))))) + (rx symbol-start (group "@" (1+ (or word (syntax symbol)))))) (defconst julia-keyword-regex (regexp-opt