branch: externals/org-modern commit ea829ce4b3ac035808d411b1a088e0947d75f554 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Fix progress bar, add more examples --- example.org | 44 +++++++++++++++++++++++++++++++------------- org-modern.el | 15 ++++++++------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/example.org b/example.org index effdb462bf..177cde8a27 100644 --- a/example.org +++ b/example.org @@ -120,16 +120,34 @@ radio link * Progress bars -- progress [1/13] -- progress [2/13] -- progress [3/13] -- progress [4/13] -- progress [5/13] -- progress [6/13] -- progress [7/13] -- progress [8/13] -- progress [9/13] -- progress [10/13] -- progress [11/13] -- progress [12/13] -- progress [13/13] +- quotient [1/13] +- quotient [2/13] +- quotient [3/13] +- quotient [4/13] +- quotient [5/13] +- quotient [6/13] +- quotient [7/13] +- quotient [8/13] +- quotient [9/13] +- quotient [10/13] +- quotient [11/13] +- quotient [12/13] +- quotient [13/13] + +- percent [0%] +- percent [1%] +- percent [2%] +- percent [5%] +- percent [10%] +- percent [20%] +- percent [30%] +- percent [40%] +- percent [50%] +- percent [60%] +- percent [70%] +- percent [80%] +- percent [90%] +- percent [100%] + +- overflow [110%] +- overflow [20/10] diff --git a/org-modern.el b/org-modern.el index cd8c11daaa..a9bd4c0276 100644 --- a/org-modern.el +++ b/org-modern.el @@ -418,12 +418,13 @@ the font.") "Prettify progress as color-coded bar." (let* ((beg (match-beginning 1)) (end (match-end 1)) - (val (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))))) + (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)) @@ -435,7 +436,7 @@ the font.") (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 (- w w1) w)) + (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))))))