all messages for Emacs-related lists mirrored at yhetil.org
 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
info.

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

  http://ftp.newartisans.com/pub/highlighting.png

John

(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
day.

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

  * Work
    :PROPERTIES:
    :CATEGORY: Work
    :OVERLAY:  (face (:background \"#fdfdeb\"))
    :END:
  ** TODO Task
  * Family
    :PROPERTIES:
    :CATEGORY: Personal
    :OVERLAY:  (face (:background \"#e8f9e8\"))
    :END:
  ** TODO Task
  * Personal
    :PROPERTIES:
    :CATEGORY: Personal
    :OVERLAY:  (face (:background \"#e8eff9\"))
    :END:
  ** 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)))
    (save-excursion
      (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)
                                        (line-end-position)))
                      (proplist (read overlays)))
                  (while proplist
                    (overlay-put ol (car proplist) (cadr proplist))
                    (setq proplist (cddr proplist))))))))
	(forward-line)))))

(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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.