From e17055ad34756567f694b8db4f33b4d950a472d1 Mon Sep 17 00:00:00 2001 From: Ankit Pandey Date: Sat, 24 Feb 2024 17:54:40 -0800 Subject: [PATCH] Add: (org-ql-view--format-element) effort properties Org uses the nested properties within the 'txt' property for effort-related computations. The contents of 'txt' itself are not used for anything (and is usually set to a string of the headline), so we do the same here. --- org-ql-view.el | 5 +++++ tests/test-org-ql.el | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/org-ql-view.el b/org-ql-view.el index 5889a567..a4579846 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -904,6 +904,8 @@ return an empty string." (file-name-sans-extension (file-name-nondirectory buffer-file-name)))))) "")) + (effort-string (org-element-property (intern (concat ":" (upcase org-effort-property))) element)) + (effort (when effort-string (org-duration-to-minutes effort-string))) (priority-string (-some->> (org-element-property :priority element) (char-to-string) (format "[#%s]") @@ -926,6 +928,9 @@ return an empty string." 'org-category category 'todo-state todo-keyword 'tags tag-list + 'txt (org-add-props string nil + 'effort effort-string + 'effort-minutes effort) 'org-habit-p habit-property))))) (defun org-ql-view--add-faces (element) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 8d2b84c0..b4e3e68f 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -176,6 +176,15 @@ with keyword arg NOW in PLIST." (cl-loop while (re-search-forward org-heading-regexp nil t) sum 1))))) + (describe "Agenda" + + (it "Sets effort properties for formatted element" + (let* ((element (car (org-ql-select org-ql-test-buffer '(effort 30)))) + (item (org-ql-view--format-element element)) + (txt (get-text-property 0 'txt item))) + (expect (get-text-property 0 'effort-minutes txt) :to-equal 30.0) + (expect (get-text-property 0 'effort txt) :to-equal "30")))) + (describe "Caching" (it "Clears value cache after buffer changes"