Skip to content

Use plain string face for quasi quotes #1061

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

Merged
merged 1 commit into from
Jan 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions haskell-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ Inherit from `default' to avoid fontification of them."
:group 'haskell)

(defface haskell-quasi-quote-face
'((((background light)) :background "gray90")
(((background dark)) :background "gray10")
(t :inherit font-lock-string-face))
"Face for background with which to fontify quasi quotes that
are fontified according to other mode defined in
'((t :inherit font-lock-string-face))
"Generic face for quasiquotes.

Some quote types are fontified according to other mode defined in
`haskell-font-lock-quasi-quote-modes'."
:group 'haskell)

Expand Down Expand Up @@ -442,16 +441,15 @@ Returns keywords suitable for `font-lock-keywords'."

(if (and lang-mode
(fboundp lang-mode))
(save-excursion
;; find the end of the QuasiQuote
(parse-partial-sexp (point) (point-max) nil nil state
'syntax-table)
(haskell-font-lock-fontify-block lang-mode (1+ (nth 8 state)) (1- (point)))
(font-lock-prepend-text-property (nth 8 state) (point) 'face 'haskell-quasi-quote-face)
;; must return nil here so that it is not fontified again as string
nil)
(save-excursion
;; find the end of the QuasiQuote
(parse-partial-sexp (point) (point-max) nil nil state
'syntax-table)
(haskell-font-lock-fontify-block lang-mode (1+ (nth 8 state)) (1- (point)))
;; must return nil here so that it is not fontified again as string
nil)
;; fontify normally as string because lang-mode is not present
'(haskell-quasi-quote-face font-lock-string-face)))
'haskell-quasi-quote-face))
'font-lock-string-face))
;; Else comment. If it's from syntax table, use default face.
((or (eq 'syntax-table (nth 7 state))
Expand Down
32 changes: 16 additions & 16 deletions tests/haskell-font-lock-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ if all of its characters have syntax and face. See
(check-properties
'("[qq| \\|] Cons")
'(("qq" "w" nil)
("\\" "." (haskell-quasi-quote-face font-lock-string-face))
("\\" "." haskell-quasi-quote-face)
("Cons" "w" haskell-constructor-face))))

(ert-deftest haskell-syntactic-quasiquote-three-punctuation ()
"Check string escape vs comment escape"
(check-properties
'("[qq| %\\|] Cons")
'(("qq" "w" nil)
("%\\" "." (haskell-quasi-quote-face font-lock-string-face))
("%\\" "." haskell-quasi-quote-face)
("Cons" "w" haskell-constructor-face))))

(ert-deftest haskell-syntactic-test-11a ()
Expand Down Expand Up @@ -360,9 +360,9 @@ if all of its characters have syntax and face. See
(check-properties
'("v = [quoter| string |] Cons")
'(("[" t nil)
("|" t (haskell-quasi-quote-face font-lock-string-face))
("string" t (haskell-quasi-quote-face font-lock-string-face))
("|" t (haskell-quasi-quote-face font-lock-string-face))
("|" t haskell-quasi-quote-face)
("string" t haskell-quasi-quote-face)
("|" t haskell-quasi-quote-face)
("]" t nil)
("Cons" "w" haskell-constructor-face))))

Expand All @@ -374,10 +374,10 @@ if all of its characters have syntax and face. See
" finishing line"
"|] Cons")
'(("[" t nil)
("|" t (haskell-quasi-quote-face font-lock-string-face))
("string" t (haskell-quasi-quote-face font-lock-string-face))
("line" t (haskell-quasi-quote-face font-lock-string-face))
("|" t (haskell-quasi-quote-face font-lock-string-face))
("|" t haskell-quasi-quote-face)
("string" t haskell-quasi-quote-face)
("line" t haskell-quasi-quote-face)
("|" t haskell-quasi-quote-face)
("]" t nil)
("Cons" "w" haskell-constructor-face))))

Expand All @@ -386,10 +386,10 @@ if all of its characters have syntax and face. See
(check-properties
'("v = [quoter| [inner| string {- -- |] Outside |]")
'(("[" t nil)
("|" t (haskell-quasi-quote-face font-lock-string-face))
("inner" t (haskell-quasi-quote-face font-lock-string-face))
("string" t (haskell-quasi-quote-face font-lock-string-face))
("|" t (haskell-quasi-quote-face font-lock-string-face))
("|" t haskell-quasi-quote-face)
("inner" t haskell-quasi-quote-face)
("string" t haskell-quasi-quote-face)
("|" t haskell-quasi-quote-face)
("]" t nil)
("Outside" "w" haskell-constructor-face)
)))
Expand All @@ -401,8 +401,8 @@ if all of its characters have syntax and face. See
" [inner| string {- -- |] Outside1 |] Outside2")
'(("quoter" t font-lock-comment-face)
("inner" t nil)
("string" t (haskell-quasi-quote-face font-lock-string-face))
("|" t (haskell-quasi-quote-face font-lock-string-face))
("string" t haskell-quasi-quote-face)
("|" t haskell-quasi-quote-face)
("]" t nil)
("Outside1" "w" haskell-constructor-face)
("Outside2" "w" haskell-constructor-face)
Expand All @@ -422,7 +422,7 @@ if all of its characters have syntax and face. See
("Cons_t" t haskell-constructor-face)
("Cons_d" t haskell-constructor-face)
("Cons_p" t haskell-constructor-face)
("Cons_x" t (haskell-quasi-quote-face font-lock-string-face)))))
("Cons_x" t haskell-quasi-quote-face))))

(ert-deftest haskell-syntactic-test-special-not-redefined ()
"QuasiQuote should not conflict with TemplateHaskell"
Expand Down