branch: elpa/aidermacs
commit 9a8575e7de91f2cacfa16434911eeaea60f18538
Author: Mingde (Matthew) Zeng <matthew...@posteo.net>
Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>

    Use minor mode for relevant functions
---
 aidermacs-backends.el |  9 +++------
 aidermacs.el          | 10 ++++------
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/aidermacs-backends.el b/aidermacs-backends.el
index d87d682498..5b50829ed2 100644
--- a/aidermacs-backends.el
+++ b/aidermacs-backends.el
@@ -222,14 +222,11 @@ BUFFER-NAME is the name for the aidermacs buffer."
 (defun aidermacs--is-aidermacs-buffer-p (&optional buffer)
   "Check if BUFFER is any type of aidermacs buffer.
 If BUFFER is nil, check the current buffer.
-Returns non-nil if the buffer name matches the aidermacs buffer pattern
-and is using either comint or vterm mode."
+Returns non-nil if the buffer has either aidermacs-comint-mode or 
aidermacs-vterm-mode enabled."
   (let ((buf (or buffer (current-buffer))))
     (with-current-buffer buf
-      (and (string-match-p "^\\*aidermacs:" (buffer-name buf))
-           (or (derived-mode-p 'comint-mode)
-               (and (fboundp 'vterm-mode)
-                    (derived-mode-p 'vterm-mode)))))))
+      (or (bound-and-true-p aidermacs-comint-mode)
+          (bound-and-true-p aidermacs-vterm-mode)))))
 
 (defun aidermacs--send-command-backend (buffer command &optional redirect)
   "Send command to buffer using the appropriate backend.
diff --git a/aidermacs.el b/aidermacs.el
index 30f961665c..39e6a84353 100644
--- a/aidermacs.el
+++ b/aidermacs.el
@@ -184,8 +184,7 @@ If there are multiple, prompt to select one interactively.
 Returns nil if no aidermacs buffers exist.
 This is used when you want to target an existing session."
   (let* ((buffers (cl-remove-if-not
-                   (lambda (buf)
-                     (string-match-p "^\\*aidermacs:" (buffer-name buf)))
+                   #'aidermacs--is-aidermacs-buffer-p
                    (buffer-list)))
          (buffer-names (mapcar #'buffer-name buffers)))
     (cond
@@ -203,8 +202,7 @@ If USE-EXISTING is non-nil, use an existing buffer instead 
of creating new."
          ;; Get all existing aidermacs buffers
          (aidermacs-buffers
           (cl-remove-if-not
-           (lambda (buf)
-             (string-match-p "^\\*aidermacs:" (buffer-name buf)))
+           #'aidermacs--is-aidermacs-buffer-p
            (buffer-list)))
          ;; Extract directory paths and subtree status from buffer names
          (buffer-dirs
@@ -710,7 +708,7 @@ If cursor is inside a function, include the function name 
as context.
 If called from the aidermacs buffer, use general question instead."
   (interactive)
   ;; Dispatch to general question if in aidermacs buffer
-  (if (string= (buffer-name) (aidermacs-get-buffer-name))
+  (if (aidermacs--is-aidermacs-buffer-p)
       (call-interactively #'aidermacs-general-question)
     (when-let ((command (aidermacs--form-prompt "/ask" "Question")))
       (aidermacs-add-current-file)
@@ -1211,7 +1209,7 @@ configuring, troubleshooting, etc."
 ;; Add a hook to clean up temp buffers when an aidermacs buffer is killed
 (defun aidermacs--cleanup-on-buffer-kill ()
   "Clean up temporary buffers when an aidermacs buffer is killed."
-  (when (string-match "^\\*aidermacs:" (buffer-name))
+  (when (aidermacs--is-aidermacs-buffer-p)
     (aidermacs--cleanup-temp-buffers)))
 
 (defun aidermacs--setup-cleanup-hooks ()

Reply via email to