GNU bug report logs - #47417
Expand/fix use of completion-no-auto-exit flag

Previous Next

Package: emacs;

Reported by: rswgnu <at> gmail.com

Date: Fri, 26 Mar 2021 19:19:01 UTC

Severity: normal

Fixed in version 29.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Robert Weiner <rsw <at> gnu.org>
Cc: 47417 <at> debbugs.gnu.org, rswgnu <at> gmail.com
Subject: bug#47417: Expand/fix use of completion-no-auto-exit flag
Date: Tue, 13 Apr 2021 22:30:35 +0300
[Message part 1 (text/plain, inline)]
> It seems to me a high-level view of completion-no-auto-exit is to allow
> code outside of choose-completion and choose-completion-string to finish
> the completion selection process.  Presently, this flag does inhibit
> closure of the minibuffer when choosing a completion but it does not
> inhibit closure of the list of completions if '?' has been used.  I think
> the two are connected and that whatever external code is used to utilize
> the finalized completion should also handle the closure of the completion
> window.

Currently I'm developing a patch (attached below) that allows to type
‘M-0 RET’ on a completion to insert it to the minibuffer, and quit the window
without exiting the minibuffer.

So to keep backward-compatibility of completion-no-auto-exit,
its behavior should not be changed.

Then there are two options: create a new variable, e.g.
completion-no-auto-quit - to not quit the completion window.

Or better to support a new value of the existing variable
completion-no-auto-exit, e.g. 'no-quit-window'.

> This can be accomplished by simply wrapping the call to 'quit-window'
> within 'choose-completion' with an '(unless completion-no-auto-exit...)'
> like so:
>          (unless completion-no-auto-exit (quit-window nil (posn-window
> (event-start event))))
>
> Please consider adding this as a quick fix.  Then packages like Hyperbole
> which requires 2 clicks/presses to finalize a completion selection could
> use choose-completion without having to replace the whole function.

Please describe the use cases in more details.  When I tried to use
the aforementioned condition, then after selecting a completion,
the selected window is not switched to the minibuffer window.
The completion window says selected.  I'm not sure if this is what is needed.
It seems after selecting a completion without quitting the completion window,
it's expected that the minibuffer window should be selected.

[completion-no-auto-exit.patch (text/x-diff, inline)]
diff --git a/lisp/simple.el b/lisp/simple.el
index 12435a0680..fd17749451 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8850,10 +8850,12 @@ next-completion
 		    (point) 'mouse-face nil beg))
 	(setq n (1+ n))))))
 
-(defun choose-completion (&optional event)
+(defun choose-completion (&optional event arg)
   "Choose the completion at point.
-If EVENT, use EVENT's position to determine the starting position."
-  (interactive (list last-nonmenu-event))
+If EVENT, use EVENT's position to determine the starting position.
+When the prefix ARG is 0, insert the completion at point to the minibuffer
+and quit the completion window without exiting the minibuffer."
+  (interactive (list last-nonmenu-event current-prefix-arg))
   ;; In case this is run via the mouse, give temporary modes such as
   ;; isearch a chance to turn off.
   (run-hooks 'mouse-leave-buffer-hook)
@@ -8861,6 +8863,7 @@ choose-completion
     (let ((buffer completion-reference-buffer)
           (base-position completion-base-position)
           (insert-function completion-list-insert-choice-function)
+          (completion-no-auto-exit (if (eq arg 0) t completion-no-auto-exit))
           (choice
            (save-excursion
              (goto-char (posn-point (event-start event)))

This bug report was last modified 3 years and 98 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.