diff options
| -rw-r--r-- | modules/mail-config.el | 12 | ||||
| -rw-r--r-- | tests/test-mail-config-mu4e-window.el | 42 |
2 files changed, 54 insertions, 0 deletions
diff --git a/modules/mail-config.el b/modules/mail-config.el index a498844e..f71d6eeb 100644 --- a/modules/mail-config.el +++ b/modules/mail-config.el @@ -124,6 +124,18 @@ Prompts user for the action when executing." (autoload 'mu4e "mu4e" "Launch mu4e email client." t) (keymap-global-set "C-c m" #'mu4e) +;; mu4e's main view uses a display-buffer-full-frame action (see +;; mu4e-display-buffer), which deletes the window split on launch. Per that +;; function's own docstring, the supported way to change it is +;; display-buffer-alist. Route the main buffer to the current window instead +;; (reuse a window already showing it first), so launching mu4e in a split +;; leaves the rest of the layout intact. Registered eagerly rather than in +;; mu4e's deferred :config so it applies on the first launch. +(add-to-list 'display-buffer-alist + '("\\`\\*mu4e-main\\*\\'" + (display-buffer-reuse-window display-buffer-same-window) + (inhibit-same-window . nil))) + (use-package mu4e :ensure nil ;; mu4e gets installed by installing 'mu' via the system package manager :load-path "/usr/share/emacs/site-lisp/mu4e/" diff --git a/tests/test-mail-config-mu4e-window.el b/tests/test-mail-config-mu4e-window.el new file mode 100644 index 00000000..e02a7f9a --- /dev/null +++ b/tests/test-mail-config-mu4e-window.el @@ -0,0 +1,42 @@ +;;; test-mail-config-mu4e-window.el --- mu4e main-view window placement -*- lexical-binding: t; -*- + +;;; Commentary: +;; mu4e's main view defaults to a display-buffer-full-frame action that deletes +;; the window split on launch. mail-config registers a display-buffer-alist +;; entry routing the "*mu4e-main*" buffer to the current window instead. These +;; verify the entry is registered and that, with it active, displaying the main +;; buffer under mu4e's own full-frame action no longer collapses a split. + +;;; Code: + +(require 'ert) +(require 'mail-config) + +(ert-deftest test-mail-config-mu4e-main-entry-registered () + "Normal: the *mu4e-main* alist entry avoids the full-frame action." + (let ((entry (assoc "\\`\\*mu4e-main\\*\\'" display-buffer-alist))) + (should entry) + (should (memq 'display-buffer-same-window (cadr entry))) + (should-not (memq 'display-buffer-full-frame (cadr entry))))) + +(ert-deftest test-mail-config-mu4e-main-keeps-split () + "Normal: displaying *mu4e-main* under the full-frame action keeps the split. +The registered alist entry takes precedence over the action passed to +`display-buffer', so the sibling window survives." + (let ((a (get-buffer-create "*mail-win-test-a*")) + (main (get-buffer-create "*mu4e-main*"))) + (unwind-protect + (save-window-excursion + (delete-other-windows) + (set-window-buffer (selected-window) a) + (split-window (selected-window) nil t) ;; side-by-side, batch-friendly + (let ((n (count-windows))) + (display-buffer main '(display-buffer-reuse-window + display-buffer-reuse-mode-window + display-buffer-full-frame)) + (should (= (count-windows) n)))) + (ignore-errors (kill-buffer a)) + (ignore-errors (kill-buffer main))))) + +(provide 'test-mail-config-mu4e-window) +;;; test-mail-config-mu4e-window.el ends here |
