From 18a3cd7657beee460b1fef17a532a767bcc5e471 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 31 May 2010 21:45:53 +0100 Subject: [PATCH] Stop using generic-mode. Highlight comments manually. --- rebase-mode.el | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/rebase-mode.el b/rebase-mode.el index f1b74295..d4d2ef60 100644 --- a/rebase-mode.el +++ b/rebase-mode.el @@ -40,11 +40,12 @@ line-end) "Regexp that matches an action line in a rebase buffer.") -(defvar rebase-font-lock-keywords +(defvar rebase-mode-font-lock-keywords (list (list rebase-mode-action-line-re '(1 font-lock-keyword-face) - '(2 font-lock-builtin-face))) + '(2 font-lock-builtin-face)) + (list (rx line-start (char "#") (* not-newline)) 0 font-lock-comment-face)) "Font lock keywords for rebase-mode.") (defvar key-to-action-map @@ -104,11 +105,6 @@ that of CHANGE-TO." (goto-char (point-at-bol)) (looking-at rebase-mode-action-line-re))) -(defun rebase-mode-setup () - "Function run when initialising rebase-mode." - (setq buffer-read-only t) - (use-local-map rebase-mode-map)) - (defun rebase-mode-move-line-up () "Move the current action line up." (interactive) @@ -159,13 +155,16 @@ server connection)." (text (apply 'buffer-substring region))) (apply 'kill-region region)))) -(define-generic-mode 'rebase-mode - '("#") - nil - rebase-font-lock-keywords - '("git-rebase-todo") - '(rebase-mode-setup) - "Major mode for interactively editing git rebase files. -\\{rebase-mode-map}") +(defun rebase-mode () + (interactive) + (kill-all-local-variables) + + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults + '(rebase-mode-font-lock-keywords t t nil nil)) + + (use-local-map rebase-mode-map) + (setq buffer-read-only t) + (setq mode-name "rebase-mode" major-mode 'rebase-mode)) (provide 'rebase-mode)