From b3e8eeff931ef1f775d34c7f2a519a487f76f7ff Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 12 Jun 2025 09:55:19 -0400 Subject: [PATCH] [emacs] Still trying to get clock to update --- emacs/.config/doom/config.el | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/emacs/.config/doom/config.el b/emacs/.config/doom/config.el index ae1c513..0a66670 100644 --- a/emacs/.config/doom/config.el +++ b/emacs/.config/doom/config.el @@ -344,6 +344,17 @@ Returns the ID string." (save-buffer)) ;; optional: save file after inserting ID id)) +(defun org-clock-on-state-change () + "Clock in when state is STRT, clock out otherwise." + (when (and (derived-mode-p 'org-mode) + (not (org-before-first-heading-p))) + (pcase org-state + ("STRT" + (unless org-clock-marker + (org-clock-in))) + ((or "DONE" "CANC" "WAIT" "HOLD" "TODO") + (when org-clock-marker + (org-clock-out)))))) (defun send-org-todo-to-endpoint-on-state-change () "Send the current Org-mode TODO item to an HTTP endpoint." @@ -360,7 +371,7 @@ Returns the ID string." (todo-id (my-org-get-or-create-id)) (body (org-get-body-stripped)) (notes (org-extract-notes)) - ;;(properties (org-entry-properties)) + (properties (org-entry-properties)) (endpoint "https://life.lab.unbl.ink/webhook/emacs/") (data `(("description" . ,heading) ("labels" . ,tags) @@ -386,20 +397,8 @@ Returns the ID string." (message "Sent TODO: %s" data))) :error (cl-function (lambda (&rest args &key error-thrown &allow-other-keys) - (message "Error sending TODO: %S" error-thrown))))))))) + (message "Error sending TODO: %S" error-thrown)))))) + (org-clock-on-state-change) + ))) -(defun org-clock-on-state-change () - "Clock in when state is STRT, clock out otherwise." - (when (and (derived-mode-p 'org-mode) - (not (org-before-first-heading-p))) - (pcase org-state - ("STRT" - (unless org-clock-marker - (org-clock-in))) - ((or "DONE" "CANC" "WAIT" "HOLD" "TODO") - (when org-clock-marker - (org-clock-out)))))) - -(add-hook 'org-after-todo-state-change-hook #'org-clock-on-state-change) (add-hook 'org-after-todo-state-change-hook #'send-org-todo-to-endpoint-on-state-change) - ;(setq org-clock-out-when-done t)