I would like to color the background of each day in calendar according to the number of events in my org-agenda. The idea is to have a quick and visual idea of what are the busiest days. The code from How to highlight weekend days in Emacs calendar? might be a good start and I would need to write a function that, given a date, returns the number of scheduled event from my org-agenda/diary (I use org-diary) and set the face to face-busy-0, face-busy-1, etc.

I already wrote a Python code for doing more or less the same in the terminal (see Yearly calendar view of agenda (with colored background) but my elisp is not so good.

  • I actually do exactly as you describe, but it is a little complex and requires a custom solution. For some ideas, you may wish to check out my example repository for lorg-calendar which includes some highlighting onto a 3-month or 12-month calendar for certain events: github.com/lawlist/lorg-calendar And, as I mentioned in one of my previous comments to a thread you linked in the question above, one idea is to extract the data that is used to create the org-agenda and operate on that extracted data to generate the calendar view:emacs.stackexchange.com/a/12563/2287
    – lawlist
    May 21, 2020 at 16:10
  • In the lorg-calendar repository example linked in the previous comment, I use a modified version of a mark-visible-calendar-date by Drew Adams in his calendar+.el library: emacswiki.org/emacs/calendar%2B.el That library may have some other goodies that could help you on your quest.
    – lawlist
    May 21, 2020 at 16:15
  • Thanks for all the pointers, I'll start with that. May 21, 2020 at 17:28

1 Answer 1


I ended up with the code below. I guess it can be shorten/optimized (it's a bit slow) but it does the job.

(defface busy-1  '((t :foreground "black" :background "#eceff1")) "")
(defface busy-2  '((t :foreground "black" :background "#cfd8dc")) "")
(defface busy-3  '((t :foreground "black" :background "#b0bec5")) "")
(defface busy-4  '((t :foreground "black" :background "#90a4ae")) "")
(defface busy-5  '((t :foreground "white" :background "#78909c")) "")
(defface busy-6  '((t :foreground "white" :background "#607d8b")) "")
(defface busy-7  '((t :foreground "white" :background "#546e7a")) "")
(defface busy-8  '((t :foreground "white" :background "#455a64")) "")
(defface busy-9  '((t :foreground "white" :background "#37474f")) "")
(defface busy-10 '((t :foreground "white" :background "#263238")) "")

(defadvice calendar-generate-month
  (after highlight-weekend-days (month year indent) activate)
  "Highlight weekend days"
  (dotimes (i 31)
    (let ((date (list month (1+ i) year))
          (count (length (org-agenda-get-day-entries
                          "~/Documents/org/agenda.org" (list month (1+ i) year)))))
      (cond ((= count 0) ())
            ((= count 1) (calendar-mark-visible-date date 'busy-1))
            ((= count 2) (calendar-mark-visible-date date 'busy-2))
            ((= count 3) (calendar-mark-visible-date date 'busy-3))
            ((= count 4) (calendar-mark-visible-date date 'busy-4))
            ((= count 5) (calendar-mark-visible-date date 'busy-5))
            ((= count 6) (calendar-mark-visible-date date 'busy-6))
            ((= count 7) (calendar-mark-visible-date date 'busy-7))
            ((= count 8) (calendar-mark-visible-date date 'busy-8))
            ((= count 9) (calendar-mark-visible-date date 'busy-9))
            (t  (calendar-mark-visible-date date 'busy-10)))

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.