emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] support colorful blocks display on org-agenda
@ 2020-02-12  8:34 stardiviner
  2020-02-12  8:40 ` Bastien
  2020-02-12  8:42 ` Bastien
  0 siblings, 2 replies; 10+ messages in thread
From: stardiviner @ 2020-02-12  8:34 UTC (permalink / raw)
  To: Org Mode

-----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-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-02-23 22:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-12  8:34 [PATCH] support colorful blocks display on org-agenda stardiviner
2020-02-12  8:40 ` Bastien
2020-02-20  7:01   ` stardiviner
2020-02-20  7:15     ` Bastien
2020-02-20 15:17       ` stardiviner
2020-02-23 22:18       ` Daniele Nicolodi
2020-02-12  8:42 ` Bastien
2020-02-12 10:37   ` stardiviner
2020-02-20 15:34   ` [SOLVED] " stardiviner
2020-02-20 15:41     ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).