From 739c209fe77a76e82e8a3e52f61cacbaa5cc7d57 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Thu, 16 Apr 2015 16:35:09 +0200 Subject: [PATCH 1/5] Font lock: remove unused string-and-char. --- haskell-font-lock.el | 9 --------- 1 file changed, 9 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index 417937807..9a476dde6 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -227,15 +227,6 @@ Returns keywords suitable for `font-lock-keywords'." "\\(_\\|c\\(ase\\|lass\\)\\|d\\(ata\\|e\\(fault\\|riving\\)\\|o\\)\\|else\\|i\\(mport\\|n\\(fix[lr]?\\|stance\\)\\|[fn]\\)\\|let\\|module\\|mdo\\|newtype\\|of\\|rec\\|proc\\|t\\(hen\\|ype\\)\\|where\\)" "\\>")) - ;; This unreadable regexp matches strings and character - ;; constants. We need to do this with one regexp to handle - ;; stuff like '"':"'". The regexp is the composition of - ;; "([^"\\]|\\.)*" for strings and '([^\\]|\\.[^']*)' for - ;; characters, allowing for string continuations. - ;; Could probably be improved... - (string-and-char - (concat "\\(\\(\"\\|" line-prefix "[ \t]*\\\\\\)\\([^\"\\\\\n]\\|\\\\.\\)*\\(\"\\|\\\\[ \t]*$\\)\\|'\\([^'\\\\\n]\\|\\\\.[^'\n]*\\)'\\)")) - ;; Top-level declarations (topdecl-var (concat line-prefix "\\(" varid "\\(?:\\s-*,\\s-*" varid "\\)*" "\\)\\s-*" From 6c7dbc3121c4bddd28ced6d6ebe3b3b579e5dead Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Thu, 16 Apr 2015 16:37:17 +0200 Subject: [PATCH 2/5] Font lock: remove redundant reservedsym. The 'reservedsym` gets operator face just like any sym, so do not special case it. --- haskell-font-lock.el | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index 9a476dde6..c6f6818a5 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -206,13 +206,6 @@ Returns keywords suitable for `font-lock-keywords'." ;; be thrown for some reason by backslash's escape syntax. "\\(\\s.\\|\\\\\\)+") - ;; Reserved operations - (reservedsym - (concat "\\S." - ;; (regexp-opt '(".." "::" "=" "\\" "|" "<-" "->" - ;; "@" "~" "=>") t) - "\\(->\\|→\\|\\.\\.\\|::\\|∷\\|<-\\|←\\|=>\\|[=@\\|~]\\)" - "\\S.")) ;; Reserved identifiers (reservedid (concat "\\<" @@ -256,7 +249,7 @@ Returns keywords suitable for `font-lock-keywords'." ,@(haskell-font-lock-symbols-keywords) (,reservedid 1 haskell-keyword-face) - (,reservedsym 1 haskell-operator-face) + ;; Special case for `as', `hiding', `safe' and `qualified', which are ;; keywords in import statements but are not otherwise reserved. ("\\\\)[ \t]*\\)?\\(?:\\(qualified\\>\\)[ \t]*\\)?\\(?:\"[^\"]*\"[\t ]*\\)?[^ \t\n()]+[ \t]*\\(?:\\(\\\\)[ \t]*[^ \t\n()]+[ \t]*\\)?\\(\\\\)?" @@ -265,7 +258,6 @@ Returns keywords suitable for `font-lock-keywords'." (3 haskell-keyword-face nil lax) (4 haskell-keyword-face nil lax)) - (,reservedsym 1 haskell-operator-face) ;; Special case for `foreign import' ;; keywords in foreign import statements but are not otherwise reserved. ("\\<\\(foreign\\)[ \t]+\\(import\\)[ \t]+\\(?:\\(ccall\\|stdcall\\|cplusplus\\|jvm\\|dotnet\\)[ \t]+\\)?\\(?:\\(safe\\|unsafe\\|interruptible\\)[ \t]+\\)?" @@ -274,7 +266,6 @@ Returns keywords suitable for `font-lock-keywords'." (3 haskell-keyword-face nil lax) (4 haskell-keyword-face nil lax)) - (,reservedsym 1 haskell-operator-face) ;; Special case for `foreign export' ;; keywords in foreign export statements but are not otherwise reserved. ("\\<\\(foreign\\)[ \t]+\\(export\\)[ \t]+\\(?:\\(ccall\\|stdcall\\|cplusplus\\|jvm\\|dotnet\\)[ \t]+\\)?" From c9d96860287fc1e87ec829fbd9a3ed333ae4fa54 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Thu, 16 Apr 2015 16:45:50 +0200 Subject: [PATCH 3/5] Font lock: use punctuation class of backslash. --- haskell-font-lock.el | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index c6f6818a5..aa627fcb2 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -198,13 +198,7 @@ Returns keywords suitable for `font-lock-keywords'." (modid (concat "\\b" conid "\\(\\." conid "\\)*\\b")) (qvarid (concat modid "\\." varid)) (qconid (concat modid "\\." conid)) - (sym - ;; We used to use the below for non-Emacs21, but I think the - ;; regexp based on syntax works for other emacsen as well. -- Stef - ;; (concat "[" symbol ":]+") - ;; Add backslash to the symbol-syntax chars. This seems to - ;; be thrown for some reason by backslash's escape syntax. - "\\(\\s.\\|\\\\\\)+") + (sym "\\s.+") ;; Reserved identifiers (reservedid From a4b84279b0d7508e50542bf0e9efa3540864a1e8 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Thu, 16 Apr 2015 16:48:12 +0200 Subject: [PATCH 4/5] Font lock: remove confusing comments. --- haskell-font-lock.el | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index aa627fcb2..833069e5f 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -183,15 +183,6 @@ Returns keywords suitable for `font-lock-keywords'." ;; "^>", otherwise a line of code starts with "^". (line-prefix (if (eq literate 'bird) "^> ?" "^")) - ;; Most names are borrowed from the lexical syntax of the Haskell - ;; report. - ;; Some of these definitions have been superseded by using the - ;; syntax table instead. - - ;; (ASCsymbol "-!#$%&*+./<=>?@\\\\^|~") - ;; Put the minus first to make it work in ranges. - - ;; We allow _ as the first char to fit GHC (varid "\\b[[:lower:]_][[:alnum:]'_]*\\b") ;; We allow ' preceding conids because of DataKinds/PolyKinds (conid "\\b'?[[:upper:]][[:alnum:]'_]*\\b") @@ -278,17 +269,16 @@ Returns keywords suitable for `font-lock-keywords'." ;; These four are debatable... ("(\\(,*\\|->\\))" 0 haskell-constructor-face) ("\\[\\]" 0 haskell-constructor-face) - ;; Expensive. + (,(concat "`" varid "`") 0 haskell-operator-face) (,(concat "`" conid "`") 0 haskell-operator-face) (,(concat "`" qvarid "`") 0 haskell-operator-face) (,(concat "`" qconid "`") 0 haskell-operator-face) (,qvarid 0 haskell-default-face) (,qconid 0 haskell-constructor-face) - ;; Expensive. + (,conid 0 haskell-constructor-face) - ;; Very expensive. (,sym 0 (if (eq (char-after (match-beginning 0)) ?:) haskell-constructor-face haskell-operator-face)))) From edb29fefa80ec75904b0a1e577b86c26bdb89a09 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Thu, 16 Apr 2015 17:00:52 +0200 Subject: [PATCH 5/5] Font lock: font-lock-syntactic-keywords is always defined. --- haskell-font-lock.el | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/haskell-font-lock.el b/haskell-font-lock.el index 833069e5f..5932bc38f 100644 --- a/haskell-font-lock.el +++ b/haskell-font-lock.el @@ -282,17 +282,6 @@ Returns keywords suitable for `font-lock-keywords'." (,sym 0 (if (eq (char-after (match-beginning 0)) ?:) haskell-constructor-face haskell-operator-face)))) - (unless (boundp 'font-lock-syntactic-keywords) - (cl-case literate - (bird - (setq keywords - `(("^[^>\n].*$" 0 haskell-comment-face t) - ,@keywords - ("^>" 0 haskell-default-face t)))) - ((latex tex) - (setq keywords - `((haskell-font-lock-latex-comments 0 'font-lock-comment-face t) - ,@keywords))))) keywords)) (defvar haskell-font-lock-latex-cache-pos nil