emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Subtly hightling task backgrounds
@ 2011-06-30 16:28 John Wiegley
  2011-06-30 21:12 ` Eric S Fraga
  2011-07-01  8:53 ` Bastien
  0 siblings, 2 replies; 6+ messages in thread
From: John Wiegley @ 2011-06-30 16:28 UTC (permalink / raw)
  To: emacs-org list; +Cc: Carsten Dominik

I've been using the following code snippet for many weeks now to
great effect.  It helps me to "grok" my daily taskload better without
increasing the mental burden.  See the function's docstring for more

Here is a screenshot of the effect, from my today's agenda:



(defun org-agenda-add-overlays (&optional line)
  "Add overlays found in OVERLAY properties to agenda items.
Note that habitual items are excluded, as they already
extensively use text properties to draw the habits graph.

For example, for work tasks I like to use a subtle, yellow
background color; for tasks involving other people, green; and
for tasks concerning only myself, blue.  This way I know at a
glance how different responsibilities are divided for any given

To achieve this, I have the following in my todo file:

  * Work
    :CATEGORY: Work
    :OVERLAY:  (face (:background \"#fdfdeb\"))
  ** TODO Task
  * Family
    :CATEGORY: Personal
    :OVERLAY:  (face (:background \"#e8f9e8\"))
  ** TODO Task
  * Personal
    :CATEGORY: Personal
    :OVERLAY:  (face (:background \"#e8eff9\"))
  ** TODO Task

The colors (which only work well for white backgrounds) are:

  Yellow: #fdfdeb
  Green:  #e8f9e8
  Blue:   #e8eff9

To use this function, add it to `org-agenda-finalize-hook':

  (add-hook 'org-finalize-agenda-hook 'org-agenda-add-overlays)"
  (let ((inhibit-read-only t) l c
	(buffer-invisibility-spec '(org-link)))
      (goto-char (if line (point-at-bol) (point-min)))
      (while (not (eobp))
	(let ((org-marker (get-text-property (point) 'org-marker)))
          (when (and org-marker
                     (null (overlays-at (point)))
                     (not (get-text-property (point) 'org-habit-p))
                     (string-match "\\(sched\\|dead\\|todo\\)"
                                   (get-text-property (point) 'type)))
            (let ((overlays (org-entry-get org-marker "OVERLAY" t)))
              (when overlays
                (goto-char (line-end-position))
                (let ((rest (- (window-width) (current-column))))
                  (if (> rest 0)
                      (insert (make-string rest ? ))))
                (let ((ol (make-overlay (line-beginning-position)
                      (proplist (read overlays)))
                  (while proplist
                    (overlay-put ol (car proplist) (cadr proplist))
                    (setq proplist (cddr proplist))))))))

(add-hook 'org-finalize-agenda-hook 'org-agenda-add-overlays)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-02 21:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 16:28 Subtly hightling task backgrounds John Wiegley
2011-06-30 21:12 ` Eric S Fraga
2011-06-30 21:13   ` John Wiegley
2011-06-30 21:19     ` Eric S Fraga
2011-07-01  8:53 ` Bastien
2011-07-02 21:07   ` John Wiegley

Code repositories for project(s) associated with this public inbox


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).