diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-10 14:04:22 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-10 14:04:22 -0500 |
| commit | c75e36f4ec6764142499a3ec965d25895c564cb0 (patch) | |
| tree | a6435a99ee57afa47ea6905faea6078938ae1578 /modules/system-lib.el | |
| parent | 502bcf41c7258b169d6481676c59c42e0e931e7c (diff) | |
| download | dotemacs-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/system-lib.el')
| -rw-r--r-- | modules/system-lib.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/system-lib.el b/modules/system-lib.el index 4c2f17ef..f932353f 100644 --- a/modules/system-lib.el +++ b/modules/system-lib.el @@ -17,6 +17,25 @@ PROGRAM should be a string naming an executable program." (not (string-empty-p program)) (executable-find program))) +(defun cj/executable-find-or-warn (program feature &optional group) + "Return PROGRAM's executable path, or warn that FEATURE is unavailable. + +When PROGRAM is in PATH, return its absolute path. When it isn't, +emit a `display-warning' naming PROGRAM and FEATURE so the user gets +a clear hint about what won't work, and return nil. + +GROUP is the symbol passed to `display-warning' for filtering and +defaults to `cj/system-lib'. Callers should pass their own module +symbol (for example `mail-config') so per-feature warning filters +keep working." + (or (executable-find program) + (progn + (display-warning + (or group 'cj/system-lib) + (format "%s not found; %s unavailable" program feature) + :warning) + nil))) + (defun cj/log-silently (format-string &rest args) "Append formatted message (FORMAT-STRING with ARGS) to *Messages* buffer. This does so without echoing in the minibuffer." |
