From 210e592e55ade154c8d58bd467711fb69368f6cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 23 Jan 2019 16:17:03 +0000 Subject: [PATCH] Avoid cycling in minibuffer-force-complete-and-exit (bug#34116) * lisp/minibuffer.el (minibuffer-force-complete-and-exit): Check completion-cycling before minibuffer-force-complete. --- lisp/minibuffer.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 5760a2e49de..99cb66926bb 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1257,7 +1257,13 @@ scroll the window of possible completions." (defun minibuffer-force-complete-and-exit () "Complete the minibuffer with first of the matches and exit." (interactive) - (minibuffer-force-complete) + ;; If `completion-cycling' is t, then surely a + ;; `minibuffer-force-complete' has already executed. This is not + ;; just for speed: the extra rotation caused by the second + ;; unnecessary call would mess up the final result value + ;; (bug#34116). + (unless completion-cycling + (minibuffer-force-complete)) (completion--complete-and-exit (minibuffer-prompt-end) (point-max) #'exit-minibuffer ;; If the previous completion completed to an element which fails -- 2.39.5