summaryrefslogtreecommitdiff
path: root/org-fc-awk.el
diff options
context:
space:
mode:
authorLeon Rische <leon.rische@me.com>2022-11-30 12:45:24 +0100
committerLeon Rische <leon.rische@me.com>2022-11-30 12:45:24 +0100
commit44876305b38e11ac253817549a4271f926721c1e (patch)
tree62bf718d0cb1b65b04db56643d3cccdaeed82058 /org-fc-awk.el
parent973a16a9561f1ed2fd7e4c5c614b5e5d15715b12 (diff)
Change indexing functions to group cards by files
Diffstat (limited to 'org-fc-awk.el')
-rw-r--r--org-fc-awk.el49
1 files changed, 16 insertions, 33 deletions
diff --git a/org-fc-awk.el b/org-fc-awk.el
index 951c1a6..321b28d 100644
--- a/org-fc-awk.el
+++ b/org-fc-awk.el
@@ -87,27 +87,7 @@ ITAGS and LTAGS are strings `\":tag1:tag2:\"'"
(org-remove-uninherited-tags (split-string itags ":" t))
(split-string ltags ":" t))))
-(defun org-fc-awk-flatten-index (index)
- "Remove the file-level of INDEX."
- (mapcan
- (lambda (file)
- (mapcar
- (lambda (card)
- (plist-put card :path (plist-get file :path))
- (plist-put card :filetitle (plist-get file :title)))
- (plist-get file :cards)))
- index))
-
(defun org-fc-awk-index (paths &optional filter)
- "Find cards in PATHS matching an optional FILTER predicate.
-FILTER can be either nil or a function taking a single card as
- its input."
- (let ((index (org-fc-awk-index-paths paths)))
- (if filter
- (cl-remove-if-not filter index)
- index)))
-
-(defun org-fc-awk-index-paths (paths)
"Generate a list of all cards and positions in PATHS."
(let ((output (shell-command-to-string
(org-fc-awk--pipe
@@ -117,19 +97,22 @@ FILTER can be either nil or a function taking a single card as
"awk/index.awk"
:variables (org-fc-awk--indexer-variables)))))))
(if (string-prefix-p "(" output)
- (org-fc-awk-flatten-index
- (mapcar
- (lambda (file)
- (plist-put file :cards
- (mapcar
- (lambda (card)
- (plist-put
- card :tags
- (org-fc-awk-combine-tags
- (plist-get card :inherited-tags)
- (plist-get card :local-tags))))
- (plist-get file :cards))))
- (read output)))
+ (mapcar
+ (lambda (file)
+ (let ((cards
+ (mapcar
+ (lambda (card)
+ (plist-put
+ card :tags
+ (org-fc-awk-combine-tags
+ (plist-get card :inherited-tags)
+ (plist-get card :local-tags))))
+ (plist-get file :cards))))
+ (plist-put file :cards
+ (if filter
+ (cl-remove-if-not filter cards)
+ cards))))
+ (read output))
(error "Org-fc shell error: %s" output))))
(defun org-fc-awk-stats-reviews ()