Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rec/quoted quote #143

Merged
merged 14 commits into from
Sep 17, 2020
Merged
23 changes: 23 additions & 0 deletions julia-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,18 @@ identity"
a = \"#\" # |>
identity"))

(ert-deftest julia--test-indent-quoted-single-quote ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add julia--should-font-lock tests for examples from #142.

"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 ()
Expand Down Expand Up @@ -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."
Expand Down
15 changes: 11 additions & 4 deletions julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down