Rewrite code to use 'define-derived-mode'.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 20 Dec 2011 22:11:20 +0200
changeset 848 8125f4d8b6d4
parent 847 d38ced086516
child 849 c34dc5f47510
Rewrite code to use 'define-derived-mode'.
dict-mode.el
--- a/dict-mode.el	Tue Dec 20 21:45:23 2011 +0200
+++ b/dict-mode.el	Tue Dec 20 22:11:20 2011 +0200
@@ -19,26 +19,26 @@
 (setq dict-c5-mode-map (make-sparse-keymap))
 ;; (define-key dict-c5-mode-map (kbd "RET") 'my-xxx)
 
-(require 'generic-x)
+(defvar dict-c5-font-lock-keywords
+;; (setq dict-c5-font-lock-keywords
+      '(
+        ("^\\(_\\{5,\\}\\)\n\n\\(\\w[^\n]*\\)$"
+         (1 font-lock-function-name-face) (2 font-lock-keyword-face))
+        ("\\[[^]]+]" . font-lock-type-face)
+        ))
 
 ;;;###autoload
-(define-generic-mode
-  'dict-c5-mode
-  nil
-  nil
-  '(
-    ("^\\(_\\{5,\\}\\)\n\n\\([^[:blank:]][^\n]*\\)$"
-     (1 font-lock-function-name-face) (2 font-lock-keyword-face))
-    ("\\[[^]]+]" . font-lock-type-face)
-    )
-  '("\\.dict-c5$")
-  (list
-   (lambda nil
-     (use-local-map dict-c5-mode-map)
-     (modify-syntax-entry ?' ".")
-     (modify-syntax-entry ?\" ".")
-     (setq font-lock-multiline t)
-     ))
+(define-derived-mode dict-c5-mode fundamental-mode "Dict-c5"
+  "Derived mode for editing C5 dictd source file."
+  (add-to-list 'auto-mode-alist (cons "\\.dict-c5$" 'dict-c5-mode))
+  (setq font-lock-defaults
+        '(dict-c5-font-lock-keywords
+          t nil nil nil
+          (font-lock-multiline . t)
+          ))
+  (use-local-map dict-c5-mode-map)
+  (modify-syntax-entry ?' ".")
+  (modify-syntax-entry ?\" ".")
   )
 
 ;;; dict-mode.el ends here