From 8d030e4b961e0c777ac20c6684739cd6a6e6447d Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Mon, 23 Jul 2018 12:10:06 +0900 Subject: [PATCH] Expand directories in the first argument of org-ql --- org-ql.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/org-ql.el b/org-ql.el index 17e9a50..197b26b 100644 --- a/org-ql.el +++ b/org-ql.el @@ -58,7 +58,7 @@ buffer (the default is to widen and search the entire buffer)." (setq buffers-or-files (cl-typecase buffers-or-files (null (list (current-buffer))) (buffer (list buffers-or-files)) - (list buffers-or-files) + (list (org-ql--expand-directories buffers-or-files)) (string (list buffers-or-files)))) (let* ((org-use-tag-inheritance t) (org-scanner-tags nil) @@ -72,6 +72,17 @@ buffer (the default is to widen and search the entire buffer)." (org-ql--filter-buffer :pred pred :narrow narrow))) buffers-or-files)))) +(defun org-ql--expand-directories (buffers-or-files) + "If BUFFERS-OR-FILES contain directories, expand Org files in them." + (-flatten-n 1 + (mapcar + (lambda (it) + (if (and (stringp it) + (file-directory-p it)) + (directory-files it t org-agenda-file-regexp) + it)) + buffers-or-files))) + (cl-defun org-ql--filter-buffer (&key pred narrow) "Return positions of matching headings in current buffer. Headings should return non-nil for any ANY-PREDS and nil for all