diff --git a/elisp/ha-focus.el b/elisp/ha-focus.el index 967d426..0185931 100644 --- a/elisp/ha-focus.el +++ b/elisp/ha-focus.el @@ -1,13 +1,18 @@ ;;; ha-focus.el --- Emacs lisp code to focus my thoughts. -*- lexical-binding: t; -*- ;; -;; Copyright (C) 2021 Howard X. Abrams +;; Copyright Ā© 2021,2024 Howard X. Abrams ;; ;; Author: Howard X. Abrams -;; Maintainer: Howard X. Abrams +;; Maintainer: Howard X. Abrams ;; Created: May 28, 2021 ;; ;; This file is not part of GNU Emacs. ;; +;;; Commentary: +;; +;; Find details of this code on my website at: +;; https://www.howardism.org/Technical/Emacs/focused-work.html +;; ;; *NB:* Do not edit this file. Instead, edit the original literate file at: ;; ~/website/Technical/Emacs/focused-work.org ;; And tangle the file to recreate this one. @@ -18,7 +23,7 @@ (defun ha-focus-countdown-timer (minutes fun) (let ((the-future (* minutes 60))) - (run-at-time the-future nil fun))) + (setq ha-focus-timer (run-at-time the-future nil fun)))) (defun ha-focus-begin () "Start a concerted, focused effort, ala Pomodoro Technique. @@ -31,44 +36,57 @@ Call `ha-focus-break' when finished." (ha-focus--command "tell application \"Spotify\" to play") (if (eq major-mode 'org-mode) (org-clock-in) - (org-clock-in-last))) + (org-clock-in-last)) + (message "šŸ… Started clocked %s" + (substring-no-properties + (org-clock-get-clock-string)))) (defun ha-focus-break () "Stop the focused time by stopping the music. This also starts another break timer, that calls `ha-focus-break-over' when finished." (interactive) - (run-with-idle-timer 5 nil 'ha-focus-capture) + (run-with-idle-timer 30 nil 'ha-focus-capture) (ha-focus--command "tell application \"Spotify\" to pause") - (message "Time to take a break.")) + (ha-focus-countdown-timer 5 'ha-focus-break-over) + (message "šŸ… Time to take a break.")) (defun ha-focus-capture () + "Spin up a capture window." (ignore-errors (org-capture nil "cc") (sit-for 1) - (org-clock-out)) - (ha-focus-countdown-timer 5 'ha-focus-break-over) - (message "Taking a much needed break...")) + (org-clock-out))) (defun ha-focus-break-over () "Message me to know that the break time is over. Notice that -this doesn't start anything automatically, as I may have simply +this doesn't start anything automatically, as I may have wandered off." (ha-focus--command "set v to output volume of (get volume settings) set volume output volume 1 say \"Break time over. Back on your head.\" -set volume output volume v")) +set volume output volume v") + (message "šŸ… Type to restart the timer.")) + +(defun ha-focus-interrupt () + "Interrupt the current focused timer, if set." + (interactive) + (when (timerp ha-focus-timer) + (cancel-timer ha-focus-timer) + (ignore-errors + (org-clock-out)))) + +(require 'async) (defun ha-focus--command (osascript) "Runs OSASCRIPT by passing to the `osascript' command asynchronously." - (async-start-process "focus-os" "osascript" 'ha-focus--command-callback "-e" osascript)) + (async-start-process "focus-os" "osascript" + 'ha-focus--command-callback "-e" osascript)) (defun ha-focus--command-callback (proc) "Asynchronously called when the `osascript' process finishes." - (message "Finished calling osascript.")) - -(global-set-key (kbd "") 'ha-focus-begin) -(global-set-key (kbd "S-") 'ha-focus-break) + ;; ... + ) (provide 'ha-focus) ;;; ha-focus.el ends here diff --git a/ha-config.org b/ha-config.org index 630e2ed..2407b0c 100644 --- a/ha-config.org +++ b/ha-config.org @@ -24,8 +24,7 @@ A literate programming file for configuring Emacs. ;; ;;; Commentary: ;; - ;; Basic configuration of Emacs. Should be executed early in the - ;; loading sequence. + ;; Basic configuration of Emacs. Start early in the loading sequence. ;; ;;; Code: #+end_src diff --git a/ha-general.org b/ha-general.org index ba7d9fd..bd29e0b 100644 --- a/ha-general.org +++ b/ha-general.org @@ -41,7 +41,7 @@ I'm not trying an experiment where specially-placed function keys on my fancy er :states '(normal visual motion) :keymaps 'override :prefix "SPC" - :non-normal-prefix "M-SPC" + :non-normal-prefix "s-SPC" :global-prefix "") (general-create-definer ha-local-leader diff --git a/ha-org.org b/ha-org.org index f2a079d..29decd9 100644 --- a/ha-org.org +++ b/ha-org.org @@ -3,7 +3,7 @@ #+date: 2020-09-18 #+tags: emacs org #+startup: inlineimages -#+lastmod: [2024-10-20 Sun] +#+lastmod: [2024-10-25 Fri] A literate programming file for configuring org-mode and those files. @@ -827,7 +827,11 @@ I've been working on my own [[http://www.howardism.org/Technical/Emacs/focused-w :config (ha-leader "o f" '("begin focus" . ha-focus-begin) - "o F" '("break focus" . ha-focus-break))) + "o F" '("break focus" . ha-focus-break)) + :bind + (("" . ha-focus-begin) + ("S-" . ha-focus-interrupt) + ("s-" . ha-focus-timer-left))) #+end_src ** Spell Checking Let's hook some spell-checking into org files, and actually all text files. Iā€™m making this particularly delicious.