[emacs] Still trying to get clock to update

This commit is contained in:
2025-06-12 09:55:19 -04:00
parent 9e8f9946d6
commit b3e8eeff93

View File

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