From 8e491b75d30b11dc12769cbfdff59c516c8c4930 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sun, 20 Oct 2024 21:50:45 -0700 Subject: [PATCH] Don't require prelude.gdn to be open when navigating existing garden files --- editors/garden-mode.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/editors/garden-mode.el b/editors/garden-mode.el index 79fa9e6..506da77 100644 --- a/editors/garden-mode.el +++ b/editors/garden-mode.el @@ -335,10 +335,12 @@ the user entering a value in the *garden* buffer." (find-file file-name) ;; For prelude and builtins, we don't have a fully qualified ;; path. Switch to the current prelude.gdn or builtins.gdn, - ;; if open. - (let ((target-buf (--find (string= (buffer-name it) file-name) (buffer-list)))) - (when target-buf - (switch-to-buffer target-buf))))) + ;; relative to this elisp file. + (let* ((elisp-file-path (symbol-file 'garden-mode)) + (elisp-dir (directory-file-name (file-name-directory elisp-file-path))) + (garden-src-root (file-name-directory elisp-dir)) + (path (concat garden-src-root "src/" file-name))) + (find-file path)))) (defun garden--visit (file-and-line-num) "Visit a position expressed in the format \"/path/foo.gdn:123\"."