From 387a891f5237b6385bb07724673f93a76487bf95 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Sat, 24 Jan 2015 13:00:54 +0100 Subject: [PATCH 1/3] Remove old rusty emacs21 stuff. --- haskell-font-lock.el | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index 0b4efc373..1c51ce384 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -217,10 +217,6 @@ Inherit from `default' to avoid fontification of them." (defvar haskell-default-face 'haskell-default-face) (defvar haskell-literate-comment-face 'haskell-literate-comment-face) -(defconst haskell-emacs21-features (string-match "[[:alpha:]]" "x") - "Non-nil if we have regexp char classes. -Assume this means we have other useful features from Emacs 21.") - (defun haskell-font-lock-compose-symbol (alist) "Compose a sequence of ascii chars into a symbol. Regexp match data 0 points to the chars." @@ -379,15 +375,7 @@ Returns keywords suitable for `font-lock-keywords'." ("^=======" 0 'font-lock-warning-face t) ("^>>>>>>> .*$" 0 'font-lock-warning-face t) ("^#.*$" 0 'font-lock-preprocessor-face t) - ,@(unless haskell-emacs21-features ;Supports nested comments? - ;; Expensive. - `((,string-and-char 1 font-lock-string-face))) - - ;; This was originally at the very end (and needs to be after - ;; all the comment/string/doc highlighting) but it seemed to - ;; trigger a bug in Emacs-21.3 which caused the compositions to - ;; be "randomly" dropped. Moving it earlier seemed to reduce - ;; the occurrence of the bug. + ,@(haskell-font-lock-symbols-keywords) (,reservedid 1 haskell-keyword-face) @@ -457,8 +445,6 @@ Returns keywords suitable for `font-lock-keywords'." ,@keywords))))) keywords)) -;; The next three aren't used in Emacs 21. - (defvar haskell-fl-latex-cache-pos nil "Position of cache point used by `haskell-fl-latex-cache-in-comment'. Should be at the start of a line.") From 06e0eeb5d06fda080f604316fa0dda9c4211b5a4 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Sat, 24 Jan 2015 13:12:58 +0100 Subject: [PATCH 2/3] Rename haskell-fl-latex to haskell-font-lock-latex. Rename haskell-fl-latex-* to haskell-font-lock-latex-* to make naming more sane. --- haskell-font-lock.el | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index 1c51ce384..f78dcb9a0 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -441,35 +441,35 @@ Returns keywords suitable for `font-lock-keywords'." ("^>" 0 haskell-default-face t)))) ((latex tex) (setq keywords - `((haskell-fl-latex-comments 0 'font-lock-comment-face t) + `((haskell-font-lock-latex-comments 0 'font-lock-comment-face t) ,@keywords))))) keywords)) -(defvar haskell-fl-latex-cache-pos nil - "Position of cache point used by `haskell-fl-latex-cache-in-comment'. +(defvar haskell-font-lock-latex-cache-pos nil + "Position of cache point used by `haskell-font-lock-latex-cache-in-comment'. Should be at the start of a line.") -(defvar haskell-fl-latex-cache-in-comment nil - "If `haskell-fl-latex-cache-pos' is outside a +(defvar haskell-font-lock-latex-cache-in-comment nil + "If `haskell-font-lock-latex-cache-pos' is outside a \\begin{code}..\\end{code} block (and therefore inside a comment), this variable is set to t, otherwise nil.") -(defun haskell-fl-latex-comments (end) +(defun haskell-font-lock-latex-comments (end) "Sets `match-data' according to the region of the buffer before end that should be commented under LaTeX-style literate scripts." (let ((start (point))) (if (= start end) ;; We're at the end. No more to fontify. nil - (if (not (eq start haskell-fl-latex-cache-pos)) + (if (not (eq start haskell-font-lock-latex-cache-pos)) ;; If the start position is not cached, calculate the state ;; of the start. (progn - (setq haskell-fl-latex-cache-pos start) + (setq haskell-font-lock-latex-cache-pos start) ;; If the previous \begin{code} or \end{code} is a ;; \begin{code}, then start is not in a comment, otherwise ;; it is in a comment. - (setq haskell-fl-latex-cache-in-comment + (setq haskell-font-lock-latex-cache-in-comment (if (and (re-search-backward "^\\(\\(\\\\begin{code}\\)\\|\\(\\\\end{code}\\)\\)$" @@ -478,7 +478,7 @@ that should be commented under LaTeX-style literate scripts." nil t)) ;; Restore position. (goto-char start))) - (if haskell-fl-latex-cache-in-comment + (if haskell-font-lock-latex-cache-in-comment (progn ;; If start is inside a comment, search for next \begin{code}. (re-search-forward "^\\\\begin{code}$" end 'move) From 590e1e2cbac3cd5b8ab02c6f7f4eb843c19bc81f Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Sat, 24 Jan 2015 13:15:31 +0100 Subject: [PATCH 3/3] Mark haskell-font-lock-latex-cache as buffer-local. Mark haskell-font-lock-latex-cache-pos and haskell-font-lock-latex-cache-in-comment as buffer local. Otherwise editing two latex files at the same time would result in confusing results. --- haskell-font-lock.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index f78dcb9a0..adc724b20 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -448,11 +448,13 @@ Returns keywords suitable for `font-lock-keywords'." (defvar haskell-font-lock-latex-cache-pos nil "Position of cache point used by `haskell-font-lock-latex-cache-in-comment'. Should be at the start of a line.") +(make-variable-buffer-local 'haskell-font-lock-latex-cache-pos) (defvar haskell-font-lock-latex-cache-in-comment nil "If `haskell-font-lock-latex-cache-pos' is outside a \\begin{code}..\\end{code} block (and therefore inside a comment), this variable is set to t, otherwise nil.") +(make-variable-buffer-local 'haskell-font-lock-latex-cache-in-comment) (defun haskell-font-lock-latex-comments (end) "Sets `match-data' according to the region of the buffer before end