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
16 changes: 16 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,10 @@ 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'" "'\\alpha'" "'a'" "'z'"))
(julia--should-font-lock c 1 font-lock-string-face)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to test that the string-face ends at the end of the char literal.


;;; Movement
(ert-deftest julia--test-beginning-of-defun-assn-1 ()
"Point moves to beginning of single-line assignment function."
Expand Down
5 changes: 3 additions & 2 deletions julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@
(syntax whitespace)
bol)
(group "'")
(or (repeat 0 8 (not (any "'"))) (not (any "\\"))
"\\\\")
(or (not (any "\\'"))
(seq "\\" (or (repeat 1 9 (not (any "\\'")))
(any "\\'"))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this match e.g. '\n', \0, \x7f, \177? It doesn't seem like it would. Probably worth adding a test for those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They all fit into the "(1 to 9 (not (backslash or singlequote))) after backslash" clause. I could be more prescriptive, if you like.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense. This is fine. If you wanted to, you could add a couple comments with more explanation of the different forms of char literals and how they're matched, but I don't think that should block merging this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, explanations would be great if @recri has the time. Also, indentation of (seq ... looks a bit off.

(group "'"))))

(defconst julia-hanging-operator-regexp
Expand Down