From 63035cff73b0f93ceb3785cda1cd4a1f068ec58c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 14 Jun 2026 15:47:55 -0500 Subject: fix(slack): autoload w/@/# commands, guard close-all, register the prefix Three lifecycle gaps that bit before slack loads. The w / @ / # keys bound slack-message-write-another-buffer, slack-message-embed-mention, and slack-message-embed-channel, none autoloaded or in :commands, so they void-function'd before slack started; added them to :commands. cj/slack-close-all-buffers read slack-current-buffer via buffer-local-value on every buffer, which signals void-variable on buffers without the local binding; it now guards with buffer-local-boundp like its sibling. And C-; S was bound with a raw global-set-key, invisible to the keybindings registry; it now registers through cj/register-prefix-map like the signal and erc prefixes. --- tests/test-slack-config-close-all.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test-slack-config-close-all.el (limited to 'tests') diff --git a/tests/test-slack-config-close-all.el b/tests/test-slack-config-close-all.el new file mode 100644 index 000000000..a7f5423b8 --- /dev/null +++ b/tests/test-slack-config-close-all.el @@ -0,0 +1,32 @@ +;;; test-slack-config-close-all.el --- cj/slack-close-all-buffers guard -*- lexical-binding: t; -*- + +;;; Commentary: +;; cj/slack-close-all-buffers iterates every buffer. It must not signal +;; void-variable when `slack-current-buffer' has no binding in a buffer (slack +;; not loaded), and must kill only buffers where it is set non-nil. The original +;; read it with `buffer-local-value' (which errors on buffers without the local +;; binding) instead of guarding like its sibling cj/slack-mark-read-and-bury. + +;;; Code: + +(require 'ert) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'slack-config) + +(ert-deftest test-slack-close-all-buffers-skips-unbound-kills-slack () + "Error/Normal: no signal on buffers without `slack-current-buffer'; only +buffers that have it set non-nil are killed." + (let ((plain (generate-new-buffer " *plain*")) + (slackish (generate-new-buffer " *slackish*"))) + (with-current-buffer slackish (setq-local slack-current-buffer t)) + (unwind-protect + (progn + (cj/slack-close-all-buffers) + (should (buffer-live-p plain)) + (should-not (buffer-live-p slackish))) + (when (buffer-live-p plain) (kill-buffer plain)) + (when (buffer-live-p slackish) (kill-buffer slackish))))) + +(provide 'test-slack-config-close-all) +;;; test-slack-config-close-all.el ends here -- cgit v1.2.3