* todo and deadline highlighting
@ 2006-06-07 23:34 Piotr Zielinski
2006-06-12 21:16 ` Carsten Dominik
0 siblings, 1 reply; 4+ messages in thread
From: Piotr Zielinski @ 2006-06-07 23:34 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: todo and deadline highlighting
2006-06-07 23:34 todo and deadline highlighting Piotr Zielinski
@ 2006-06-12 21:16 ` Carsten Dominik
2006-06-19 20:09 ` Piotr Zielinski
0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2006-06-12 21:16 UTC (permalink / raw)
To: Piotr Zielinski; +Cc: emacs-orgmode
Hi Piotr,
On Jun 8, 2006, at 1:34, Piotr Zielinski wrote:
>
> It would be nice to be able to tell the org-occur function not to
> remove existing highlights in a less hacky way.
In the next version, you can warp your call into
(let *(org-inhibit-highlight-removal t))
......
> 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).
Suggestion noted - maybe at a later time. Thanks
>
> 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.
This is another interesting idea, but the search must allow more than
the current line. Everything up to the next headline (or any level)
should be searched.
- Carsten
>
> (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
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>
--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: todo and deadline highlighting
2006-06-12 21:16 ` Carsten Dominik
@ 2006-06-19 20:09 ` Piotr Zielinski
2006-06-20 7:09 ` Carsten Dominik
0 siblings, 1 reply; 4+ messages in thread
From: Piotr Zielinski @ 2006-06-19 20:09 UTC (permalink / raw)
To: Carsten Dominik; +Cc: emacs-orgmode
On 12/06/06, Carsten Dominik <dominik@science.uva.nl> wrote:
> On Jun 8, 2006, at 1:34, Piotr Zielinski wrote:
>
> > 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.
>
> This is another interesting idea, but the search must allow more than
> the current line. Everything up to the next headline (or any level)
> should be searched.
Another try:
(defun org-todo-is-current ()
"Checks whether a TODO item is current."
(if (re-search-forward org-scheduled-time-regexp
(save-excursion (outline-next-heading) (point)) 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))
Piotr
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: todo and deadline highlighting
2006-06-19 20:09 ` Piotr Zielinski
@ 2006-06-20 7:09 ` Carsten Dominik
0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2006-06-20 7:09 UTC (permalink / raw)
To: Piotr Zielinski; +Cc: emacs-orgmode
This looks like it is doing the right thing.
- Carsten
On Jun 19, 2006, at 22:09, Piotr Zielinski wrote:
> On 12/06/06, Carsten Dominik <dominik@science.uva.nl> wrote:
>
>> On Jun 8, 2006, at 1:34, Piotr Zielinski wrote:
>>
>> > 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.
>>
>> This is another interesting idea, but the search must allow more than
>> the current line. Everything up to the next headline (or any level)
>> should be searched.
>
> Another try:
>
> (defun org-todo-is-current ()
> "Checks whether a TODO item is current."
> (if (re-search-forward org-scheduled-time-regexp
> (save-excursion (outline-next-heading) (point)) 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))
>
>
> Piotr
>
>
--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-06-20 7:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-07 23:34 todo and deadline highlighting Piotr Zielinski
2006-06-12 21:16 ` Carsten Dominik
2006-06-19 20:09 ` Piotr Zielinski
2006-06-20 7:09 ` Carsten Dominik
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).