branch: elpa/haskell-tng-mode commit 00f7d848b70cb1df54ddbdb905d5a76dd143b9b5 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
simplify names --- haskell-tng-font-lock.el | 40 ++++++++++++++++++++-------------------- haskell-tng-mode.el | 7 +++---- haskell-tng-syntax.el | 12 ++++++------ 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el index 308da8c..0d73d0f 100644 --- a/haskell-tng-font-lock.el +++ b/haskell-tng-font-lock.el @@ -18,29 +18,29 @@ ;; ;;; Code: -(defgroup haskell-tng-font-lock:faces nil +(defgroup haskell-tng:faces nil "Haskell font faces." :group 'haskell-tng) -(defface haskell-tng-font-lock:keyword +(defface haskell-tng:keyword '((t :inherit font-lock-keyword-face)) "Haskell reserved names and operators." - :group 'haskell-tng-font-lock:faces) + :group 'haskell-tng:faces) -(defface haskell-tng-font-lock:package +(defface haskell-tng:package '((t :inherit font-lock-variable-name-face :weight bold)) "Haskell packages." - :group 'haskell-tng-font-lock:faces) + :group 'haskell-tng:faces) -(defface haskell-tng-font-lock:type +(defface haskell-tng:type '((t :inherit font-lock-type-face)) "Haskell types." - :group 'haskell-tng-font-lock:faces) + :group 'haskell-tng:faces) -(defface haskell-tng-font-lock:constructor +(defface haskell-tng:constructor '((t :inherit font-lock-constant-face)) "Haskell constructors." - :group 'haskell-tng-font-lock:faces) + :group 'haskell-tng:faces) ;; TODO: types (signatures, classes and imports) ;; @@ -52,33 +52,33 @@ ;; that obfuscate the meaning, plus we could use DRY. (setq - haskell-tng-font-lock:keywords + haskell-tng:keywords `((,(regexp-opt '("case" "class" "data" "default" "deriving" "do" "else" "foreign" "if" "import" "in" "infix" "infixl" "infixr" "instance" "let" "module" "newtype" "of" "then" "type" "where" "_") 'words) - . 'haskell-tng-font-lock:keyword) ;; reservedid + . 'haskell-tng:keyword) ;; reservedid (,(regexp-opt '(".." ":" "::" "=" "|" "<-" ">" "->" "@" "~" "=>") 'symbols) - . 'haskell-tng-font-lock:keyword) ;; reservedop + . 'haskell-tng:keyword) ;; reservedop ;; lambda syntax may be followed by a trailing symbol - ("\\_<\\(\\\\\\)" . 'haskell-tng-font-lock:keyword) + ("\\_<\\(\\\\\\)" . 'haskell-tng:keyword) ;; TODO: contextual / multiline support for the import region. ;; qualified/hiding/as are keywords when used in imports - ("\\_<import\\_>[[:space:]]+\\_<\\(qualified\\)\\_>" 1 'haskell-tng-font-lock:keyword) - ("\\_<import\\_>[^(]+?\\_<\\(hiding\\|as\\)\\_>" 1 'haskell-tng-font-lock:keyword) + ("\\_<import\\_>[[:space:]]+\\_<\\(qualified\\)\\_>" 1 'haskell-tng:keyword) + ("\\_<import\\_>[^(]+?\\_<\\(hiding\\|as\\)\\_>" 1 'haskell-tng:keyword) ("\\_<import\\_>\\(?:[[:space:]]\\|qualified\\)+\\_<\\([[:upper:]]\\(?:\\.\\|\\w\\)*\\)\\_>" - 1 'haskell-tng-font-lock:package) + 1 'haskell-tng:package) ("\\_<import\\_>[^(]+?\\_<as[[:space:]]+\\([[:upper:]]\\w+\\)" - 1 'haskell-tng-font-lock:package) + 1 'haskell-tng:package) ("\\_<\\(\\(?:[[:upper:]]\\w*\\.\\)+\\)" - . 'haskell-tng-font-lock:package) ;; uses of F.Q.N.s + . 'haskell-tng:package) ;; uses of F.Q.N.s - ("\\_<\\([[:upper:]]\\w*\\)\\_>" 0 'haskell-tng-font-lock:constructor) ;; conid - ("\\_<\\(:\\s_+\\)\\_>" 0 'haskell-tng-font-lock:constructor) ;; consym + ("\\_<\\([[:upper:]]\\w*\\)\\_>" 0 'haskell-tng:constructor) ;; conid + ("\\_<\\(:\\s_+\\)\\_>" 0 'haskell-tng:constructor) ;; consym )) (provide 'haskell-tng-font-lock) diff --git a/haskell-tng-mode.el b/haskell-tng-mode.el index cf9bdee..4cd0798 100644 --- a/haskell-tng-mode.el +++ b/haskell-tng-mode.el @@ -22,7 +22,7 @@ (define-derived-mode haskell-tng-mode prog-mode "Hask" "Major mode for editing Haskell programs." :group 'haskell-tng - :syntax-table haskell-tng-syntax:table + :syntax-table haskell-tng:syntax-table ;; TODO paragraph-start, paragraph-separate, fill-paragraph-function ;; @@ -41,11 +41,10 @@ dabbrev-case-replace nil words-include-escapes t - syntax-propertize-function #'haskell-tng-syntax:propertize + syntax-propertize-function #'haskell-tng:syntax-propertize parse-sexp-lookup-properties t - font-lock-defaults '(haskell-tng-font-lock:keywords - nil nil nil) + font-lock-defaults '(haskell-tng:keywords nil nil nil) ;; whitespace is meaningful, no electric indentation electric-indent-inhibit t)) diff --git a/haskell-tng-syntax.el b/haskell-tng-syntax.el index fbb9d17..015e804 100644 --- a/haskell-tng-syntax.el +++ b/haskell-tng-syntax.el @@ -15,7 +15,7 @@ (require 'dash) -(defvar haskell-tng-syntax:table +(defvar haskell-tng:syntax-table (let ((table (make-syntax-table))) (map-char-table #'(lambda (k v) @@ -68,12 +68,12 @@ table) "Haskell syntax table.") -(defun haskell-tng-syntax:propertize (start end) +(defun haskell-tng:syntax-propertize (start end) "For some context-sensitive syntax entries." - (haskell-tng-syntax:propertize-char-delims start end) - (haskell-tng-syntax:propertize-escapes start end)) + (haskell-tng:propertize-char-delims start end) + (haskell-tng:propertize-escapes start end)) -(defun haskell-tng-syntax:propertize-char-delims (start end) +(defun haskell-tng:propertize-char-delims (start end) "Matching apostrophes are string delimiters (literal chars)." (save-excursion (goto-char start) @@ -83,7 +83,7 @@ (put-text-property open (1+ open) 'syntax-table '(7 . ?\')) (put-text-property close (1+ close) 'syntax-table '(7 . ?\')))))) -(defun haskell-tng-syntax:propertize-escapes (start end) +(defun haskell-tng:propertize-escapes (start end) "Backslash inside String is an escape character." (save-excursion (goto-char start)