From 94763aa52112b4fc72ba5dfda2df558d6034fac8 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 15 Nov 2023 19:44:04 +0200 Subject: [PATCH] Enable completion-in-region-mode in minibuffer-complete-history/defaults * lisp/minibuffer.el (minibuffer-complete-history) (minibuffer-complete-defaults): Let-bind completion-in-region-mode-predicate to lambda that checks if the "*Completions*" buffer window is visible. This enables completion-in-region-mode that supports arrows with minibuffer-visible-completions. --- lisp/minibuffer.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 9f4ac704599..9ca3ecdf542 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -4727,13 +4727,15 @@ instead of the default completion table." history) (user-error "No history available")))) ;; FIXME: Can we make it work for CRM? - (completion-in-region - (minibuffer--completion-prompt-end) (point-max) - (lambda (string pred action) - (if (eq action 'metadata) - '(metadata (display-sort-function . identity) - (cycle-sort-function . identity)) - (complete-with-action action completions string pred)))))) + (let ((completion-in-region-mode-predicate + (lambda () (get-buffer-window "*Completions*" 0)))) + (completion-in-region + (minibuffer--completion-prompt-end) (point-max) + (lambda (string pred action) + (if (eq action 'metadata) + '(metadata (display-sort-function . identity) + (cycle-sort-function . identity)) + (complete-with-action action completions string pred))))))) (defun minibuffer-complete-defaults () "Complete minibuffer defaults as far as possible. @@ -4744,7 +4746,9 @@ instead of the completion table." (functionp minibuffer-default-add-function)) (setq minibuffer-default-add-done t minibuffer-default (funcall minibuffer-default-add-function))) - (let ((completions (ensure-list minibuffer-default))) + (let ((completions (ensure-list minibuffer-default)) + (completion-in-region-mode-predicate + (lambda () (get-buffer-window "*Completions*" 0)))) (completion-in-region (minibuffer--completion-prompt-end) (point-max) (lambda (string pred action) -- 2.39.2