branch: externals/org-modern
commit 6550abc8c7b059cfa8b1653c280dde030787a6e7
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    Fix TODO state formatting in custom agendas
    
    Fix #26, #85, #199, #210, #211
---
 CHANGELOG.org |  1 +
 org-modern.el | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index d0aed96b26..3300d5b0c3 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -6,6 +6,7 @@
 
 - Fix date formatting after #+date keyword.
 - Fix table divider line scaling.
+- Fix TODO state formatting in custom agendas.
 - Bump Compat dependency to Compat 30.
 
 * Version 1.3 (2024-06-02)
diff --git a/org-modern.el b/org-modern.el
index 97c8440d3e..ab7e8a67a2 100644
--- a/org-modern.el
+++ b/org-modern.el
@@ -481,9 +481,8 @@ the font.")
      (if-let ((face (or (cdr (assoc todo org-modern-todo-faces))
                         (cdr (assq t org-modern-todo-faces)))))
          `(:inherit (,face org-modern-label))
-       (if (member todo org-done-keywords)
-           'org-modern-done
-         'org-modern-todo)))))
+       (if (string-match-p org-not-done-regexp todo)
+           'org-modern-todo 'org-modern-done)))))
 
 (defun org-modern--timestamp ()
   "Prettify timestamps."
@@ -902,13 +901,14 @@ whole buffer; otherwise, for the line at point."
       (let (case-fold-search)
         (when org-modern-todo
           (goto-char (point-min))
-          (let ((re (format " %s "
-                            (regexp-opt
-                             (append org-todo-keywords-for-agenda
-                                     org-done-keywords-for-agenda) t)))
-                (org-done-keywords org-done-keywords-for-agenda))
-            (while (re-search-forward re nil 'noerror)
-              (org-modern--todo))))
+          (while (< (point) (point-max))
+            (when-let (((get-text-property (point) 'todo-state))
+                       (re (get-text-property (point) 'org-todo-regexp))
+                       (re (concat " " re " "))
+                       (pos (re-search-forward re (pos-eol) 'noerror))
+                       (org-not-done-regexp (get-text-property (point) 
'org-not-done-regexp)))
+              (org-modern--todo))
+            (goto-char (min (1+ (pos-eol)) (point-max)))))
         (when org-modern-tag
           (goto-char (point-min))
           (let ((re (concat "\\( \\)\\(:\\(?:" org-tag-re "::?\\)+\\)[ 
\t]*$")))

Reply via email to