Add: org-ql-view-recent-items
This commit is contained in:
parent
ab3d1178b9
commit
c2ecbc67a5
3 changed files with 24 additions and 35 deletions
|
|
@ -170,6 +170,10 @@ Here's an example of using it to generate an agenda-like view for certain files
|
||||||
|
|
||||||
Choose and display a view stored in ~org-ql-views~.
|
Choose and display a view stored in ~org-ql-views~.
|
||||||
|
|
||||||
|
*** org-ql-view-recent-items
|
||||||
|
|
||||||
|
Show items in ~FILES~ from last ~DAYS~ days with timestamps of ~TYPE~. ~TYPE~ may be ~ts~, ~ts-active~, ~ts-inactive~, ~clocked~, ~closed~, ~deadline~, ~planning~, or ~scheduled~. =FILES= defaults to those returned by the function =org-agenda-files=.
|
||||||
|
|
||||||
** Queries
|
** Queries
|
||||||
|
|
||||||
A query is a lisp form which may contain arbitrary lisp forms, as well as certain built-in predicates. It is byte-compiled into a predicate function which is tested with point on each heading in an Org buffer; when it returns non-nil, the heading matches the query.
|
A query is a lisp form which may contain arbitrary lisp forms, as well as certain built-in predicates. It is byte-compiled into a predicate function which is tested with point on each heading in an Org buffer; when it returns non-nil, the heading matches the query.
|
||||||
|
|
|
||||||
19
examples.org
19
examples.org
|
|
@ -10,24 +10,9 @@
|
||||||
|
|
||||||
* Show entries with recent timestamps
|
* Show entries with recent timestamps
|
||||||
|
|
||||||
#+BEGIN_SRC elisp
|
You can also access these views with the command ~org-ql-view~.
|
||||||
(cl-defun org-ql-view-recent-items (days &optional (type 'ts))
|
|
||||||
"Show items from previous DAYS days with timestamps of TYPE.
|
|
||||||
TYPE may be `ts', `ts-active', `ts-inactive', `clocked',
|
|
||||||
`closed', `deadline', `planning', or `scheduled'."
|
|
||||||
(interactive (list (read-number "Days: ")
|
|
||||||
(->> '(ts ts-active ts-inactive clocked closed deadline planning scheduled)
|
|
||||||
(completing-read "Timestamp type: ")
|
|
||||||
intern)))
|
|
||||||
(org-ql-search (org-agenda-files)
|
|
||||||
`(,type ,days)
|
|
||||||
:title "Recent items"
|
|
||||||
:sort '(date priority todo)
|
|
||||||
:groups '((:todo "DONE")
|
|
||||||
(:name "Log" :category "log" :tag "log")
|
|
||||||
(:auto-parent t)
|
|
||||||
(:auto-todo t))))
|
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
;; Show entries with any timestamp from last 7 days:
|
;; Show entries with any timestamp from last 7 days:
|
||||||
(org-ql-view-recent-items 7)
|
(org-ql-view-recent-items 7)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,24 +80,7 @@ Based on `org-agenda-mode-map'.")
|
||||||
;;;; Customization
|
;;;; Customization
|
||||||
|
|
||||||
(defcustom org-ql-views
|
(defcustom org-ql-views
|
||||||
(list (cons "Recent entries" (cl-function
|
(list (cons "Recent entries" #'org-ql-view-recent-items)
|
||||||
(lambda (days &optional (type 'ts))
|
|
||||||
(interactive (list (read-number "Days: ")
|
|
||||||
(->> '(ts ts-active ts-inactive clocked closed deadline planning scheduled)
|
|
||||||
(completing-read "Timestamp type: ")
|
|
||||||
intern)))
|
|
||||||
(let ((from (->> (ts-now)
|
|
||||||
(ts-adjust 'day (* -1 days))
|
|
||||||
(ts-apply :hour 0 :minute 0 :second 0)
|
|
||||||
;; Formatting isn't required, but it looks better in the header than a struct.
|
|
||||||
ts-format)))
|
|
||||||
(org-ql-search (org-agenda-files)
|
|
||||||
`(,type :from ,from :to ,(ts-format (ts-now)))
|
|
||||||
:title "Recent Entries"
|
|
||||||
:sort '(date priority todo)
|
|
||||||
:groups '((:todo "DONE")
|
|
||||||
(:auto-parent t)
|
|
||||||
(:auto-todo t)))))))
|
|
||||||
(cons "Stuck Projects" (lambda ()
|
(cons "Stuck Projects" (lambda ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(org-ql-search (org-agenda-files)
|
(org-ql-search (org-agenda-files)
|
||||||
|
|
@ -282,6 +265,23 @@ TITLE: An optional string displayed in the header."
|
||||||
(interactive (list (completing-read "View: " (mapcar #'car org-ql-views))))
|
(interactive (list (completing-read "View: " (mapcar #'car org-ql-views))))
|
||||||
(call-interactively (alist-get view org-ql-views nil nil #'string=)))
|
(call-interactively (alist-get view org-ql-views nil nil #'string=)))
|
||||||
|
|
||||||
|
(cl-defun org-ql-view-recent-items (days &optional (type 'ts) (files (org-agenda-files)))
|
||||||
|
"Show items in FILES from last DAYS days with timestamps of TYPE.
|
||||||
|
TYPE may be `ts', `ts-active', `ts-inactive', `clocked',
|
||||||
|
`closed', `deadline', `planning', or `scheduled'."
|
||||||
|
(interactive (list (read-number "Days: ")
|
||||||
|
(->> '(ts ts-active ts-inactive clocked closed deadline planning scheduled)
|
||||||
|
(completing-read "Timestamp type: ")
|
||||||
|
intern)))
|
||||||
|
(org-ql-search files
|
||||||
|
`(,type ,days)
|
||||||
|
:title "Recent items"
|
||||||
|
:sort '(date priority todo)
|
||||||
|
:groups '((:todo "DONE")
|
||||||
|
(:name "Log" :category "log" :tag "log")
|
||||||
|
(:auto-parent t)
|
||||||
|
(:auto-todo t))))
|
||||||
|
|
||||||
;;;; Functions
|
;;;; Functions
|
||||||
|
|
||||||
;; 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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue