Function: org-modern--progress

org-modern--progress is a natively compiled function defined in org-modern.el.

Signature

(org-modern--progress)

Documentation

Prettify progress as color-coded bar.

Source Code

;; Defined in /nix/store/0fwir9vccqq0yiqnswyf22ip3sl68f49-emacs-packages-deps/share/emacs/site-lisp/elpa/org-modern-20260722.1411/org-modern.el
(defun org-modern--progress ()
  "Prettify progress as color-coded bar."
  (let* ((beg (match-beginning 1))
         (end (match-end 1))
         (val (min 1.0
                   (if (match-beginning 2)
                       (* 0.01 (string-to-number (match-string-no-properties 2)))
                     (let ((q (string-to-number (match-string-no-properties 4))))
                       (if (= q 0)
                           1.0
                         (/ (* 1.0 (string-to-number (match-string-no-properties 3))) q))))))
         (w org-modern-progress)
         (complete (floor (* w val)))
         (w0 (- end beg 2))
         (w1 (/ (- w w0) 2))
         (bar (concat (make-string w1 ?\s)
                      (buffer-substring-no-properties (1+ beg) (1- end))
                      (make-string (- w w1 w0) ?\s))))
    (put-text-property 0 complete 'face 'org-modern-progress-complete bar)
    (put-text-property complete w 'face 'org-modern-progress-incomplete bar)
    (put-text-property beg end 'face 'org-modern-label)
    (put-text-property beg (1+ beg) 'display (substring bar 0 w1))
    (put-text-property (1- end) end 'display (substring bar (+ w1 w0) w))
    (dotimes (i w0)
      (put-text-property (+ 1 beg i) (+ 2 beg i)
                         'display (substring bar (+ w1 i) (+ w1 i 1))))))