branch: elpa/julia-mode commit 8ea90c7927f6d87a291cfb0216f34dacf43c722e Author: Roger E Critchlow Jr <r...@elf.org> Commit: GitHub <nore...@github.com>
Rec/quoted quote (#143) Fix escaped quotes, various minor fixes. --- julia-mode-tests.el | 23 +++++++++++++++++++++++ julia-mode.el | 15 +++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/julia-mode-tests.el b/julia-mode-tests.el index f348821..72713f1 100644 --- a/julia-mode-tests.el +++ b/julia-mode-tests.el @@ -482,6 +482,18 @@ identity" a = \"#\" # |> identity")) +(ert-deftest julia--test-indent-quoted-single-quote () + "We should indent after seeing a character constant containing a single quote character." + (julia--should-indent " +if c in ('\'') +s = \"$c$c\"*string[startpos:pos] +end +" " +if c in ('\'') + s = \"$c$c\"*string[startpos:pos] +end +")) + ;;; font-lock tests (ert-deftest julia--test-symbol-font-locking-at-bol () @@ -620,6 +632,17 @@ identity")) (julia--should-font-lock s1 4 nil) (julia--should-font-lock s1 10 nil))) +(ert-deftest julia--test-char-const-font-lock () + (dolist (c '("'\\''" "'\\\"'" "'\\\\'" "'\\010'" "'\\xfe'" "'\\uabcd'" + "'\\Uabcdef01'" "'\\n'" "'a'" "'z'" "'''")) + (let ((c (format " %s " c))) + (progn + (julia--should-font-lock c 1 nil) + (julia--should-font-lock c 2 font-lock-string-face) + (julia--should-font-lock c (- (length c) 1) font-lock-string-face) + (julia--should-font-lock c (length c) 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 0230ff6..377c9ce 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -109,10 +109,17 @@ (syntax open-parenthesis) (syntax whitespace) bol) - (group "'") - (or (repeat 0 8 (not (any "'"))) (not (any "\\")) - "\\\\") - (group "'")))) + (group "'") ; start single quote of character constant + (or ; two alternatives + (not (any "\\")) ; one character, not backslash + (seq "\\" ; sequence of a backslash followed by ... + (or ; five alternatives + (any "\\'\"abfnrtv") ; single character escape + (repeat 1 3 (any "0-7")) ; octal escape + (seq "x" (repeat 1 2 hex)) ; hex escape + (seq "u" (repeat 1 4 hex)) ; unicode escape + (seq "U" (repeat 1 8 hex))))) ; extended unicode escape + (group "'")))) ; end single quote of character constant (defconst julia-hanging-operator-regexp ;; taken from julia-parser.scm