start work on marking habits as skipped the previous day for better tracking (has bug on scheduled date currently)

This commit is contained in:
KemoNine 2022-09-02 10:44:08 -04:00
parent 189bbea314
commit 51ee49b12b
1 changed files with 32 additions and 0 deletions

View File

@ -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