[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 30fc4cd 023/135: Created finders for compatibility with or
From: |
Ian Dunn |
Subject: |
[elpa] master 30fc4cd 023/135: Created finders for compatibility with org-depend |
Date: |
Mon, 17 Feb 2020 10:52:46 -0500 (EST) |
branch: master
commit 30fc4cdb2c87dc11e801daf73ae3a099c53a4836
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>
Created finders for compatibility with org-depend
* org-edna.el (org-edna-finder/siblings-wrap):
(org-edna-finder/rest-of-siblings): New functions
(org-edna-finder/chain-find): Finder for org-depend's chain-find-next
---
org-edna.el | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/org-edna.el b/org-edna.el
index 720db92..0c00145 100644
--- a/org-edna.el
+++ b/org-edna.el
@@ -237,6 +237,32 @@ IDS are all UUIDs as understood by `org-id-find'."
(push (point-marker) markers)))
(nreverse markers))))
+(defun org-edna-finder/siblings-wrap ()
+ (org-with-wide-buffer
+ (let ((self (and (ignore-errors (org-back-to-heading t)) (point)))
+ (markers))
+ ;; Go from this heading to the end
+ (while (org-get-next-sibling)
+ (unless (equal (point) self)
+ (push (point-marker) markers)))
+ ;; Go to the first heading
+ (org-up-heading-safe)
+ (org-goto-first-child)
+ (while (not (equal (point) self))
+ (push (point-marker) markers)
+ (org-get-next-sibling))
+ (nreverse markers))))
+
+(defun org-edna-finder/rest-of-siblings ()
+ (org-with-wide-buffer
+ (let ((self (and (ignore-errors (org-back-to-heading t)) (point)))
+ (markers))
+ ;; Go from this heading to the end
+ (while (org-get-next-sibling)
+ (unless (equal (point) self)
+ (push (point-marker) markers)))
+ (nreverse markers))))
+
(defun org-edna-finder/next-sibling ()
(org-with-wide-buffer
(and (org-get-next-sibling)
@@ -295,6 +321,60 @@ IDS are all UUIDs as understood by `org-id-find'."
(with-current-buffer (find-file-noselect (expand-file-name file
org-directory))
(list (point-min-marker))))
+(defun org-edna-finder/chain-find (&rest options)
+ ;; sortfun - function to use to sort elements
+ ;; filterufn - Function to use to filter elements
+ ;; Both should handle positioning point
+ (let (targets sortfun filterfun)
+ (dolist (opt options)
+ (pcase (intern opt)
+ ('from-top
+ (setq targets (org-edna-finder/siblings)))
+ ('from-bottom
+ (setq targets (seq-reverse (org-edna-finder/siblings))))
+ ('from-current
+ (setq targets (org-edna-finder/siblings-wrap)))
+ ('no-wrap
+ (setq targets (org-edna-finder/rest-of-siblings)))
+ ('todo-only
+ (setq filterfun
+ (lambda (target)
+ (org-entry-get target "TODO"))))
+ ('todo-and-done-only
+ (setq filterfun
+ (lambda (target)
+ (member (org-entry-get target "TODO") org-done-keywords))))
+ ('priority-up
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((priority-lhs (org-entry-get lhs "PRIORITY"))
+ (priority-rhs (org-entry-get rhs "PRIORITY")))
+ (not (string-lessp priority-lhs priority-rhs))))))
+ ('priority-down
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((priority-lhs (org-entry-get lhs "PRIORITY"))
+ (priority-rhs (org-entry-get rhs "PRIORITY")))
+ (string-lessp priority-lhs priority-rhs)))))
+ ('effort-up
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((effort-lhs (org-duration-to-minutes (org-entry-get lhs
"EFFORT")))
+ (effort-rhs (org-duration-to-minutes (org-entry-get rhs
"EFFORT"))))
+ (not (< effort-lhs effort-rhs))))))
+ ('effort-down
+ (setq sortfun
+ (lambda (lhs rhs)
+ (let ((effort-lhs (org-duration-to-minutes (org-entry-get lhs
"EFFORT")))
+ (effort-rhs (org-duration-to-minutes (org-entry-get rhs
"EFFORT"))))
+ (< effort-lhs effort-rhs)))))))
+ (when (and targets sortfun)
+ (setq targets (seq-sort sortfun targets)))
+ (when (and targets filterfun)
+ (setq targets (seq-filter filterfun targets)))
+ (when targets
+ (seq-elt 0 targets))))
+
;; Set TODO state
- [elpa] master 13e752b 021/135: Fix uses of substring, (continued)
- [elpa] master 13e752b 021/135: Fix uses of substring, Ian Dunn, 2020/02/17
- [elpa] master 3937f31 009/135: Fixed headings condition, Ian Dunn, 2020/02/17
- [elpa] master 975da4b 010/135: Improved org-bat-parse-form to handle new argument types, Ian Dunn, 2020/02/17
- [elpa] master 029bc2e 012/135: Cleaned up condition handling, Ian Dunn, 2020/02/17
- [elpa] master 602ad6d 011/135: Added tests for org-bat-parse-form, Ian Dunn, 2020/02/17
- [elpa] master a70f9ac 016/135: Fixed bug in Makefile, Ian Dunn, 2020/02/17
- [elpa] master abb0083 018/135: Fixed up indenting, Ian Dunn, 2020/02/17
- [elpa] master cb1f51f 020/135: Don't assume arguments will be symbols or strings, Ian Dunn, 2020/02/17
- [elpa] master 180d05b 022/135: Added configuration option to use inheritance, Ian Dunn, 2020/02/17
- [elpa] master b38a1ca 024/135: Added tests for ids and match finders, Ian Dunn, 2020/02/17
- [elpa] master 30fc4cd 023/135: Created finders for compatibility with org-depend,
Ian Dunn <=
- [elpa] master 9916819 028/135: Added test for parsing multiple forms, Ian Dunn, 2020/02/17
- [elpa] master fc0dcc1 029/135: Added re-search condition, Ian Dunn, 2020/02/17
- [elpa] master c675036 030/135: Added test for empty argument list, Ian Dunn, 2020/02/17
- [elpa] master 7a3332d 032/135: Fixed error in re-search, Ian Dunn, 2020/02/17
- [elpa] master 6470c5f 033/135: Added test for todo action, Ian Dunn, 2020/02/17
- [elpa] master db23e3f 034/135: Added some more test headings, Ian Dunn, 2020/02/17
- [elpa] master aa259f0 037/135: Fix considerations, Ian Dunn, 2020/02/17
- [elpa] master f80835a 038/135: Added tests for considerations, Ian Dunn, 2020/02/17
- [elpa] master 729a391 040/135: Added copyright and licensing information to all files, Ian Dunn, 2020/02/17
- [elpa] master 7379c4f 043/135: Added copyright date to source files, Ian Dunn, 2020/02/17