[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/org-edna 0273bf1 02/72: Make all finders return lists of
From: |
Ian Dunn |
Subject: |
[elpa] scratch/org-edna 0273bf1 02/72: Make all finders return lists of markers |
Date: |
Sun, 21 May 2017 21:11:18 -0400 (EDT) |
branch: scratch/org-edna
commit 0273bf191a2695db0a7745a9ed47f33525c20624
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>
Make all finders return lists of markers
* org-bat.el (org-bat-process-form): Assume all finders will either be nil
or
lists.
(org-bat-finder/self):
(org-bat-finder/next-sibling):
(org-bat-finder/previous-sibling):
(org-bat-finder/first-child):
(org-bat-finder/parent):
(org-bat-finder/olp):
(org-bat-finder/file):
(org-bat-finder/org-file): Wrap markers in a list.
---
org-bat.el | 43 ++++++++++++++++++-------------------------
1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/org-bat.el b/org-bat.el
index ac2f8b0..23dd096 100644
--- a/org-bat.el
+++ b/org-bat.el
@@ -1,21 +1,13 @@
;;; org-bat.el --- Extendable Blockers and Triggers -*- lexical-binding: t; -*-
-;; Author: Ian Dunn
+;; Author: Ian Dunn <address@hidden>
+;; Keywords: convenience, text, org
+;; Version: 1.0
+;; Created: 20 Mar 2017
+;; Modified: 05 Apr 2017
;;; Commentary:
-;; Finders:
-
-;; - self Self
-;; - siblings Find all siblings of the current entry
-;; - next-sibling Find the next sibling on the same level as the entry
-;; - previous-sibling Find the previous sibling on the same level
-;; - first-child Find the first child of the current entry
-;; - children Find all children of the current entry
-;; - parent Find direct parent of current entry
-;; - descendants Find all descendants of the current entry
-;; - ancestors Find all ancestors of the current entry
-
;;; Code:
(require 'org)
@@ -69,13 +61,12 @@
(setq targets nil))
(setq state 'finder)
(let ((markers (apply func args)))
- ;; Ensure targets is a list so append continues to work
- (setq targets (append targets (if (consp markers) markers (list
markers))))))
+ (setq targets `(,@targets ,@markers))))
('action
(unless (eq action-or-condition 'action)
(user-error "Actions aren't allowed in this context."))
(unless targets
- (user-error "Action specified without targets"))
+ (message "Warning: Action specified without targets"))
(setq state 'action)
(dolist (target targets)
(org-with-point-at target
@@ -84,7 +75,7 @@
(unless (eq action-or-condition 'condition)
(user-error "Conditions aren't allowed in this context"))
(unless targets
- (user-error "Condition specified without targets"))
+ (message "Warning: Condition specified without targets"))
(setq state 'condition)
(unless blocking-entry ;; We're already blocking
;; Check the condition at each target
@@ -192,7 +183,7 @@ IDS are all UUIDs as understood by `org-id-find'."
(mapcar (lambda (id) (org-id-find id 'marker)) ids))
(defun org-bat-finder/self ()
- (point-marker))
+ (list (point-marker)))
(defun org-bat-finder/siblings ()
(org-with-wide-buffer
@@ -209,17 +200,17 @@ IDS are all UUIDs as understood by `org-id-find'."
(defun org-bat-finder/next-sibling ()
(org-with-wide-buffer
(and (org-get-next-sibling)
- (point-marker))))
+ (list (point-marker)))))
(defun org-bat-finder/previous-sibling ()
(org-with-wide-buffer
(and (org-get-last-sibling)
- (point-marker))))
+ (list (point-marker)))))
(defun org-bat-finder/first-child ()
(org-with-wide-buffer
(and (org-goto-first-child)
- (point-marker))))
+ (list (point-marker)))))
(defun org-bat-finder/children ()
(org-with-wide-buffer
@@ -233,7 +224,7 @@ IDS are all UUIDs as understood by `org-id-find'."
(defun org-bat-finder/parent ()
(org-with-wide-buffer
(and (org-up-heading-safe)
- (point-marker))))
+ (list (point-marker)))))
(defun org-bat-finder/descendants ()
(org-with-wide-buffer
@@ -249,18 +240,20 @@ IDS are all UUIDs as understood by `org-id-find'."
(nreverse markers))))
(defun org-bat-finder/olp (file path)
- (org-find-olp (cons file (split-string-and-unquote path "/"))))
+ (let ((marker (org-find-olp (cons file (split-string-and-unquote path
"/")))))
+ (when (markerp marker)
+ (list marker))))
(defun org-bat-finder/file (file)
;; If there isn't a buffer visiting file, then there's no point in having a
;; marker to the start of the file.
(with-current-buffer (find-file-noselect file)
- (point-min-marker)))
+ (list (point-min-marker))))
(defun org-bat-finder/org-file (file)
"Finds FILE in `org-directory'."
(with-current-buffer (find-file-noselect (expand-file-name file
org-directory))
- (point-min-marker)))
+ (list (point-min-marker))))
- [elpa] branch scratch/org-edna created (now 901a84a), Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 352d95c 06/72: Added has-property condition, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 69cc5d4 07/72: Added package requirements, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 0273bf1 02/72: Make all finders return lists of markers,
Ian Dunn <=
- [elpa] scratch/org-edna 03a6a95 03/72: Added Makefile., Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 5e69f84 04/72: Added .bzrignore., Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 6ec67b8 10/72: Improved org-bat-parse-form to handle new argument types, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 8b58c07 14/72: Clarified use of case-fold-search in `org-bat--handle-planning', Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 00ef89a 11/72: Added tests for org-bat-parse-form, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 8aeb66c 08/72: Added more custom IDs to documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 89baba4 13/72: Added chain action, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna e2db4dc 19/72: Remove duplicate targets, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 68b01b8 16/72: Fixed bug in Makefile, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna dc320fe 17/72: Use existing org-xor instead of new function, Ian Dunn, 2017/05/21