emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] support colorful blocks display on org-agenda


From: stardiviner
Subject: [PATCH] support colorful blocks display on org-agenda
Date: Wed, 12 Feb 2020 16:34:24 +0800
User-agent: mu4e 1.3.8; emacs 27.0.50

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


I have got author's permission to add this patch to Org Mode.

Here is the original thread: https://emacs-china.org/t/org-agenda/8679/8

I don't know whether this patch have to get author signed FSF papers. Might have
not exceeded the TINYCHANGE limit?

Here is the patch code.

#+begin_src emacs-lisp
;; Show Org Agenda tasks with heigh spacing based on clock time with 
`org-agenda-log-mode'.
;; https://emacs-china.org/t/org-agenda/8679
;; work with org-agenda dispatcher [c] "Today Clocked Tasks" to view today's 
clocked tasks.
(defun org-agenda-time-grid-colorful-spacing ()
  "Set different line spacing w.r.t. time duration."
  (save-excursion
    ;; (list "#aa557f" "DarkGreen" "DarkSlateGray" "DarkSlateBlue") ; dark theme
    ;; (list "#F6B1C3" "#FFFF9D" "#BEEB9F" "#ADD5F7") ; white theme
    (let* ((colors (list "#aa557f" "DarkGreen" "DarkSlateGray" "DarkSlateBlue"))
           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)))
          ;; larger duration bar height
          (let ((line-height (if (< duration 15) 1.0 (+ 0.5 (/ duration 30))))
                (ov (make-overlay (point-at-bol) (1+ (point-at-eol)))))
            (overlay-put ov 'face `(:background ,(car colors) :foreground 
"black"))
            (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 #'org-agenda-time-grid-colorful-spacing)
#+end_src

If this patch can be merged. I will submit an PATCH format file.

BTW, about this patch, I know using hook is a user hack way. In real patch, I
will add a defcustom option to enabled by default (WDYT?). and loaded in
org-agenda finalize position.

- -- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      
-----BEGIN PGP SIGNATURE-----

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5DuJEUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsM8Qwf+MFGcBeC180m7fN/PLwrkeuOMS5zT
XsR3oS2B/urrPY8DU2+Ff3YgA+HABFpJ0O0DHe5O+xdFr0uggJhFJi3wqPXetl4e
i+IKGx3j8gJ2cpSf1E5CATWppCklMEX4aFB7hk35zRtrIsn+Kgs5irr1EPxAmqjY
0CyvklRe3RacPSDRNh6PTPYJPmYa3UIgjkD6kzzSxB+ED6xTECDwuh9dSMQhqj1q
8+/ji9OfYjyFzHkdEC8+fc+e2wZ7/lm4sGUfW6Y3v5KIonhtrA+D/tikGfqHvfR2
Q728uZGGQcrYO511V37f+bAndW2GSSaAIZJ5gzcatqB+wRnqTcqMlQSiHw==
=mhYR
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]