Tidy
This commit is contained in:
parent
cdd25e8a7f
commit
c9245be371
1 changed files with 12 additions and 23 deletions
|
|
@ -42,26 +42,22 @@
|
||||||
;; FIXME: DRY these two macros.
|
;; FIXME: DRY these two macros.
|
||||||
|
|
||||||
(cl-defmacro org-agenda-ng (&rest args)
|
(cl-defmacro org-agenda-ng (&rest args)
|
||||||
"Display an agenda-like buffer of entries in FILES that match PRED.
|
"Display an agenda-like buffer of entries in FILES that match QUERY.
|
||||||
|
|
||||||
FILES-OR-PRED is a sexp that is evaluated to get the list of
|
FILES-OR-QUERY is a sexp that is evaluated to get the list of
|
||||||
files to scan.
|
files to scan.
|
||||||
|
|
||||||
PRED is a predicate sexp which is evaluated on each entry to test
|
QUERY is an `org-ql' query. The query may be passed as
|
||||||
whether it matches. This should be a form used by `org-ql'.
|
FILES-OR-QUERY and QUERY may be left nil, in which case the list
|
||||||
|
of files will automatically be set to the value of calling
|
||||||
|
`org-agenda-files'.
|
||||||
|
|
||||||
The predicate may be passed as FILES-OR-PRED and PRED may be left
|
SORT is passed to `org-ql', which see..
|
||||||
nil, in which case the list of files will automatically be set to
|
|
||||||
the value of calling `org-agenda-files'.
|
|
||||||
|
|
||||||
SORT is a list of sorting keys: `deadline', `scheduled',
|
|
||||||
`date' (matching either `deadline' or `scheduled'), `priority',
|
|
||||||
or `todo'.
|
|
||||||
|
|
||||||
NARROW, when non-nil, means to respect narrowing in buffers.
|
NARROW, when non-nil, means to respect narrowing in buffers.
|
||||||
When nil, buffers are widened before being searched."
|
When nil, buffers are widened before being searched."
|
||||||
(declare (indent defun)
|
(declare (indent defun)
|
||||||
(advertised-calling-convention '(files-or-pred &optional pred &key sort narrow) nil))
|
(advertised-calling-convention (files-or-query &optional query &key sort narrow) nil))
|
||||||
(cl-macrolet ((set-keyword-args (args)
|
(cl-macrolet ((set-keyword-args (args)
|
||||||
`(setq sort (plist-get ,args :sort)
|
`(setq sort (plist-get ,args :sort)
|
||||||
narrow (plist-get ,args :narrow))))
|
narrow (plist-get ,args :narrow))))
|
||||||
|
|
@ -94,18 +90,12 @@ When nil, buffers are widened before being searched."
|
||||||
;; TODO: Move the action-fn down into --filter-buffer, so users can avoid calling the
|
;; TODO: Move the action-fn down into --filter-buffer, so users can avoid calling the
|
||||||
;; headline-parser when they don't need it.
|
;; headline-parser when they don't need it.
|
||||||
|
|
||||||
(cl-defun org-agenda-ng--agenda (files pred &key sort)
|
(cl-defun org-agenda-ng--agenda (buffers-files query &key sort)
|
||||||
;; `org-ql--query' uses `org-element-headline-parser' by default, which we then map
|
"FIXME: Docstring"
|
||||||
;; `org-agenda-ng--format-element' across to get formatted, propertized strings for the agenda.
|
|
||||||
;; NOTE: `org-element-headline-parser' should remain the low-level action function, because the
|
|
||||||
;; sorting functions work on Org elements (so e.g. if we put `org-agenda-ng--format-element' as
|
|
||||||
;; the low-level action function, sorting would do nothing, because the sorting functions would
|
|
||||||
;; not find any data to sort on). IOW we have to call `org-agenda-ng--format-element' here, not
|
|
||||||
;; pass it to lower functions.
|
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
;; I think it's reasonable to use `eval' here.
|
;; I think it's reasonable to use `eval' here.
|
||||||
(let* ((entries (--> (eval `(org-ql ',files
|
(let* ((entries (--> (eval `(org-ql ',buffers-files
|
||||||
,pred
|
,query
|
||||||
:sort ,sort
|
:sort ,sort
|
||||||
:markers t))
|
:markers t))
|
||||||
(mapcar #'org-agenda-ng--format-element it)
|
(mapcar #'org-agenda-ng--format-element it)
|
||||||
|
|
@ -114,7 +104,6 @@ When nil, buffers are widened before being searched."
|
||||||
(s-join "\n" it)))
|
(s-join "\n" it)))
|
||||||
(target-buffer (get-buffer-create "test-agenda-ng"))
|
(target-buffer (get-buffer-create "test-agenda-ng"))
|
||||||
(inhibit-read-only t))
|
(inhibit-read-only t))
|
||||||
|
|
||||||
(with-current-buffer target-buffer
|
(with-current-buffer target-buffer
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert entries)
|
(insert entries)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue