From 51ee49b12bbe5a27a98df8617c784fabd3990429 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Fri, 2 Sep 2022 10:44:08 -0400 Subject: [PATCH] start work on marking habits as skipped the previous day for better tracking (has bug on scheduled date currently) --- org/config-org-agendas.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/org/config-org-agendas.el b/org/config-org-agendas.el index f6debd2..39088e9 100644 --- a/org/config-org-agendas.el +++ b/org/config-org-agendas.el @@ -16,6 +16,33 @@ ) ) +; https://emacs.stackexchange.com/questions/9433/how-to-make-org-prompt-for-a-timestamp-when-changing-state-of-a-todo/63809 +; https://stackoverflow.com/questions/25437069/how-can-i-mark-org-habits-as-done-in-the-past +(defun kmn/org-habit-with-date (&optional arg) + (interactive "P") + (cl-letf* ((org-read-date-prefer-future nil) + (my-current-time (org-read-date t t nil "when:" nil nil nil)) + ((symbol-function 'current-time) + #'(lambda () my-current-time)) + ((symbol-function 'org-today) + #'(lambda () (time-to-days my-current-time))) + ((symbol-function 'org-current-effective-time) + #'(lambda () my-current-time)) + + (super-org-entry-put (symbol-function 'org-entry-put)) + ((symbol-function 'org-entry-put) + #'(lambda (pom property value) + (print property) + (if (lambda (or (equal property "LAST_REPEAT") (equal property "SCHEDULED"))) + (let ((my-value (format-time-string (org-time-stamp-format t t) my-current-time))) + (funcall super-org-entry-put pom property my-value)) + (funcall super-org-entry-put pom property value) + )))) + (if (eq major-mode 'org-agenda-mode) (org-agenda-todo arg) (org-todo arg)) + ) + (org-schedule arg (format-time-string "%Y-%m-%d")) +) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; org-agenda tuning (view stuff only) (setq org-agenda-todo-ignore-scheduled 'all) @@ -27,6 +54,11 @@ (setq org-agenda-skip-timestamp-if-done t) ;; dont tend to care about tag inheritance outside of search (setq org-agenda-use-tag-inheritance nil) +;; add new option to update habit for yesterday and reschedule it as active today +(add-hook 'org-agenda-mode-hook + (lambda () + (local-set-key (kbd "y") 'kmn/org-habit-with-date))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Set some org agendas/dashboards