aboutsummaryrefslogtreecommitdiff
path: root/modules/mail-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-10 14:04:22 -0500
committerCraig Jennings <c@cjennings.net>2026-05-10 14:04:22 -0500
commitc75e36f4ec6764142499a3ec965d25895c564cb0 (patch)
treea6435a99ee57afa47ea6905faea6078938ae1578 /modules/mail-config.el
parent502bcf41c7258b169d6481676c59c42e0e931e7c (diff)
downloaddotemacs-c75e36f4ec6764142499a3ec965d25895c564cb0.tar.gz
dotemacs-c75e36f4ec6764142499a3ec965d25895c564cb0.zip
refactor(system-lib): extract cj/executable-find-or-warn from mail-config
Phase 2 of utility-consolidation, first commit per the spec's recommended order. `cj/mail--executable-or-warn' was the right pattern -- check executable-find, return the path, otherwise emit a clear `display-warning' naming the feature -- but it was trapped in mail-config and only mail callers benefited. Lift it into `cj/executable-find-or-warn' in system-lib.el with one new argument: an optional GROUP symbol that flows through to `display-warning' (defaulting to `cj/system-lib') so per-feature warning filters keep working. Mail callers pass `mail-config' explicitly. Migrate `cj/mail--mbsync-command' and `cj/mail-configure-smtpmail' to the new helper. Drop the local definition. Add `(require \='system-lib)' to mail-config.el per the spec's Phase 2 exit criterion ("consumer modules explicitly require system-lib"). Five Normal/Boundary tests cover the four return-shape cases (program found / program missing / warning content / default vs explicit group). Other consumers (prog-*.el, dirvish-config.el, browser-config.el) still call `executable-find' directly. Migrating them is a follow-up commit, audited per call site -- the spec flags some `:if' silent checks as intentional and they should NOT switch to the warning helper.
Diffstat (limited to 'modules/mail-config.el')
-rw-r--r--modules/mail-config.el19
1 files changed, 5 insertions, 14 deletions
diff --git a/modules/mail-config.el b/modules/mail-config.el
index f19adf80..7a41e942 100644
--- a/modules/mail-config.el
+++ b/modules/mail-config.el
@@ -25,6 +25,7 @@
;;; Code:
(require 'user-constants)
+(require 'system-lib)
;; cj/custom-keymap's real binding is in keybindings.el, which init.el loads
;; first. The use-package org-msg :preface below wraps in eval-and-compile, so
@@ -63,27 +64,17 @@ transport details in debug buffers."
(interactive)
(cj/set-smtpmail-debug (not smtpmail-debug-info)))
-(defun cj/mail--executable-or-warn (program feature)
- "Return PROGRAM's executable path, or warn that FEATURE is unavailable."
- (or (executable-find program)
- (progn
- (display-warning
- 'mail-config
- (format "%s not found; %s unavailable" program feature)
- :warning)
- nil)))
-
(defun cj/mail--mbsync-command ()
"Return the mu4e mail sync command, or nil if mbsync is unavailable."
- (when-let ((mbsync (cj/mail--executable-or-warn
- "mbsync" "mu4e mail synchronization")))
+ (when-let ((mbsync (cj/executable-find-or-warn
+ "mbsync" "mu4e mail synchronization" 'mail-config)))
(concat (shell-quote-argument mbsync) " -a")))
(defun cj/mail-configure-smtpmail ()
"Configure SMTP mail transport when msmtp is available."
(setq smtpmail-debug-info cj/smtpmail-debug-enabled)
- (if-let ((msmtp (cj/mail--executable-or-warn
- "msmtp" "SMTP mail sending")))
+ (if-let ((msmtp (cj/executable-find-or-warn
+ "msmtp" "SMTP mail sending" 'mail-config)))
(setq sendmail-program msmtp
send-mail-function 'message-send-mail-with-sendmail
message-send-mail-function 'message-send-mail-with-sendmail