aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/slack-config.el5
-rw-r--r--tests/test-slack-config-reactions.el8
2 files changed, 12 insertions, 1 deletions
diff --git a/modules/slack-config.el b/modules/slack-config.el
index 9eb9f838..e0ad5b75 100644
--- a/modules/slack-config.el
+++ b/modules/slack-config.el
@@ -197,7 +197,10 @@ so the Slack buffer stays usable."
"Add a reaction to the current Slack message using a curated shortlist.
Errors if called outside a Slack message buffer."
(interactive)
- (let ((buf (or slack-current-buffer
+ ;; boundp guard: the defvar above declares the var with no value, so it is
+ ;; void until slack.el loads -- a bare read on a cold call would signal
+ ;; void-variable instead of this friendly error.
+ (let ((buf (or (and (boundp 'slack-current-buffer) slack-current-buffer)
(user-error "Not in a Slack buffer"))))
(when-let* ((team (slack-buffer-team buf))
(reaction (cj/slack-select-reaction team)))
diff --git a/tests/test-slack-config-reactions.el b/tests/test-slack-config-reactions.el
index 491b8147..bfcf3e29 100644
--- a/tests/test-slack-config-reactions.el
+++ b/tests/test-slack-config-reactions.el
@@ -92,5 +92,13 @@
(let ((slack-current-buffer nil))
(should-error (cj/slack-message-add-reaction) :type 'user-error)))
+(ert-deftest test-slack-config-message-add-reaction-errors-before-slack-loads ()
+ "Error: a cold call before slack.el ever loads gives the friendly user-error.
+The module defvars slack-current-buffer with no value, so until slack.el
+binds it the variable is void -- a bare read signals void-variable instead
+of the intended \"Not in a Slack buffer\"."
+ (makunbound 'slack-current-buffer)
+ (should-error (cj/slack-message-add-reaction) :type 'user-error))
+
(provide 'test-slack-config-reactions)
;;; test-slack-config-reactions.el ends here