Skip to content

Commit b71b3c8

Browse files
committed
Merge pull request #1061 from gracjan/pr-string-qq
Use plain string face for quasi quotes
2 parents a7653e3 + 1186820 commit b71b3c8

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

haskell-font-lock.el

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,10 @@ Inherit from `default' to avoid fontification of them."
153153
:group 'haskell)
154154

155155
(defface haskell-quasi-quote-face
156-
'((((background light)) :background "gray90")
157-
(((background dark)) :background "gray10")
158-
(t :inherit font-lock-string-face))
159-
"Face for background with which to fontify quasi quotes that
160-
are fontified according to other mode defined in
156+
'((t :inherit font-lock-string-face))
157+
"Generic face for quasiquotes.
158+
159+
Some quote types are fontified according to other mode defined in
161160
`haskell-font-lock-quasi-quote-modes'."
162161
:group 'haskell)
163162

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

443442
(if (and lang-mode
444443
(fboundp lang-mode))
445-
(save-excursion
446-
;; find the end of the QuasiQuote
447-
(parse-partial-sexp (point) (point-max) nil nil state
448-
'syntax-table)
449-
(haskell-font-lock-fontify-block lang-mode (1+ (nth 8 state)) (1- (point)))
450-
(font-lock-prepend-text-property (nth 8 state) (point) 'face 'haskell-quasi-quote-face)
451-
;; must return nil here so that it is not fontified again as string
452-
nil)
444+
(save-excursion
445+
;; find the end of the QuasiQuote
446+
(parse-partial-sexp (point) (point-max) nil nil state
447+
'syntax-table)
448+
(haskell-font-lock-fontify-block lang-mode (1+ (nth 8 state)) (1- (point)))
449+
;; must return nil here so that it is not fontified again as string
450+
nil)
453451
;; fontify normally as string because lang-mode is not present
454-
'(haskell-quasi-quote-face font-lock-string-face)))
452+
'haskell-quasi-quote-face))
455453
'font-lock-string-face))
456454
;; Else comment. If it's from syntax table, use default face.
457455
((or (eq 'syntax-table (nth 7 state))

tests/haskell-font-lock-tests.el

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,15 @@ if all of its characters have syntax and face. See
250250
(check-properties
251251
'("[qq| \\|] Cons")
252252
'(("qq" "w" nil)
253-
("\\" "." (haskell-quasi-quote-face font-lock-string-face))
253+
("\\" "." haskell-quasi-quote-face)
254254
("Cons" "w" haskell-constructor-face))))
255255

256256
(ert-deftest haskell-syntactic-quasiquote-three-punctuation ()
257257
"Check string escape vs comment escape"
258258
(check-properties
259259
'("[qq| %\\|] Cons")
260260
'(("qq" "w" nil)
261-
("%\\" "." (haskell-quasi-quote-face font-lock-string-face))
261+
("%\\" "." haskell-quasi-quote-face)
262262
("Cons" "w" haskell-constructor-face))))
263263

264264
(ert-deftest haskell-syntactic-test-11a ()
@@ -360,9 +360,9 @@ if all of its characters have syntax and face. See
360360
(check-properties
361361
'("v = [quoter| string |] Cons")
362362
'(("[" t nil)
363-
("|" t (haskell-quasi-quote-face font-lock-string-face))
364-
("string" t (haskell-quasi-quote-face font-lock-string-face))
365-
("|" t (haskell-quasi-quote-face font-lock-string-face))
363+
("|" t haskell-quasi-quote-face)
364+
("string" t haskell-quasi-quote-face)
365+
("|" t haskell-quasi-quote-face)
366366
("]" t nil)
367367
("Cons" "w" haskell-constructor-face))))
368368

@@ -374,10 +374,10 @@ if all of its characters have syntax and face. See
374374
" finishing line"
375375
"|] Cons")
376376
'(("[" t nil)
377-
("|" t (haskell-quasi-quote-face font-lock-string-face))
378-
("string" t (haskell-quasi-quote-face font-lock-string-face))
379-
("line" t (haskell-quasi-quote-face font-lock-string-face))
380-
("|" t (haskell-quasi-quote-face font-lock-string-face))
377+
("|" t haskell-quasi-quote-face)
378+
("string" t haskell-quasi-quote-face)
379+
("line" t haskell-quasi-quote-face)
380+
("|" t haskell-quasi-quote-face)
381381
("]" t nil)
382382
("Cons" "w" haskell-constructor-face))))
383383

@@ -386,10 +386,10 @@ if all of its characters have syntax and face. See
386386
(check-properties
387387
'("v = [quoter| [inner| string {- -- |] Outside |]")
388388
'(("[" t nil)
389-
("|" t (haskell-quasi-quote-face font-lock-string-face))
390-
("inner" t (haskell-quasi-quote-face font-lock-string-face))
391-
("string" t (haskell-quasi-quote-face font-lock-string-face))
392-
("|" t (haskell-quasi-quote-face font-lock-string-face))
389+
("|" t haskell-quasi-quote-face)
390+
("inner" t haskell-quasi-quote-face)
391+
("string" t haskell-quasi-quote-face)
392+
("|" t haskell-quasi-quote-face)
393393
("]" t nil)
394394
("Outside" "w" haskell-constructor-face)
395395
)))
@@ -401,8 +401,8 @@ if all of its characters have syntax and face. See
401401
" [inner| string {- -- |] Outside1 |] Outside2")
402402
'(("quoter" t font-lock-comment-face)
403403
("inner" t nil)
404-
("string" t (haskell-quasi-quote-face font-lock-string-face))
405-
("|" t (haskell-quasi-quote-face font-lock-string-face))
404+
("string" t haskell-quasi-quote-face)
405+
("|" t haskell-quasi-quote-face)
406406
("]" t nil)
407407
("Outside1" "w" haskell-constructor-face)
408408
("Outside2" "w" haskell-constructor-face)
@@ -422,7 +422,7 @@ if all of its characters have syntax and face. See
422422
("Cons_t" t haskell-constructor-face)
423423
("Cons_d" t haskell-constructor-face)
424424
("Cons_p" t haskell-constructor-face)
425-
("Cons_x" t (haskell-quasi-quote-face font-lock-string-face)))))
425+
("Cons_x" t haskell-quasi-quote-face))))
426426

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

0 commit comments

Comments
 (0)