aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-26 14:21:20 -0500
committerCraig Jennings <c@cjennings.net>2026-05-26 14:21:20 -0500
commit6c7f9ae225b91dee81a04d2271a6648924c0f3cf (patch)
tree2ca709a04afa25f7d106a425e8cf438f62ddd55d /modules
parentfcf3e0f89f47cd377612406c62448b0bf626b389 (diff)
downloaddotemacs-6c7f9ae225b91dee81a04d2271a6648924c0f3cf.tar.gz
dotemacs-6c7f9ae225b91dee81a04d2271a6648924c0f3cf.zip
feat(slack): open rooms in another window, never the selected one
slack-buffer-function defaulted to switch-to-buffer-other-window, which gives no real guarantee about placement: with three or more panes it picks a least-recently-used window, and it offers nothing that keeps Slack out of the window point is in. So opening a room in a split could land it wherever, including over the buffer I was working in. I set slack-buffer-function to cj/slack--display-buffer, a pop-to-buffer call with inhibit-same-window and a reuse / use-some-window / pop-up-window action list. In a split it reuses one of the other windows and leaves the selected window alone; with a lone window it splits. Tests cover both the split-placement case and the selected-window-preserved invariant.
Diffstat (limited to 'modules')
-rw-r--r--modules/slack-config.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/slack-config.el b/modules/slack-config.el
index 48af9c93..0902ef35 100644
--- a/modules/slack-config.el
+++ b/modules/slack-config.el
@@ -102,6 +102,20 @@
(slack-ws-close)
(message "Slack disconnected."))
+(defun cj/slack--display-buffer (buffer)
+ "Display Slack BUFFER in another window, never the selected one.
+With a split, reuse one of the other windows rather than taking over the
+window point is in or always spawning a fresh split; with a lone window,
+split. Wired as `slack-buffer-function' so opening a room or thread lands
+beside the current work instead of clobbering it. The default
+`switch-to-buffer-other-window' picks a least-recently-used window with three
+or more panes; this pins the choice to any non-selected window."
+ (pop-to-buffer buffer
+ '((display-buffer-reuse-window
+ display-buffer-use-some-window
+ display-buffer-pop-up-window)
+ (inhibit-same-window . t))))
+
(use-package slack
:defer t
:commands (slack-start slack-select-rooms slack-select-unread-rooms
@@ -114,6 +128,9 @@
;; Re-enable if emojify/circe fix the interaction. (2026-03-16)
(slack-buffer-emojify nil)
(slack-prefer-current-team t)
+ ;; Open rooms/threads in another window, never the selected one (see
+ ;; cj/slack--display-buffer) so Slack lands beside the current work in a split.
+ (slack-buffer-function #'cj/slack--display-buffer)
:config
(setq slack-message-custom-notifier #'cj/slack-notify))