Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color code agenda view per file

Tags:

emacs

org-mode

I have several .org files, e.g. personal.org and work.org.

When viewing the agenda, I'd like to have events from each file differently colored.

For example,

Wednesday  12 June 2013
  personal:   11:00am........ Personal Meeting
  work:       2:00pm- 3:00pm  Work Meeting

There are already some colors in the agenda, but those two lines are both white. How can I set the line coming from personal to one color, and the line coming from work to another? I figure at least there has to be a way to define a color scheme based on the personal: and work: text if there's no easy way to have org do it by file.

Thanks!

like image 654
Josh Avatar asked Jun 12 '13 13:06

Josh


2 Answers

The only thing I found as solution for what you ask, you have to use a hook function, changing faces after the agenda view is ready. The following code is untested, but should get you going:

(add-hook 'org-finalize-agenda-hook
    (lambda ()
      (save-excursion
        (goto-char (point-min))
        (while (re-search-forward "personal:" nil t) 
          (add-text-properties (match-beginning 0) (point-at-eol)
             '(face secondary-selection)))
        (goto-char (point-min))
        (while (re-search-forward "work:" nil t) 
          (add-text-properties (match-beginning 0) (point-at-eol)
             '(face bold))))))
like image 110
Tom Regner Avatar answered Oct 17 '22 01:10

Tom Regner


John Wiegley sent once a patch he wrote so that, with an :OVERLAY: property, all Work items have the same background color. And with another value for Personal, those items have a different color.

See http://comments.gmane.org/gmane.emacs.orgmode/54342

like image 3
fniessen Avatar answered Oct 17 '22 01:10

fniessen