Skip to content

Instantly share code, notes, and snippets.

@lijigang
Created May 5, 2020 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lijigang/3c9326a2cf86b50f9041c20c74398bb1 to your computer and use it in GitHub Desktop.
Save lijigang/3c9326a2cf86b50f9041c20c74398bb1 to your computer and use it in GitHub Desktop.
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