aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-16 14:56:59 -0500
committerCraig Jennings <c@cjennings.net>2026-06-16 14:56:59 -0500
commit4bfdc0a1f56d877c23cec895bdc108e0f196e18c (patch)
treef01de5875f30d2a259b04269ac3611a0ab1127df /modules
parent58a38dcba409c604a2c11fdc578bfa298926be56 (diff)
downloaddotemacs-4bfdc0a1f56d877c23cec895bdc108e0f196e18c.tar.gz
dotemacs-4bfdc0a1f56d877c23cec895bdc108e0f196e18c.zip
feat(ui-navigation): split from the dashboard opens scratch, not the dashboard
C-x 2 / C-x 3 already show the dashboard in the new window while point stays put. The one dead spot was splitting from the dashboard itself, which put the dashboard in both panes. Now the new window shows *scratch* when the current buffer is the dashboard, and the dashboard everywhere else. I pulled the choice into a pure predicate (cj/--split-from-dashboard-p) and a companion helper, both tested.
Diffstat (limited to 'modules')
-rw-r--r--modules/ui-navigation.el23
1 files changed, 19 insertions, 4 deletions
diff --git a/modules/ui-navigation.el b/modules/ui-navigation.el
index e9c9eaf26..d8d7162e2 100644
--- a/modules/ui-navigation.el
+++ b/modules/ui-navigation.el
@@ -118,15 +118,30 @@ window. Return the new window."
(set-window-buffer new buffer))
new))
+(defun cj/--split-from-dashboard-p (buffer-name)
+ "Return non-nil when BUFFER-NAME is the dashboard.
+Splitting from the dashboard shows *scratch* in the new window instead of
+the dashboard again."
+ (equal buffer-name "*dashboard*"))
+
+(defun cj/--split-companion-buffer ()
+ "Buffer to show in the new window after a C-x 2 / C-x 3 split.
+The dashboard, or the *scratch* buffer when splitting from the dashboard."
+ (if (cj/--split-from-dashboard-p (buffer-name))
+ (get-scratch-buffer-create)
+ (cj/--dashboard-buffer)))
+
(defun cj/split-below-with-dashboard ()
- "Split below and show the dashboard in the new window; stay in this one."
+ "Split below and show the companion buffer in the new window; stay in this one.
+The companion is the dashboard, or *scratch* when splitting from the dashboard."
(interactive)
- (cj/--split-show-buffer #'split-window-below (cj/--dashboard-buffer)))
+ (cj/--split-show-buffer #'split-window-below (cj/--split-companion-buffer)))
(defun cj/split-right-with-dashboard ()
- "Split right and show the dashboard in the new window; stay in this one."
+ "Split right and show the companion buffer in the new window; stay in this one.
+The companion is the dashboard, or *scratch* when splitting from the dashboard."
(interactive)
- (cj/--split-show-buffer #'split-window-right (cj/--dashboard-buffer)))
+ (cj/--split-show-buffer #'split-window-right (cj/--split-companion-buffer)))
(keymap-global-set "C-x 2" #'cj/split-below-with-dashboard)
(keymap-global-set "C-x 3" #'cj/split-right-with-dashboard)