From 18a3cd7657beee460b1fef17a532a767bcc5e471 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 31 May 2010 21:45:53 +0100 Subject: [PATCH 1/3] 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) From f4ef288e7787ba70f5c40da37c7542991dc7f5d2 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 31 May 2010 22:16:21 +0100 Subject: [PATCH 2/3] Repopulate `auto-mode-alist'. --- rebase-mode.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rebase-mode.el b/rebase-mode.el index d4d2ef60..76c8053c 100644 --- a/rebase-mode.el +++ b/rebase-mode.el @@ -167,4 +167,7 @@ server connection)." (setq buffer-read-only t) (setq mode-name "rebase-mode" major-mode 'rebase-mode)) +(add-to-list 'auto-mode-alist + '("git-rebase-todo" . rebase-mode)) + (provide 'rebase-mode) From 78800f21046ababfc7f650984762c69801441dba Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 31 May 2010 22:18:48 +0100 Subject: [PATCH 3/3] Fixed the action regexp which was too greedy. --- rebase-mode.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rebase-mode.el b/rebase-mode.el index 76c8053c..233a3952 100644 --- a/rebase-mode.el +++ b/rebase-mode.el @@ -36,8 +36,7 @@ (group (** 7 40 (char "0-9" "a-f" "A-F"))) ;sha1 (char space) - (* anything) ; msg - line-end) + (* not-newline)) "Regexp that matches an action line in a rebase buffer.") (defvar rebase-mode-font-lock-keywords