From 12fad985f6e08b4544521844ba6968ee2c1b6526 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 15 Jun 2026 21:48:10 -0500 Subject: feat(ui-navigation): C-x 2/3 show the dashboard in the new window Splitting with C-x 2 or C-x 3 now shows *dashboard* in the freshly created window and keeps point in the original, instead of mirroring the current buffer. cj/--split-show-buffer does the placement; cj/--dashboard-buffer fetches or opens the dashboard without disturbing windows. --- modules/ui-navigation.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'modules') diff --git a/modules/ui-navigation.el b/modules/ui-navigation.el index f2181d97e..fba9153c2 100644 --- a/modules/ui-navigation.el +++ b/modules/ui-navigation.el @@ -103,6 +103,34 @@ nudging until any other key. Bound to `C-; b ///'." (consult-buffer)) (keymap-global-set "M-S-h" #'cj/split-and-follow-below) ;; was M-H +(defun cj/--dashboard-buffer () + "Return the *dashboard* buffer, creating it if needed, without changing windows." + (or (get-buffer "*dashboard*") + (save-window-excursion + (when (fboundp 'dashboard-open) (dashboard-open)) + (get-buffer "*dashboard*")))) + +(defun cj/--split-show-buffer (split-fn buffer) + "Split with SPLIT-FN, show BUFFER in the new window, keep point in the current +window. Return the new window." + (let ((new (funcall split-fn))) + (when (and (window-live-p new) buffer) + (set-window-buffer new buffer)) + new)) + +(defun cj/split-below-with-dashboard () + "Split below and show the dashboard in the new window; stay in this one." + (interactive) + (cj/--split-show-buffer #'split-window-below (cj/--dashboard-buffer))) + +(defun cj/split-right-with-dashboard () + "Split right and show the dashboard in the new window; stay in this one." + (interactive) + (cj/--split-show-buffer #'split-window-right (cj/--dashboard-buffer))) + +(keymap-global-set "C-x 2" #'cj/split-below-with-dashboard) +(keymap-global-set "C-x 3" #'cj/split-right-with-dashboard) + ;; ------------------------- Split Window Reorientation ------------------------ (defun toggle-window-split () -- cgit v1.2.3