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

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

[emacs-wiki-discuss] Re: planner.el: planner-markup-tasks


From: Martin Morgan
Subject: [emacs-wiki-discuss] Re: planner.el: planner-markup-tasks
Date: Wed, 28 Jan 2004 12:38:15 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt)

Thanks Sacha for incorporating my suggestion!

Is this a flexible way for different aesthetics to coexist? It
separates out preferences from the program, making it easier to
customize (modify the ---rules, rather than messing with logic). I
didn't pay enough attention to whitespace & its markup, and don't
really know lisp at all...


(defun planner-markup-task-rules (priority schedule mark)
  "Rules for marking up task lines, based on the priority, schedule,
and mark of the task. Return a list with entries for text
properties of the hash mark, priority, schedule, mark, and the task
itself."
  (list (list                                                   ; hash mark (#)
                 'face (list :foreground
                                         (cond ((string= mark "X") "gray")
                                                   ((string= priority "A") 
"red")
                                                   ((string= priority "B") 
"orange")
                                                   ((string= priority "C") 
"yellow"))
                                         :underline (string= mark ">")
                                         :slant (if (string= mark "o") 'italic 
'normal)))
                (list 'invisible t)                             ; priority
                (list 'invisible t)                             ; schedule
                (list 'invisible t)                             ; mark
                nil                                                             
; task
                ))
(defun planner-markup-tasks (beg end &optional verbose)
  "Highlight tasks from BEG to END.  VERBOSE is ignored."
  (goto-char beg)
  (while (re-search-forward (concat "^\\(#\\)\\([A-C]\\)\\([0-9 ]+\\)\\("
                                                                        
planner-marks-regexp
                                    "\\)\\s-") nil t)
    (let* ((arg 1)
                   (rules (planner-markup-task-rules
                                   (match-string 2) (match-string 3) 
(match-string 4))))
          (while (car rules)
                (planner-markup-region
                 (match-beginning arg) (match-end arg)
                 'planner-task 50 (car rules))
                (setq arg (1+ arg))
                (setq rules (cdr rules))))))





reply via email to

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