Created
May 5, 2020 10:16
-
-
Save lijigang/3c9326a2cf86b50f9041c20c74398bb1 to your computer and use it in GitHub Desktop.
orgmode configuraion of agenda (colorful block)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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