branch: elpa/aidermacs commit b3eb5055f0d5651282169f5e899b220f519770fa Author: tninja (aider) <tni...@gmail.com> Commit: tninja (aider) <tni...@gmail.com>
feat: Skip buffer switch if already in Aider buffer --- aider.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/aider.el b/aider.el index 8d6e5637bb..f657ca0703 100644 --- a/aider.el +++ b/aider.el @@ -203,13 +203,16 @@ If not in a git repository, an error is raised." ;;;###autoload (defun aider-switch-to-buffer () "Switch to the Aider buffer. -When `aider--switch-to-buffer-other-frame' is non-nil, open in a new frame." +When `aider--switch-to-buffer-other-frame' is non-nil, open in a new frame. +If the current buffer is already the Aider buffer, do nothing." (interactive) - (if-let ((buffer (get-buffer (aider-buffer-name)))) - (if aider--switch-to-buffer-other-frame - (switch-to-buffer-other-frame buffer) - (pop-to-buffer buffer)) - (message "Aider buffer '%s' does not exist." (aider-buffer-name)))) + (if (string= (buffer-name) (aider-buffer-name)) + (message "Already in Aider buffer") + (if-let ((buffer (get-buffer (aider-buffer-name)))) + (if aider--switch-to-buffer-other-frame + (switch-to-buffer-other-frame buffer) + (pop-to-buffer buffer)) + (message "Aider buffer '%s' does not exist." (aider-buffer-name))))) ;; Function to reset the Aider buffer ;;;###autoload