aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 08:00:20 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 08:00:20 -0500
commit92eaba30ae35727509f1d9d6dcc467c248f627dc (patch)
tree941a9dfc2229185df5a8962da96e3473a99f4a1e /modules
parent3f75b39bbbc4e1c136d3f786024c5c1ed19011ce (diff)
downloaddotemacs-92eaba30ae35727509f1d9d6dcc467c248f627dc.tar.gz
dotemacs-92eaba30ae35727509f1d9d6dcc467c248f627dc.zip
fix(prog-general): open the project todo in the other window when split
C-c p t (cj/open-project-root-todo) called find-file, which always opened todo.org in the selected window, replacing whatever I was looking at. Now it opens in the other window when the frame is split and in the current window when it isn't, through a small cj/--find-file-respecting-split helper. The helper is a top-level defun rather than buried in the projectile :config block so it can be unit-tested without loading projectile. I left cj/project-switch-actions alone. Opening the todo on a project switch is a different trigger and not what this fixes.
Diffstat (limited to 'modules')
-rw-r--r--modules/prog-general.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/prog-general.el b/modules/prog-general.el
index dedf8a80..93a3a95c 100644
--- a/modules/prog-general.el
+++ b/modules/prog-general.el
@@ -137,6 +137,15 @@
(unless (file-exists-p projectile-bookmark-file)
(run-at-time "3" nil 'projectile-discover-projects-in-search-path))))
+(defun cj/--find-file-respecting-split (file)
+ "Open FILE in another window when the frame is split, else in this window.
+\"Split\" means the selected window is not the only one in its frame, so
+opening the file lands it in the other pane rather than replacing the
+buffer the user is looking at."
+ (if (one-window-p)
+ (find-file file)
+ (find-file-other-window file)))
+
(use-package projectile
:bind-keymap
("C-c p" . projectile-command-map)
@@ -171,7 +180,7 @@ If no such file exists there, display a message."
(if-let ((root (projectile-project-root)))
(let ((file (cj/find-project-root-file "^todo\\.org$")))
(if file
- (find-file (expand-file-name file root))
+ (cj/--find-file-respecting-split (expand-file-name file root))
(message "No todo.org in project root: %s" root)))
(message "Not in a Projectile project")))