From c123250c3cf928864aab118e1b9bfbaf9e1102b3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 14 May 2026 08:07:33 -0500 Subject: feat(telega-config): guard launcher with a helpful message when telega is missing Without the guard, both `C-; G' and the dashboard Telegram icon trigger telega's autoload stub directly. When the package isn't installed yet the user sees `Cannot open load file: telega' in `*Messages*' with no hint about what to do. Wrap the launcher in `cj/telega' that checks `featurep' / `locate-library' first. If telega is present, delegate to it. Otherwise signal a `user-error' pointing at `scripts/setup-telega.sh' and the manual `M-x package-install RET telega' fallback. Rebind `C-; G' and the dashboard "g" key + Telegram icon callback to the wrapper. Two new tests in `test-telega-config.el' cover the wrapper paths (absent -> user-error with the recovery hint; present -> delegates to `telega') alongside the updated binding assertion. --- tests/test-telega-config.el | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-telega-config.el b/tests/test-telega-config.el index ace96555..c642d1f6 100644 --- a/tests/test-telega-config.el +++ b/tests/test-telega-config.el @@ -18,8 +18,33 @@ (should (featurep 'telega-config))) (ert-deftest test-telega-config-launcher-binding-is-telega () - "Normal: =C-; G= invokes `telega'." - (should (eq (keymap-lookup cj/custom-keymap "G") #'telega))) + "Normal: =C-; G= invokes the launcher wrapper, which routes to +`telega' when installed or signals a helpful user-error otherwise." + (should (eq (keymap-lookup cj/custom-keymap "G") #'cj/telega))) + +(ert-deftest test-telega-config-launcher-without-package-signals-user-error () + "Error: with telega absent, the launcher signals a `user-error' that +mentions the recovery path instead of falling through to the autoload +stub's cryptic load-file failure." + (cl-letf (((symbol-function 'featurep) + (lambda (sym &optional _sub) + (and (not (eq sym 'telega)) t))) + ((symbol-function 'locate-library) + (lambda (lib &rest _) (unless (equal lib "telega") t)))) + (let* ((err (should-error (cj/telega) :type 'user-error)) + (msg (error-message-string err))) + (should (string-match-p "telega not installed" msg)) + (should (string-match-p "setup-telega\\.sh\\|package-install" msg))))) + +(ert-deftest test-telega-config-launcher-with-package-calls-telega () + "Normal: with telega loadable, the launcher delegates to `telega'." + (let (called) + (cl-letf (((symbol-function 'featurep) + (lambda (sym &optional _sub) (eq sym 'telega))) + ((symbol-function 'telega) + (lambda (&rest _) (setq called t)))) + (cj/telega)) + (should called))) (provide 'test-telega-config) ;;; test-telega-config.el ends here -- cgit v1.2.3