Skip to content

Commit e8f0973

Browse files
committed
Merge pull request #583 from gracjan/pr-use-faces-directly
Use faces directly.
2 parents 5325fcf + 772de91 commit e8f0973

File tree

1 file changed

+41
-50
lines changed

1 file changed

+41
-50
lines changed

haskell-font-lock.el

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -86,56 +86,47 @@ This is the case if the \".\" is part of a \"forall <tvar> . <type>\"."
8686
(line-beginning-position) t)))
8787

8888
(defface haskell-keyword-face
89-
'((t :inherit font-lock-keyword-face))
89+
'((t :inherit 'font-lock-keyword-face))
9090
"Face used to highlight Haskell keywords."
9191
:group 'haskell)
9292

9393
(defface haskell-constructor-face
94-
'((t :inherit font-lock-type-face))
94+
'((t :inherit 'font-lock-type-face))
9595
"Face used to highlight Haskell constructors."
9696
:group 'haskell)
9797

9898
;; This used to be `font-lock-variable-name-face' but it doesn't result in
9999
;; a highlighting that's consistent with other modes (it's mostly used
100100
;; for function defintions).
101101
(defface haskell-definition-face
102-
'((t :inherit font-lock-function-name-face))
102+
'((t :inherit 'font-lock-function-name-face))
103103
"Face used to highlight Haskell definitions."
104104
:group 'haskell)
105105

106106
;; This is probably just wrong, but it used to use
107107
;; `font-lock-function-name-face' with a result that was not consistent with
108108
;; other major modes, so I just exchanged with `haskell-definition-face'.
109109
(defface haskell-operator-face
110-
'((t :inherit font-lock-variable-name-face))
110+
'((t :inherit 'font-lock-variable-name-face))
111111
"Face used to highlight Haskell operators."
112112
:group 'haskell)
113113

114114
(defface haskell-pragma-face
115-
'((t :inherit font-lock-preprocessor-face))
115+
'((t :inherit 'font-lock-preprocessor-face))
116116
"Face used to highlight Haskell pragmas."
117117
:group 'haskell)
118118

119119
(defface haskell-default-face
120-
'((t :inherit default))
120+
'((t :inherit 'default))
121121
"Face used to highlight ordinary Haskell code."
122122
:group 'haskell)
123123

124124
(defface haskell-literate-comment-face
125-
'((t :inherit font-lock-doc-face))
125+
'((t :inherit 'font-lock-doc-face))
126126
"Face with which to fontify literate comments.
127127
Inherit from `default' to avoid fontification of them."
128128
:group 'haskell)
129129

130-
;; These variables exist only for backward compatibility.
131-
(defvar haskell-keyword-face 'haskell-keyword-face)
132-
(defvar haskell-constructor-face 'haskell-constructor-face)
133-
(defvar haskell-definition-face 'haskell-definition-face)
134-
(defvar haskell-operator-face 'haskell-operator-face)
135-
(defvar haskell-pragma-face 'haskell-pragma-face)
136-
(defvar haskell-default-face 'haskell-default-face)
137-
(defvar haskell-literate-comment-face 'haskell-literate-comment-face)
138-
139130
(defun haskell-font-lock-compose-symbol (alist)
140131
"Compose a sequence of ascii chars into a symbol.
141132
Regexp match data 0 points to the chars."
@@ -234,55 +225,55 @@ Returns keywords suitable for `font-lock-keywords'."
234225

235226
,@(haskell-font-lock-symbols-keywords)
236227

237-
(,reservedid 1 haskell-keyword-face)
228+
(,reservedid 1 'haskell-keyword-face)
238229

239230
;; Special case for `as', `hiding', `safe' and `qualified', which are
240231
;; keywords in import statements but are not otherwise reserved.
241232
("\\<import[ \t]+\\(?:\\(safe\\>\\)[ \t]*\\)?\\(?:\\(qualified\\>\\)[ \t]*\\)?\\(?:\"[^\"]*\"[\t ]*\\)?[^ \t\n()]+[ \t]*\\(?:\\(\\<as\\>\\)[ \t]*[^ \t\n()]+[ \t]*\\)?\\(\\<hiding\\>\\)?"
242-
(1 haskell-keyword-face nil lax)
243-
(2 haskell-keyword-face nil lax)
244-
(3 haskell-keyword-face nil lax)
245-
(4 haskell-keyword-face nil lax))
233+
(1 'haskell-keyword-face nil lax)
234+
(2 'haskell-keyword-face nil lax)
235+
(3 'haskell-keyword-face nil lax)
236+
(4 'haskell-keyword-face nil lax))
246237

247238
;; Special case for `foreign import'
248239
;; keywords in foreign import statements but are not otherwise reserved.
249240
("\\<\\(foreign\\)[ \t]+\\(import\\)[ \t]+\\(?:\\(ccall\\|stdcall\\|cplusplus\\|jvm\\|dotnet\\)[ \t]+\\)?\\(?:\\(safe\\|unsafe\\|interruptible\\)[ \t]+\\)?"
250-
(1 haskell-keyword-face nil lax)
251-
(2 haskell-keyword-face nil lax)
252-
(3 haskell-keyword-face nil lax)
253-
(4 haskell-keyword-face nil lax))
241+
(1 'haskell-keyword-face nil lax)
242+
(2 'haskell-keyword-face nil lax)
243+
(3 'haskell-keyword-face nil lax)
244+
(4 'haskell-keyword-face nil lax))
254245

255246
;; Special case for `foreign export'
256247
;; keywords in foreign export statements but are not otherwise reserved.
257248
("\\<\\(foreign\\)[ \t]+\\(export\\)[ \t]+\\(?:\\(ccall\\|stdcall\\|cplusplus\\|jvm\\|dotnet\\)[ \t]+\\)?"
258-
(1 haskell-keyword-face nil lax)
259-
(2 haskell-keyword-face nil lax)
260-
(3 haskell-keyword-face nil lax))
249+
(1 'haskell-keyword-face nil lax)
250+
(2 'haskell-keyword-face nil lax)
251+
(3 'haskell-keyword-face nil lax))
261252

262253
;; Toplevel Declarations.
263254
;; Place them *before* generic id-and-op highlighting.
264-
(,topdecl-var (1 haskell-definition-face))
265-
(,topdecl-var2 (2 haskell-definition-face))
266-
(,topdecl-bangpat (1 haskell-definition-face))
267-
(,topdecl-sym (2 haskell-definition-face))
268-
(,topdecl-sym2 (1 haskell-definition-face))
255+
(,topdecl-var (1 'haskell-definition-face))
256+
(,topdecl-var2 (2 'haskell-definition-face))
257+
(,topdecl-bangpat (1 'haskell-definition-face))
258+
(,topdecl-sym (2 'haskell-definition-face))
259+
(,topdecl-sym2 (1 'haskell-definition-face))
269260

270261
;; These four are debatable...
271-
("(\\(,*\\|->\\))" 0 haskell-constructor-face)
272-
("\\[\\]" 0 haskell-constructor-face)
262+
("(\\(,*\\|->\\))" 0 'haskell-constructor-face)
263+
("\\[\\]" 0 'haskell-constructor-face)
273264

274-
(,(concat "`" varid "`") 0 haskell-operator-face)
275-
(,(concat "`" conid "`") 0 haskell-operator-face)
276-
(,(concat "`" qvarid "`") 0 haskell-operator-face)
277-
(,(concat "`" qconid "`") 0 haskell-operator-face)
278-
(,qvarid 0 haskell-default-face)
279-
(,qconid 0 haskell-constructor-face)
265+
(,(concat "`" varid "`") 0 'haskell-operator-face)
266+
(,(concat "`" conid "`") 0 'haskell-operator-face)
267+
(,(concat "`" qvarid "`") 0 'haskell-operator-face)
268+
(,(concat "`" qconid "`") 0 'haskell-operator-face)
269+
(,qvarid 0 'haskell-default-face)
270+
(,qconid 0 'haskell-constructor-face)
280271

281-
(,conid 0 haskell-constructor-face)
272+
(,conid 0 'haskell-constructor-face)
282273

283274
(,sym 0 (if (eq (char-after (match-beginning 0)) ?:)
284-
haskell-constructor-face
285-
haskell-operator-face))))
275+
'haskell-constructor-face
276+
'haskell-operator-face))))
286277
keywords))
287278

288279
(defvar haskell-font-lock-latex-cache-pos nil
@@ -382,12 +373,12 @@ that should be commented under LaTeX-style literate scripts."
382373
(defun haskell-syntactic-face-function (state)
383374
"`font-lock-syntactic-face-function' for Haskell."
384375
(cond
385-
((nth 3 state) font-lock-string-face) ; as normal
376+
((nth 3 state) 'font-lock-string-face) ; as normal
386377
;; Else comment. If it's from syntax table, use default face.
387378
((or (eq 'syntax-table (nth 7 state))
388379
(and (eq haskell-literate 'bird)
389380
(memq (char-before (nth 8 state)) '(nil ?\n))))
390-
haskell-literate-comment-face)
381+
'haskell-literate-comment-face)
391382
;; Detect pragmas. A pragma is enclosed in special comment
392383
;; delimeters {-# .. #-}.
393384
((save-excursion
@@ -396,7 +387,7 @@ that should be commented under LaTeX-style literate scripts."
396387
(forward-comment 1)
397388
(goto-char (- (point) 3))
398389
(looking-at-p "#-}")))
399-
haskell-pragma-face)
390+
'haskell-pragma-face)
400391
;; Haddock comment start with either "-- [|^*$]" or "{- ?[|^*$]"
401392
;; (note space optional for nested comments and mandatory for
402393
;; double dash comments).
@@ -415,12 +406,12 @@ that should be commented under LaTeX-style literate scripts."
415406
(and (looking-at-p "--") ; are we at double dash comment
416407
(forward-line -1) ; this is nil on first line
417408
(eq (get-text-property (line-end-position) 'face)
418-
font-lock-doc-face) ; is a doc face
409+
'font-lock-doc-face) ; is a doc face
419410
(forward-line)
420411
(skip-syntax-forward "-") ; see if there is only whitespace
421412
(eq (point) (nth 8 state))))) ; we are back in position
422-
font-lock-doc-face)
423-
(t font-lock-comment-face)))
413+
'font-lock-doc-face)
414+
(t 'font-lock-comment-face)))
424415

425416
(defconst haskell-font-lock-keywords
426417
(haskell-font-lock-keywords-create nil)

0 commit comments

Comments
 (0)