From 3a639902a084f64dff16cee9cc9ff95c659d93b3 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Tue, 2 Dec 2025 17:15:33 -0800 Subject: [PATCH] Helper functions for clocking in and out Called by Hammerspoon script when laptop lid closes. --- ha-org.org | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ha-org.org b/ha-org.org index fb734d3..3f392c3 100644 --- a/ha-org.org +++ b/ha-org.org @@ -3,7 +3,7 @@ #+date: 2020-09-18 #+tags: emacs org #+startup: inlineimages -#+lastmod: [2025-07-01 Tue] +#+lastmod: [2025-12-02 Tue] A literate programming file for configuring org-mode and those files. @@ -245,6 +245,32 @@ And I would like to have cute little icons for those states: ("^ +\\([-*]\\) " (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))) #+end_src + +What was + +#+BEGIN_SRC emacs-lisp +(defun display-latest-clocked-task () + "Display the name of the latest task that was clocked in." + (interactive) + (let ((latest-task (car (org-clock-get-clock-string)))) + (if latest-task + (message "Latest clocked task: %s" latest-task) + (message "No task is currently clocked in.")))) + +#+END_SRC + +Need to be able to clock out of a task even if no /clock-in/ has occurred. + +#+BEGIN_SRC emacs-lisp + (defun ha-clock-out () + "Safely clock out of the current task. + This will not throw an error if not active clock exists." + (interactive) + (ignore-errors + (org-clock-out) + (message "Clocked out."))) +#+END_SRC + ** Meetings I've notice that while showing a screen while taking meeting notes, I don't always like showing other windows, so I created this function to remove distractions during a meeting.