emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 029bc2e 012/135: Cleaned up condition handling


From: Ian Dunn
Subject: [elpa] master 029bc2e 012/135: Cleaned up condition handling
Date: Mon, 17 Feb 2020 10:52:44 -0500 (EST)

branch: master
commit 029bc2e8fc6a5b91aaae798acfc514b718d542a0
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>

    Cleaned up condition handling
    
    * org-bat.el (org-bat--handle-condition): New function.
      (org-bat-process-form): Use it.
---
 org-bat.el | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/org-bat.el b/org-bat.el
index d360732..41c7627 100644
--- a/org-bat.el
+++ b/org-bat.el
@@ -71,6 +71,17 @@
                   org-bat--types)))
        (cons new-sym (intern (format func-format new-sym)))))))
 
+(defun org-bat--handle-condition (func mod args targets consideration)
+  ;; Check the condition at each target
+  (when-let ((blocks
+              (mapcar
+               (lambda (entry-marker)
+                 (org-with-point-at entry-marker
+                   (apply func mod args)))
+               targets)))
+    ;; Apply consideration
+    (org-bat-handle-consideration consideration blocks)))
+
 (defun org-bat-process-form (form action-or-condition)
   (let ((targets)
         (blocking-entry)
@@ -108,17 +119,9 @@
            (unless targets
              (message "Warning: Condition specified without targets"))
            (setq state 'condition)
-           (unless blocking-entry ;; We're already blocking
-             ;; Check the condition at each target
-             (when-let ((blocks
-                         (mapcar
-                          (lambda (entry-marker)
-                            (org-with-point-at entry-marker
-                              (apply func mod args)))
-                          targets)))
-               ;; Apply consideration
-               (setq blocking-entry
-                     (org-bat-handle-consideration consideration blocks)))))
+           (setq blocking-entry
+                 (or blocking-entry  ;; We're already blocking
+                     (org-bat--handle-condition func mod args targets 
consideration))))
           ('consideration
            ;; Consideration must be at the start of the targets, so clear out
            ;; any old targets.
@@ -130,15 +133,9 @@
     (when (and (eq action-or-condition 'condition) ;; Looking for conditions
                (eq state 'finder)                  ;; but haven't found any
                (not blocking-entry))                 ;; ever
-      (when-let ((blocks
-                  (mapcar
-                   (lambda (entry-marker)
-                     (org-with-point-at entry-marker
-                       (org-bat-condition/done t)))
-                   targets)))
-        ;; Apply consideration
-        (setq blocking-entry
-              (org-bat-handle-consideration consideration blocks))))
+      (setq blocking-entry
+            (org-bat--handle-condition 'org-bat-condition/done
+                                       t nil targets consideration)))
     ;; Only blockers care about the return value, and this will be non-nil if
     ;; the entry should be blocked.
     (setq org-block-entry-blocking blocking-entry)



reply via email to

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