emacs-wiki-discuss
[Top][All Lists]
Advanced

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

[emacs-wiki-discuss] Highlighting dates


From: Sacha Chua
Subject: [emacs-wiki-discuss] Highlighting dates
Date: Thu, 03 Nov 2005 17:57:10 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Because [[2005.11.01.muse][2005.11.01]] is an abomination. ;)
This works for muse-colors. Someone should get it to work with publishing. 
<grin>

--- orig/planner.el
+++ mod/planner.el
@@ -1011,11 +1011,17 @@
     (when (and font-lock-mode muse-mode-highlight-p)
       (muse-colors-buffer))))
 
+(defvar planner-date-regexp
+  "\\<\\([1-9][0-9][0-9][0-9]\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\>")
+
 (defun planner-setup-highlighting ()
   "Set up fontification for planner."
   (add-hook 'muse-colors-buffer-hook 'planner-zap-overlays t t)
   (add-hook 'muse-colors-buffer-hook 'planner-highlight-tasks t t)
   (add-hook 'muse-colors-buffer-hook 'planner-highlight-notes t t)
+  (add-to-list 'muse-colors-markup
+               (list planner-date-regexp t 'muse-colors-implicit-link))
+  (muse-configure-highlighting 'muse-colors-markup muse-colors-markup)
   (set (make-local-variable 'font-lock-unfontify-region-function)
        'planner-unhighlight-region)
   (set (make-local-variable 'font-lock-defaults)
@@ -1024,6 +1030,16 @@
         (font-lock-unfontify-region-function
          . planner-unhighlight-region))))
 
+(defun planner-muse-handle-date-link (&optional string)
+  "If STRING or point has a date, match and return it."
+  (when (if string
+            (string-match planner-date-regexp string)
+          (looking-at planner-date-regexp))
+    (match-string 0 string)))
+
+(custom-add-option 'muse-implicit-link-functions 
'planner-muse-handle-date-link)
+(add-hook 'muse-implicit-link-functions 'planner-muse-handle-date-link t)
+
 ;;;_ + Wiki pages
 
 (defun planner-strip-whitespace (string)
@@ -1068,9 +1084,6 @@
           (funcall planner-delete-file-function filename)))
     (kill-buffer (current-buffer))))
 
-(defvar planner-date-regexp
-  "\\`\\([1-9][0-9][0-9][0-9]\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\'")
-
 (defun planner-prepare-file ()
   "Insert some standard sections into an empty planner file."
   (when (= (buffer-size) 0)

-- 
Sacha Chua <address@hidden> - open source, free software geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, public speaking
sachac on irc.freenode.net#emacs . YM: sachachua83




reply via email to

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