bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simple fontification patch for TODO mode


From: Alexander Pohoyda
Subject: Simple fontification patch for TODO mode
Date: Thu, 13 May 2004 22:58:33 +0200 (CEST)

Hi there,

Please consider the following patch.  Thank you.

Index: todo-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/todo-mode.el,v
retrieving revision 1.52
diff -u -r1.52 todo-mode.el
--- todo-mode.el        10 Apr 2004 05:55:47 -0000      1.52
+++ todo-mode.el        13 May 2004 20:43:26 -0000
@@ -373,6 +373,13 @@
   (let ((time-stamp-format todo-time-string-format))
     (concat (time-stamp-string) " " todo-initials ": ")))
 
+(defface todo-date-face
+  '((t (:inherit font-lock-string-face)))
+  "Face used to highlight dates in item lines."
+  :group 'todo)
+(defvar todo-date-face 'todo-date-face
+  "Face used to highlight dates in item lines.")
+
 ;; ---------------------------------------------------------------------------
 
 ;; Set up some helpful context ...
@@ -431,6 +438,15 @@
 (defvar todo-header "-*- mode: todo; "
   "Header of todo files.")
 
+(defvar todo-font-lock-keywords
+  (list (list (concat "^\\(" (regexp-quote todo-prefix) "\\) "
+                     "\\(.*\\) " todo-initials ": "
+                     "\\(---.*\\)?")
+             '(1 font-lock-constant-face t)
+             '(2 todo-date-face t)
+             '(3 font-lock-warning-face t t)))
+  "Additional expressions to highlight items in ToDo mode.")
+
 ;; ---------------------------------------------------------------------------
 
 (defun todo-category-select ()
@@ -908,6 +924,11 @@
   (setq mode-name "TODO")
   (use-local-map todo-mode-map)
   (easy-menu-add todo-menu)
+
+  (make-local-variable 'font-lock-defaults)
+  (setq font-lock-defaults '(todo-font-lock-keywords t))
+  (font-lock-mode t)
+
   (run-hooks 'todo-mode-hook))
 
 (eval-when-compile

-- 
Alexander Pohoyda <alexander.pohoyda@gmx.net>
PGP Key fingerprint: 7F C9 CC 5A 75 CD 89 72  15 54 5F 62 20 23 C6 44




reply via email to

[Prev in Thread] Current Thread [Next in Thread]