branch: externals/beframe
commit 5831fe88648f27544a07d1c59203d132635bd657
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Use a completion table instead of let binding completion-extra-properties
    
    Thanks to Stefan Monnier for telling me that let binding the metadata
    can affect nested minibuffers, which we do not want.
    
    This was done on the emacs-devel mailing list:
    <https://lists.gnu.org/archive/html/emacs-devel/2025-12/msg00264.html>.
---
 beframe.el | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/beframe.el b/beframe.el
index a79cce6faf..8708073573 100644
--- a/beframe.el
+++ b/beframe.el
@@ -306,21 +306,27 @@ empty string."
       (format "​%s " (propertize beframe-prompt-prefix 'face 
'beframe-face-prompt-prefix))
     ""))
 
+(defun beframe-completion-table ()
+  "Return new completion table with `beframe-buffer-names'."
+  (lambda (string pred action)
+    (if (eq action 'metadata)
+        (list 'metadata '(category . buffer))
+      (complete-with-action action (beframe-buffer-names) string pred))))
+
 ;;;###autoload
 (defun beframe-read-buffer (prompt &optional def require-match _predicate)
   "The `read-buffer-function' that limits buffers to frames.
 PROMPT, DEF, REQUIRE-MATCH, and PREDICATE are the same as
 `read-buffer'.  The PREDICATE is ignored, however, to apply the
 per-frame filter."
-  (let ((completion-extra-properties (list :category 'buffer)))
-    (completing-read
-     (format "%s%s" (beframe--propertize-prompt-prefix) prompt)
-     (beframe-buffer-names)
-     #'beframe--read-buffer-p
-     require-match
-     nil
-     'beframe-history
-     def)))
+  (completing-read
+   (format "%s%s" (beframe--propertize-prompt-prefix) prompt)
+   (beframe-completion-table)
+   #'beframe--read-buffer-p
+   require-match
+   nil
+   'beframe-history
+   def))
 
 (defun beframe--buffer-prompt (&optional frame)
   "Prompt for buffer among `beframe-buffer-names'.

Reply via email to