From 5ef49fc9d3b0f2fc3e46f833adc5b1e4ced631f3 Mon Sep 17 00:00:00 2001 From: Boris Buliga Date: Mon, 6 Jan 2025 16:50:28 +0200 Subject: [PATCH] emacs:vulpea:agenda: include current quarter --- emacs/lisp/init-vulpea.el | 3 ++- emacs/lisp/lib-vulpea-agenda.el | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/emacs/lisp/init-vulpea.el b/emacs/lisp/init-vulpea.el index c929a38e..38996806 100644 --- a/emacs/lisp/init-vulpea.el +++ b/emacs/lisp/init-vulpea.el @@ -335,7 +335,8 @@ (,vulpea-agenda-cmd-refile ,vulpea-agenda-cmd-today ,vulpea-agenda-cmd-focus - ,vulpea-agenda-cmd-waiting) + ,vulpea-agenda-cmd-waiting + ,vulpea-agenda-cmd-current-quarter) ((org-agenda-buffer-name vulpea-agenda-main-buffer-name)))))) diff --git a/emacs/lisp/lib-vulpea-agenda.el b/emacs/lisp/lib-vulpea-agenda.el index b4bf7195..eb30bc4b 100644 --- a/emacs/lisp/lib-vulpea-agenda.el +++ b/emacs/lisp/lib-vulpea-agenda.el @@ -167,6 +167,28 @@ Affects the following commands: (org-agenda-todo-ignore-deadlines vulpea-agenda-hide-scheduled-and-waiting-next-tasks)))) +;;;###autoload +(defconst vulpea-agenda-cmd-current-quarter + (let ((quarter (vulpea-agenda-current-quarter (current-time)))) + `(tags-todo + ,quarter + ((org-agenda-overriding-header + (concat "Tasks for" ,quarter + (if vulpea-agenda-hide-scheduled-and-waiting-next-tasks + "" + " (including WAITING and SCHEDULED tasks)"))) + (org-agenda-skip-function 'vulpea-agenda-skip-habits) + (org-tags-match-list-sublevels t) + (org-agenda-todo-ignore-scheduled + vulpea-agenda-hide-scheduled-and-waiting-next-tasks) + (org-agenda-todo-ignore-deadlines + vulpea-agenda-hide-scheduled-and-waiting-next-tasks) + (org-agenda-todo-ignore-with-date + vulpea-agenda-hide-scheduled-and-waiting-next-tasks) + (org-agenda-tags-todo-honor-ignore-options t) + (org-agenda-sorting-strategy + '(todo-state-down priority-down effort-up category-keep)))))) + ;; Utilities to build agenda commands -- skip @@ -347,6 +369,20 @@ Refer to `org-agenda-prefix-format' for more information." result)) (s-repeat (or len 0) " "))) +;;;###autoload +(defun vulpea-agenda-current-quarter (time) + "Return the quarter of the given TIME in the format YYQn (e.g. 25Q1)." + (let* ((decoded (decode-time time)) + (year (nth 5 decoded)) + (month (nth 4 decoded)) + (yy (mod year 100)) ;; last two digits of the year + (quarter (cond + ((<= month 3) "Q1") + ((<= month 6) "Q2") + ((<= month 9) "Q3") + (t "Q4")))) + (format "%02d%s" yy quarter))) + (provide 'lib-vulpea-agenda)