Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
orgmode configuraion of agenda (colorful block)
;; agenda 里面时间块彩色显示
;; From: https://emacs-china.org/t/org-agenda/8679/3
(defun ljg/org-agenda-time-grid-spacing ()
"Set different line spacing w.r.t. time duration."
(save-excursion
(let* ((background (alist-get 'background-mode (frame-parameters)))
(background-dark-p (string= background "dark"))
(colors (list "#1ABC9C" "#2ECC71" "#3498DB" "#9966ff"))
pos
duration)
(nconc colors colors)
(goto-char (point-min))
(while (setq pos (next-single-property-change (point) 'duration))
(goto-char pos)
(when (and (not (equal pos (point-at-eol)))
(setq duration (org-get-at-bol 'duration)))
(let ((line-height (if (< duration 30) 1.0 (+ 0.5 (/ duration 60))))
(ov (make-overlay (point-at-bol) (1+ (point-at-eol)))))
(overlay-put ov 'face `(:background ,(car colors)
:foreground
,(if background-dark-p "black" "white")))
(setq colors (cdr colors))
(overlay-put ov 'line-height line-height)
(overlay-put ov 'line-spacing (1- line-height))))))))
(add-hook 'org-agenda-finalize-hook #'ljg/org-agenda-time-grid-spacing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.