[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 01c50c0 002/135: Make all finders return lists of markers
From: |
Ian Dunn |
Subject: |
[elpa] master 01c50c0 002/135: Make all finders return lists of markers |
Date: |
Mon, 17 Feb 2020 10:52:42 -0500 (EST) |
branch: master
commit 01c50c057d8854f4e17a9057eb9ed33119ec0e37
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] master updated (487ad1b -> bf8ecda), Ian Dunn, 2020/02/17
- [elpa] master 567e982 007/135: Added package requirements, Ian Dunn, 2020/02/17
- [elpa] master a943aa6 008/135: Added more custom IDs to documentation, Ian Dunn, 2020/02/17
- [elpa] master 21d2019 006/135: Added has-property condition, Ian Dunn, 2020/02/17
- [elpa] master 0e5fd41 004/135: Added .bzrignore., Ian Dunn, 2020/02/17
- [elpa] master 3a4cca9 003/135: Added Makefile., Ian Dunn, 2020/02/17
- [elpa] master 01c50c0 002/135: Make all finders return lists of markers,
Ian Dunn <=
- [elpa] master 5010097 005/135: Added initial documentation, Ian Dunn, 2020/02/17
- [elpa] master 18814ca 001/135: Initial Commit., Ian Dunn, 2020/02/17
- [elpa] master 1fb6dcf 013/135: Added chain action, Ian Dunn, 2020/02/17
- [elpa] master ad75461 017/135: Use existing org-xor instead of new function, Ian Dunn, 2020/02/17
- [elpa] master adbff7e 019/135: Remove duplicate targets, Ian Dunn, 2020/02/17
- [elpa] master 6886b8a 026/135: Fixed chain-find, Ian Dunn, 2020/02/17
- [elpa] master 55283ff 015/135: Renamed to Org-Edna., Ian Dunn, 2020/02/17
- [elpa] master d348102 025/135: Added file for tests, Ian Dunn, 2020/02/17
- [elpa] master 71cdc0a 027/135: Fixed parsing bug, Ian Dunn, 2020/02/17
- [elpa] master 6b9a676 031/135: Added documentation for each condition, Ian Dunn, 2020/02/17