From 1186820196fd2870195cfb72d06d7a31e61b1d26 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Sun, 10 Jan 2016 20:23:47 +0100 Subject: [PATCH] Use plain string face for quasi quotes --- haskell-font-lock.el | 26 ++++++++++++-------------- tests/haskell-font-lock-tests.el | 32 ++++++++++++++++---------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index 6aadff468..bcf20d3e3 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -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) @@ -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)) diff --git a/tests/haskell-font-lock-tests.el b/tests/haskell-font-lock-tests.el index 665f5f448..ccfd64075 100644 --- a/tests/haskell-font-lock-tests.el +++ b/tests/haskell-font-lock-tests.el @@ -250,7 +250,7 @@ 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 () @@ -258,7 +258,7 @@ 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-test-11a () @@ -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)))) @@ -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)))) @@ -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) ))) @@ -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) @@ -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"