branch: elpa/aidermacs commit 8ce3d8cf395ca178c26f0f6eb03e73f2a6f9e4fd Author: Mingde (Matthew) Zeng <matthew...@posteo.net> Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>
feat: Add option to kill Aider buffer on exit Closes #144 --- README.md | 9 +++++++++ aidermacs.el | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6a3646cdfc..b6be47ac1e 100644 --- a/README.md +++ b/README.md @@ -433,6 +433,15 @@ With auto-commits disabled, you must manually commit changes using your preferre *Note: This configuration will be overwritten by the existence of an `.aider.conf.yml` file (see [details](#Overwrite-Configuration-with-Configuration-File)).* +### Control Buffer Killing on Exit + +By default, when you exit an Aidermacs session using `aidermacs-exit` (or `x` in the transient menu), the Aidermacs buffer remains open. If you prefer the buffer to be automatically killed upon exiting the session, you can customize this behavior: + +```emacs-lisp +;; Kill the Aider buffer when exiting the session +(setq aidermacs-exit-kills-buffer t) +``` + ### Customize Aider Options with `aidermacs-extra-args` If these configurations aren't sufficient, the `aidermacs-extra-args` variable enables passing any Aider-supported command-line options. diff --git a/aidermacs.el b/aidermacs.el index 0c4d259a71..bb649e6170 100644 --- a/aidermacs.el +++ b/aidermacs.el @@ -109,6 +109,10 @@ any AI coding instructions you add using your favorite IDE or text editor." When nil, require explicit confirmation before applying changes." :type 'boolean) +(defcustom aidermacs-exit-kills-buffer nil + "When non-nil, `aidermacs-exit' will also kill the Aider buffer." + :type 'boolean) + (defvar aidermacs--read-string-history nil "History list for aidermacs read string inputs.") @@ -470,12 +474,17 @@ If the current buffer is already the aidermacs buffer, do nothing." (aidermacs--send-command "/reset")) (defun aidermacs-exit () - "Send the command \"/exit\" to the aidermacs buffer." + "Send the command \"/exit\" to the aidermacs buffer. +If `aidermacs-exit-kills-buffer' is non-nil, also kill the buffer." (interactive) - (when (get-buffer (aidermacs-get-buffer-name)) - (aidermacs--cleanup-temp-buffers) - (when (aidermacs--live-p (aidermacs-get-buffer-name)) - (aidermacs--send-command "/exit" t)))) + (let ((buffer-name (aidermacs-get-buffer-name))) + (when (get-buffer buffer-name) + (aidermacs--cleanup-temp-buffers) + (when (aidermacs--live-p buffer-name) + (aidermacs--send-command "/exit" t)) + (when aidermacs-exit-kills-buffer + (sit-for 1) + (kill-buffer buffer-name))))) (defun aidermacs--process-message-if-multi-line (str) "Process multi-line chat messages for proper formatting.