From d5aeb89414aee495e1c2b75d8e434c7103f4165f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=9Awi=C4=85tkowski?= Date: Thu, 12 Dec 2024 11:58:13 +0100 Subject: [PATCH] Use projectile root if available If projectile is available, use its root directory to set as current directory when creating a comint buffer. This way aider --subtree-only will start correctly in the project root, not in the semi-random location related to current file. --- aider.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aider.el b/aider.el index f1081a2..5d45645 100644 --- a/aider.el +++ b/aider.el @@ -137,7 +137,13 @@ If not in a git repository, an error is raised." (interactive) (let* ((buffer-name (aider-buffer-name)) (comint-terminfo-terminal "dumb") - (source-buffer (window-buffer (selected-window)))) + (source-buffer (window-buffer (selected-window))) + ;; Add Projectile support: use project root if available + (default-directory + (if (and (fboundp 'projectile-project-root) + (projectile-project-p)) + (projectile-project-root) + default-directory))) (unless (comint-check-proc buffer-name) (apply 'make-comint-in-buffer "aider" buffer-name aider-program nil aider-args) (with-current-buffer buffer-name