aboutsummaryrefslogtreecommitdiff
path: root/modules/transcription-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-19 07:10:17 -0500
committerCraig Jennings <c@cjennings.net>2026-04-19 07:10:17 -0500
commite18d90875c221b489a568421e8356c1ec8fdfe85 (patch)
treeb5c606fd25011023a19fbb9648e697bcd7fddf77 /modules/transcription-config.el
parent13c057a75ce6d92f9de7e1d53d0ae2554261cb2e (diff)
downloaddotemacs-e18d90875c221b489a568421e8356c1ec8fdfe85.tar.gz
dotemacs-e18d90875c221b489a568421e8356c1ec8fdfe85.zip
refactor(transcription): extract init-log-file and track-transcription
Pull two more helpers out of cj/--start-transcription-process: - cj/--init-log-file: writes the initial log header with timestamp, backend, audio file, script path - cj/--track-transcription: pushes a running-status entry and refreshes the modeline Start-process shrinks from 58 lines with 4 levels of nesting to ~25 lines mostly at depth 1-2. 10 tests cover the extracted helpers.
Diffstat (limited to 'modules/transcription-config.el')
-rw-r--r--modules/transcription-config.el30
1 files changed, 16 insertions, 14 deletions
diff --git a/modules/transcription-config.el b/modules/transcription-config.el
index 69111a11..e8fe1159 100644
--- a/modules/transcription-config.el
+++ b/modules/transcription-config.el
@@ -132,6 +132,20 @@ a key but none is found in authinfo.gpg."
(user-error "API key not found in authinfo.gpg for host %s" auth-host))
process-environment)))
+(defun cj/--init-log-file (log-file audio-file script)
+ "Create LOG-FILE with a header recording the start of transcription.
+Records the current time, active backend, AUDIO-FILE, and SCRIPT path."
+ (with-temp-file log-file
+ (insert (format "Transcription started: %s\n" (current-time-string))
+ (format "Backend: %s\n" cj/transcribe-backend)
+ (format "Audio file: %s\n" audio-file)
+ (format "Script: %s\n\n" script))))
+
+(defun cj/--track-transcription (process audio-file)
+ "Push a running-status entry for PROCESS and AUDIO-FILE, refresh modeline."
+ (push (list process audio-file (current-time) 'running) cj/transcriptions-list)
+ (force-mode-line-update t))
+
;; ---------------------------- Process Management -----------------------------
(defun cj/--notify (title message &optional urgency)
@@ -164,14 +178,8 @@ Returns the process object."
(unless (file-executable-p script)
(user-error "Transcription script not found or not executable: %s" script))
- ;; Create log file
- (with-temp-file log-file
- (insert (format "Transcription started: %s\n" (current-time-string))
- (format "Backend: %s\n" cj/transcribe-backend)
- (format "Audio file: %s\n" audio-file)
- (format "Script: %s\n\n" script)))
+ (cj/--init-log-file log-file audio-file script)
- ;; Start process with environment
(let* ((process-environment (cj/--build-process-environment cj/transcribe-backend))
(process (make-process
:name process-name
@@ -180,15 +188,9 @@ Returns the process object."
:sentinel (lambda (proc event)
(cj/--transcription-sentinel proc event audio-file txt-file log-file))
:stderr log-file)))
-
- ;; Track transcription
- (push (list process audio-file (current-time) 'running) cj/transcriptions-list)
- (force-mode-line-update t)
-
- ;; Notify user
+ (cj/--track-transcription process audio-file)
(cj/--notify "Transcription"
(format "Started on %s" (file-name-nondirectory audio-file)))
-
process)))
(defun cj/--transcription-sentinel (process event audio-file txt-file log-file)