Skip to content

Commit ce64899

Browse files
committed
Merge pull request #451 from gracjan/pr-font-lock-1
Pr font lock 1
2 parents 2b90202 + 590e1e2 commit ce64899

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

haskell-font-lock.el

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ Inherit from `default' to avoid fontification of them."
217217
(defvar haskell-default-face 'haskell-default-face)
218218
(defvar haskell-literate-comment-face 'haskell-literate-comment-face)
219219

220-
(defconst haskell-emacs21-features (string-match "[[:alpha:]]" "x")
221-
"Non-nil if we have regexp char classes.
222-
Assume this means we have other useful features from Emacs 21.")
223-
224220
(defun haskell-font-lock-compose-symbol (alist)
225221
"Compose a sequence of ascii chars into a symbol.
226222
Regexp match data 0 points to the chars."
@@ -379,15 +375,7 @@ Returns keywords suitable for `font-lock-keywords'."
379375
("^=======" 0 'font-lock-warning-face t)
380376
("^>>>>>>> .*$" 0 'font-lock-warning-face t)
381377
("^#.*$" 0 'font-lock-preprocessor-face t)
382-
,@(unless haskell-emacs21-features ;Supports nested comments?
383-
;; Expensive.
384-
`((,string-and-char 1 font-lock-string-face)))
385-
386-
;; This was originally at the very end (and needs to be after
387-
;; all the comment/string/doc highlighting) but it seemed to
388-
;; trigger a bug in Emacs-21.3 which caused the compositions to
389-
;; be "randomly" dropped. Moving it earlier seemed to reduce
390-
;; the occurrence of the bug.
378+
391379
,@(haskell-font-lock-symbols-keywords)
392380

393381
(,reservedid 1 haskell-keyword-face)
@@ -453,37 +441,37 @@ Returns keywords suitable for `font-lock-keywords'."
453441
("^>" 0 haskell-default-face t))))
454442
((latex tex)
455443
(setq keywords
456-
`((haskell-fl-latex-comments 0 'font-lock-comment-face t)
444+
`((haskell-font-lock-latex-comments 0 'font-lock-comment-face t)
457445
,@keywords)))))
458446
keywords))
459447

460-
;; The next three aren't used in Emacs 21.
461-
462-
(defvar haskell-fl-latex-cache-pos nil
463-
"Position of cache point used by `haskell-fl-latex-cache-in-comment'.
448+
(defvar haskell-font-lock-latex-cache-pos nil
449+
"Position of cache point used by `haskell-font-lock-latex-cache-in-comment'.
464450
Should be at the start of a line.")
451+
(make-variable-buffer-local 'haskell-font-lock-latex-cache-pos)
465452

466-
(defvar haskell-fl-latex-cache-in-comment nil
467-
"If `haskell-fl-latex-cache-pos' is outside a
453+
(defvar haskell-font-lock-latex-cache-in-comment nil
454+
"If `haskell-font-lock-latex-cache-pos' is outside a
468455
\\begin{code}..\\end{code} block (and therefore inside a comment),
469456
this variable is set to t, otherwise nil.")
457+
(make-variable-buffer-local 'haskell-font-lock-latex-cache-in-comment)
470458

471-
(defun haskell-fl-latex-comments (end)
459+
(defun haskell-font-lock-latex-comments (end)
472460
"Sets `match-data' according to the region of the buffer before end
473461
that should be commented under LaTeX-style literate scripts."
474462
(let ((start (point)))
475463
(if (= start end)
476464
;; We're at the end. No more to fontify.
477465
nil
478-
(if (not (eq start haskell-fl-latex-cache-pos))
466+
(if (not (eq start haskell-font-lock-latex-cache-pos))
479467
;; If the start position is not cached, calculate the state
480468
;; of the start.
481469
(progn
482-
(setq haskell-fl-latex-cache-pos start)
470+
(setq haskell-font-lock-latex-cache-pos start)
483471
;; If the previous \begin{code} or \end{code} is a
484472
;; \begin{code}, then start is not in a comment, otherwise
485473
;; it is in a comment.
486-
(setq haskell-fl-latex-cache-in-comment
474+
(setq haskell-font-lock-latex-cache-in-comment
487475
(if (and
488476
(re-search-backward
489477
"^\\(\\(\\\\begin{code}\\)\\|\\(\\\\end{code}\\)\\)$"
@@ -492,7 +480,7 @@ that should be commented under LaTeX-style literate scripts."
492480
nil t))
493481
;; Restore position.
494482
(goto-char start)))
495-
(if haskell-fl-latex-cache-in-comment
483+
(if haskell-font-lock-latex-cache-in-comment
496484
(progn
497485
;; If start is inside a comment, search for next \begin{code}.
498486
(re-search-forward "^\\\\begin{code}$" end 'move)

0 commit comments

Comments
 (0)