From f0f1a374ae4a9f855f3d260d605a889cbed8a4cd Mon Sep 17 00:00:00 2001 From: John Doty Date: Tue, 3 Jun 2025 06:37:36 -0700 Subject: [PATCH] [beets] Apropos should not return stale results It's confusing for emacs. --- site-lisp/doty-tools.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/site-lisp/doty-tools.el b/site-lisp/doty-tools.el index 42d823e..0e482d0 100644 --- a/site-lisp/doty-tools.el +++ b/site-lisp/doty-tools.el @@ -98,9 +98,13 @@ (defun doty-tools--apropos (pattern) "Invoke the help apropos function for PATTERN and return the results as a string." (save-window-excursion + (when-let (existing-buffer (get-buffer "*Apropos*")) + (kill-buffer existing-buffer)) (apropos pattern) - (with-current-buffer "*Apropos*" - (buffer-substring-no-properties (point-min) (point-max))))) + (if-let* ((apropos-buffer (get-buffer "*Apropos*"))) + (with-current-buffer apropos-buffer + (buffer-substring-no-properties (point-min) (point-max))) + ""))) (gptel-make-tool :name "emacs_help_apropos" @@ -118,7 +122,12 @@ (should (string-match-p "with-current-buffer" (doty-tools--test--invoke-tool - "emacs_help_apropos" '(:pattern "buffer"))))) + "emacs_help_apropos" '(:pattern "buffer")))) + + (should + (string-match-p "" + (doty-tools--test--invoke-tool + "emacs_help_apropos" '(:pattern "argle-3324-nonsense"))))) ;; === File reading