branch: externals/corfu
commit 4c4a41b0b3a7a65729b701670052d2287f57b427
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    Work around Emacs bug#79792
---
 CHANGELOG.org                 |  1 +
 extensions/corfu-info.el      | 11 +++++++----
 extensions/corfu-popupinfo.el | 16 +++++++++-------
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 0d10038ea4..6924b4732b 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -6,6 +6,7 @@
 
 - corfu-popupinfo: Faster scrolling speed.
 - corfu-popupinfo: Fix Emacs 30 deprecation warning.
+- Work around Emacs bug#79792, where the ~*Help*~ buffer is replaced 
unexpectedly.
 - Experimental: Use new function =set-frame-size-and-position-pixelwise= if
   available. The patch can be downloaded from here:
   https://lists.gnu.org/archive/html/emacs-devel/2025-12/msg00359.html
diff --git a/extensions/corfu-info.el b/extensions/corfu-info.el
index 6298db79e1..4ce4b62307 100644
--- a/extensions/corfu-info.el
+++ b/extensions/corfu-info.el
@@ -35,7 +35,8 @@
 
 (require 'corfu)
 (eval-when-compile
-  (require 'subr-x))
+  (require 'subr-x)
+  (require 'cl-lib))
 
 (defun corfu-info--restore-on-next-command ()
   "Restore window configuration before next command."
@@ -73,13 +74,15 @@ If called with a prefix ARG, the buffer is persistent."
   ;; Company support, taken from `company.el', see `company-show-doc-buffer'.
   (when (< corfu--index 0)
     (user-error "No candidate selected"))
-  (let* ((cand (nth corfu--index corfu--candidates))
-         (cand-str (substring-no-properties cand)))
+  (cl-letf* ((cand (nth corfu--index corfu--candidates))
+             (cand-str (substring-no-properties cand))
+             ((symbol-function #'help-buffer) ;; Work around bug#79792
+              (lambda () (get-buffer-create " *corfu-info*"))))
     (if-let ((fun (corfu--metadata-get 'company-doc-buffer))
              (res (funcall fun cand)))
         (set-window-start (corfu-info--display-buffer
                            (get-buffer (or (car-safe res) res))
-                           (and arg (format "*corfu doc: %s*" cand-str)))
+                           (and arg (format "*corfu info: %s*" cand-str)))
                           (or (cdr-safe res) (point-min)))
       (user-error "No documentation available for `%s'" cand-str))))
 
diff --git a/extensions/corfu-popupinfo.el b/extensions/corfu-popupinfo.el
index 34510302ce..dcd678ef0a 100644
--- a/extensions/corfu-popupinfo.el
+++ b/extensions/corfu-popupinfo.el
@@ -223,13 +223,15 @@ all values are in pixels relative to the origin.  See
   "Get the documentation for CANDIDATE."
   (when-let ((fun (corfu--metadata-get 'company-doc-buffer))
              (res (save-excursion
-                    (let ((inhibit-message t)
-                          (message-log-max nil)
-                          (inhibit-redisplay t)
-                          ;; Reduce print length for elisp backend (#249)
-                          (print-level 3)
-                          (print-length (* corfu-popupinfo-max-width
-                                           corfu-popupinfo-max-height)))
+                    (cl-letf (((symbol-function #'help-buffer) ;; Work around 
bug#79792
+                               (lambda () (get-buffer-create " *corfu-info*")))
+                              (inhibit-message t)
+                              (message-log-max nil)
+                              (inhibit-redisplay t)
+                              ;; Reduce print length for elisp backend (#249)
+                              (print-level 3)
+                              (print-length (* corfu-popupinfo-max-width
+                                               corfu-popupinfo-max-height)))
                       (funcall fun candidate)))))
     (with-current-buffer (or (car-safe res) res)
       (setq res (string-trim

Reply via email to