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

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

[nongnu] elpa/dslide dbcf00d38d 161/230: allow inclusive matching in sec


From: ELPA Syncer
Subject: [nongnu] elpa/dslide dbcf00d38d 161/230: allow inclusive matching in section mapping
Date: Sun, 7 Jul 2024 19:00:31 -0400 (EDT)

branch: elpa/dslide
commit dbcf00d38df59cea9bc0d44bf61673eec8398e21
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>

    allow inclusive matching in section mapping
    
    Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
---
 dslide.el | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/dslide.el b/dslide.el
index cdd9ef2b5b..789cc972b2 100644
--- a/dslide.el
+++ b/dslide.el
@@ -1907,24 +1907,32 @@ and NO-RECURSION are described in `org-element-map'."
                  first-match no-recursion)))
 
 (defun dslide--section-next
-    (heading type after &optional pred info no-recursion)
-  "Return HEADING's next element of TYPE that begins after AFTER.
+    (heading type after &optional pred inclusive info no-recursion)
+  "Return HEADING's next element of TYPE.
+By default, matches only after AFTER but with optional INCLUSIVE,
+also includes matches at AFTER.
+
 PRED, INFO, FIRST-MATCH, and NO-RECURSION are described in
 `org-element-map'."
-  (let* ((combined-pred (dslide-and
-                         pred
-                         (lambda (e) (> (org-element-property :begin e) 
after)))))
+  (let* ((combined-pred
+          (dslide-and pred
+                      (lambda (e) (funcall (if inclusive  #'>=  #'>)
+                                      (org-element-property :begin e) 
after)))))
     (dslide--section-map
      heading type combined-pred info t no-recursion)))
 
 (defun dslide--section-previous
-    (heading type before &optional pred info no-recursion)
-    "Return HEADING's previous element of TYPE before BEFORE.
+    (heading type before &optional pred inclusive info no-recursion)
+  "Return HEADING's previous element of TYPE.
+By default, matches only before BEFORE but with optional
+INCLUSIVE, also includes matches at BEFORE.
+
 PRED, INFO, FIRST-MATCH, and NO-RECURSION are described in
 `org-element-map'."
   (let* ((combined-pred (dslide-and
                          pred
-                         (lambda (e) (< (org-element-property :begin e) 
before)))))
+                         (lambda (e) (funcall (if inclusive #'<= #'<)
+                                         (org-element-property :begin e) 
before)))))
     ;; We can't map in reverse, so just retrieve all matched elements and
     ;; return the last one.
     (car (last (dslide--section-map



reply via email to

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