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

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

[elpa] master 2cfb021 02/14: Added next-sibling-wrap finder


From: Ian Dunn
Subject: [elpa] master 2cfb021 02/14: Added next-sibling-wrap finder
Date: Sun, 17 Dec 2017 17:39:57 -0500 (EST)

branch: master
commit 2cfb0217c7efc91967a251db474569938e0566d9
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>

    Added next-sibling-wrap finder
    
    * org-edna.el (org-edna-finder/next-sibling-wrap): Added
    
    * org-edna-tests.el (org-edna-finder/next-sibling-wrap-next):
      (org-edna-finder/next-sibling-wrap-wrap): New tests.
    
    * org-edna.org (next-sibling-wrap): Document new finder.
---
 org-edna-tests.el | 24 +++++++++++++++++++++++-
 org-edna.el       | 10 +++++++++-
 org-edna.org      | 11 +++++++++++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/org-edna-tests.el b/org-edna-tests.el
index bdbd49f..00a9a8d 100644
--- a/org-edna-tests.el
+++ b/org-edna-tests.el
@@ -254,6 +254,28 @@
     (should (= (length targets) 1))
     (should (equal siblings targets))))
 
+(ert-deftest org-edna-finder/next-sibling-wrap-next ()
+  (let* ((org-agenda-files `(,org-edna-test-file))
+         (current (org-id-find org-edna-test-sibling-two-id t))
+         (siblings (mapcar
+                    (lambda (uuid) (org-id-find uuid t))
+                    `(,org-edna-test-sibling-three-id)))
+         (targets (org-with-point-at current
+                    (org-edna-finder/next-sibling-wrap))))
+    (should (= (length targets) 1))
+    (should (equal siblings targets))))
+
+(ert-deftest org-edna-finder/next-sibling-wrap-wrap ()
+  (let* ((org-agenda-files `(,org-edna-test-file))
+         (current (org-id-find org-edna-test-sibling-three-id t))
+         (siblings (mapcar
+                    (lambda (uuid) (org-id-find uuid t))
+                    `(,org-edna-test-sibling-one-id)))
+         (targets (org-with-point-at current
+                    (org-edna-finder/next-sibling-wrap))))
+    (should (= (length targets) 1))
+    (should (equal siblings targets))))
+
 (ert-deftest org-edna-finder/previous-sibling ()
   (let* ((org-agenda-files `(,org-edna-test-file))
          (current (org-id-find "06aca55e-ce09-46df-80d7-5b52e55d6505" t))
@@ -374,7 +396,7 @@
       (org-edna-action/tag! nil "tag")
       (should (equal (org-get-tags) '("tag")))
       (org-edna-action/tag! nil "")
-      (should-not (org-get-tags)))))
+      (should (equal (org-get-tags) '(""))))))
 
 (ert-deftest org-edna-action-property ()
   (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
diff --git a/org-edna.el b/org-edna.el
index d11f5de..38d1a3c 100644
--- a/org-edna.el
+++ b/org-edna.el
@@ -241,7 +241,7 @@ is changing from a TODO state to a DONE state, run BODY."
            (error
             (if (eq (car err) 'invalid-read-syntax)
                 (org-edna--print-syntax-error (cdr err))
-              (message "Edna Error: %s" (error-message-string err)))
+              (message "Edna Error at heading %s: %s" (org-get-heading t t t) 
(error-message-string err)))
             (setq org-block-entry-blocking (org-get-heading))
             ;; Block
             nil))
@@ -370,6 +370,14 @@ IDS are all UUIDs as understood by `org-id-find'."
    (and (org-get-next-sibling)
         (list (point-marker)))))
 
+(defun org-edna-finder/next-sibling-wrap ()
+  (org-with-wide-buffer
+   (if (org-goto-sibling)
+       (list (point-marker))
+     (org-up-heading-safe)
+     (org-goto-first-child)
+     (list (point-marker)))))
+
 (defun org-edna-finder/previous-sibling ()
   (org-with-wide-buffer
    (and (org-get-last-sibling)
diff --git a/org-edna.org b/org-edna.org
index ee2cd93..240acae 100644
--- a/org-edna.org
+++ b/org-edna.org
@@ -404,6 +404,17 @@ argument.
 The ~next-sibling~ keyword returns the next sibling of the current heading, if
 any.
 
+*** next-sibling-wrap
+:PROPERTIES:
+:CUSTOM_ID: next-sibling-wrap
+:DESCRIPTION: Find the next sibling, wrapping around
+:END:
+
+- Syntax: next-sibling-wrap
+
+Find the next sibling of the current heading, if any.  If there isn't, wrap 
back
+around to the first heading in the same subtree.
+
 *** olp
 :PROPERTIES:
 :CUSTOM_ID: olp



reply via email to

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