From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Piotr Zielinski" Subject: todo and deadline highlighting Date: Thu, 8 Jun 2006 00:34:10 +0100 Message-ID: <3c12eb8d0606071634k6bdcf44dh37207ab742221d2f@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fo7XT-0006xQ-70 for emacs-orgmode@gnu.org; Wed, 07 Jun 2006 19:34:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fo7XR-0006x1-Lu for emacs-orgmode@gnu.org; Wed, 07 Jun 2006 19:34:14 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fo7XR-0006wy-Hb for emacs-orgmode@gnu.org; Wed, 07 Jun 2006 19:34:13 -0400 Received: from [64.233.184.236] (helo=wr-out-0506.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fo7f8-0007j5-EL for emacs-orgmode@gnu.org; Wed, 07 Jun 2006 19:42:10 -0400 Received: by wr-out-0506.google.com with SMTP id i11so568344wra for ; Wed, 07 Jun 2006 16:34:10 -0700 (PDT) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi, Here are three functions related to todo and deadline highlighting is the todo buffer. The first lets you highlight upoming deadlines and todo items at the same time. (defun org-check-deadlines-and-todos (ndays) (org-check-deadlines ndays) (flet ((org-remove-occur-highlights (&optional beg end noremove)) (org-overview ())) (org-show-todo-tree nil))) It would be nice to be able to tell the org-occur function not to remove existing highlights in a less hacky way. Another suggestion: explicit specification of the face used for highlighting so that deadlines and todos could use a different face. Yet another suggestion: the org-occur callback could return the face to use, so that different faces could be used for deadline highlighting, depending on the urgency of the deadline (ie. in 3 days vs. in 30 days). The following two functions redefine org-show-todo-tree, so that TODO items SCHEDULED for the future are not highlighted. Only non-scheduled TODO items or TODO items scheduled for the past or present are highlighted. The SCHEDULED directive must be on the same line as the TODO keyword. (defun org-todo-is-current () "Checks whether a TODO items is current." (if (re-search-forward org-scheduled-time-regexp (point-at-eol) t) (let ((today (calendar-absolute-from-gregorian (calendar-current-date))) (timestamp (time-to-days (org-time-string-to-time (match-string 1))))) (<= timestamp today)) t)) (defun org-show-todo-tree (arg) "Make a compact tree which shows all headlines marked with TODO. The tree will show the lines where the regexp matches, and all higher headlines above the match. With \\[universal-argument] prefix, also show the DONE entries. With a numeric prefix N, construct a sparse tree for the Nth element of `org-todo-keywords'." (interactive "P") (let ((case-fold-search nil) (kwd-re (cond ((null arg) org-not-done-regexp) ((equal arg '(4)) org-todo-regexp) ((<= (prefix-numeric-value arg) (length org-todo-keywords)) (regexp-quote (nth (1- (prefix-numeric-value arg)) org-todo-keywords))) (t (error "Invalid prefix argument: %s" arg))))) (message "%d TODO entries found" (org-occur (concat "^" outline-regexp " +" kwd-re ) 'org-todo-is-current)))) Piotr