From 29e1b25fefab970756a1ac37cb1c4bfc24177ab7 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 16 Feb 2024 12:30:42 +0800 Subject: [PATCH] Emacs: Also try and find a buffer named FILENAME, kinda WIP --- .config/emacs/init.org | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 31ea245..b207989 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -1457,8 +1457,12 @@ These are functions to load a project specific file given the conventions I use. #+begin_src emacs-lisp (defun joe/project-open-project-file (FILENAME) (when (project-current) - (let ((proj-dir (project-root (project-current t)))) - (find-file-other-window (expand-file-name FILENAME proj-dir))))) + (let* ((proj-dir (project-root (project-current t))) + (file-path (expand-file-name FILENAME proj-dir))) + (if (file-exists-p file-path) + (find-file-other-window (expand-file-name FILENAME proj-dir)) + (when (get-buffer FILENAME) + (switch-to-buffer (get-buffer FILENAME))))))) (defun joe/project-open-project-todo () (interactive)