summaryrefslogtreecommitdiff
path: root/modules/transcription-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-22 19:32:32 -0500
committerCraig Jennings <c@cjennings.net>2026-05-22 19:32:32 -0500
commitab320f6884bef3fb21567b6f1ad8a734eaa16a41 (patch)
tree811b7ec002fad81f1a0c024625d6b4de682a244a /modules/transcription-config.el
parente9b3570fab05a39b88d71183dec66357e47ebb24 (diff)
downloaddotemacs-ab320f6884bef3fb21567b6f1ad8a734eaa16a41.tar.gz
dotemacs-ab320f6884bef3fb21567b6f1ad8a734eaa16a41.zip
refactor(auth): consolidate the auth-source secret lookup into one helper
The auth-source-search + funcall-the-secret block was copied four times: calendar-sync--calendar-url, cj/auth-source-secret (ai-config), cj/--auth-source-password (transcription), and cj/slack--get-credential. Each searched authinfo, pulled :secret, and called it when the netrc backend returned a function. I pulled that into cj/auth-source-secret-value in system-lib (a leaf, so calendar-sync doesn't have to depend on ai-config and drag in the gptel stack). It takes an optional user and returns the secret or nil. The four callers now delegate to it: ai-config layers its required-secret error on top, and the others keep their nil-on-miss behavior. With the direct auth-source-search calls gone, I dropped the now-unused (require 'auth-source) from transcription, slack, and calendar-sync. The helper's autoload covers it. The transcription tests that exercise the delegated path stay green, and the primitive and the error wrapper get their own tests.
Diffstat (limited to 'modules/transcription-config.el')
-rw-r--r--modules/transcription-config.el12
1 files changed, 4 insertions, 8 deletions
diff --git a/modules/transcription-config.el b/modules/transcription-config.el
index d81ccba0..344ec473 100644
--- a/modules/transcription-config.el
+++ b/modules/transcription-config.el
@@ -38,7 +38,7 @@
(require 'dired)
(require 'notifications)
-(require 'auth-source)
+(require 'system-lib) ; provides cj/auth-source-secret-value
(require 'user-constants) ; For cj/audio-file-extensions
;; Declare keymap defined in keybindings.el
@@ -121,14 +121,10 @@ SUCCESS-P indicates whether transcription succeeded."
(expand-file-name (concat "scripts/" script-name) user-emacs-directory)))
(defun cj/--auth-source-password (host)
- "Retrieve password for HOST from authinfo.gpg.
-Expects entry like: machine HOST login api password <key>.
+ "Retrieve the auth-source secret for HOST from authinfo.gpg.
+Expects an entry like: machine HOST login api password <key>.
Returns the password string, or nil if no matching entry exists."
- (when-let* ((auth-info (car (auth-source-search :host host :require '(:secret))))
- (secret (plist-get auth-info :secret)))
- (if (functionp secret)
- (funcall secret)
- secret)))
+ (cj/auth-source-secret-value host))
(defun cj/--build-process-environment (backend)
"Return `process-environment' augmented with BACKEND's API-key env var.