From 5be31a383d83fd5270719d2e6b4ef552cd42b394 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 30 Aug 2010 23:45:51 +0100 Subject: [PATCH] Some font-locking. --- magit-keys.el | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/magit-keys.el b/magit-keys.el index df68f500..484a0fc1 100644 --- a/magit-keys.el +++ b/magit-keys.el @@ -183,6 +183,26 @@ put it in magit-key-mode-key-maps for fast lookup." (aput 'magit-key-mode-key-maps for-group map)) map))) +(defvar magit-key-mode-header-re + (rx line-start (| "Actions:"))) + +(defvar magit-key-mode-action-re + (rx line-start + (char space) + (group + (char alpha)) + ": " + (group + (* not-newline)))) + +(defvar magit-key-mode-font-lock-keywords + (list + (list magit-key-mode-header-re 0 'font-lock-keyword-face) + (list magit-key-mode-action-re + '(1 font-lock-builtin-face)))) + +(magit-key-mode 'logging) + (defun magit-key-mode (for-group) (interactive) (let ((buf (get-buffer-create "*magit-key*"))) @@ -191,6 +211,8 @@ put it in magit-key-mode-key-maps for fast lookup." (erase-buffer) (kill-all-local-variables) (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults + '(magit-key-mode-font-lock-keywords t t nil nil)) (use-local-map (or (cdr (assoc for-group magit-key-mode-key-maps)) (magit-key-mode-build-keymap for-group))) @@ -198,9 +220,8 @@ put it in magit-key-mode-key-maps for fast lookup." (setq buffer-read-only t) (setq mode-name "magit-key-mode" major-mode 'magit-key-mode)))) -(magit-key-mode 'logging) - (defun magit-key-mode-draw (for-group) + "Function used to draw actions, switches and parameters." (let* ((options (magit-key-mode-options-for-group for-group)) (actions (cdr (assoc 'actions options)))) (insert "Actions:\n")