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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: rswgnu@HIDDEN; dated Fri, 26 Mar 2021 19:19:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 47417 <at> debbugs.gnu.org:


Received: (at 47417) by debbugs.gnu.org; 13 Apr 2021 19:45:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 13 15:45:22 2021
Received: from localhost ([127.0.0.1]:60871 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lWOyQ-0007XG-I8
	for submit <at> debbugs.gnu.org; Tue, 13 Apr 2021 15:45:22 -0400
Received: from relay3-d.mail.gandi.net ([217.70.183.195]:36491)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lWOyK-0007Wv-3a
 for 47417 <at> debbugs.gnu.org; Tue, 13 Apr 2021 15:45:20 -0400
X-Originating-IP: 91.129.96.157
Received: from mail.gandi.net (m91-129-96-157.cust.tele2.ee [91.129.96.157])
 (Authenticated sender: juri@HIDDEN)
 by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id E8AAA60008;
 Tue, 13 Apr 2021 19:45:08 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Robert Weiner <rsw@HIDDEN>
Subject: Re: bug#47417: Expand/fix use of completion-no-auto-exit flag
References: <CA+OMD9juuWkramRh8qFbyryBvR10nxG9rzEiDdugVPMk4GnL=g@HIDDEN>
Date: Tue, 13 Apr 2021 22:30:35 +0300
In-Reply-To: <CA+OMD9juuWkramRh8qFbyryBvR10nxG9rzEiDdugVPMk4GnL=g@HIDDEN>
 (Robert Weiner's message of "Fri, 26 Mar 2021 15:18:26 -0400")
Message-ID: <87pmyyqbp0.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 47417
Cc: 47417 <at> debbugs.gnu.org, rswgnu@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

> 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.


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=completion-no-auto-exit.patch

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)))

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#47417; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Mar 2021 19:18:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 26 15:18:46 2021
Received: from localhost ([127.0.0.1]:42518 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lPryo-0000Dm-Au
	for submit <at> debbugs.gnu.org; Fri, 26 Mar 2021 15:18:46 -0400
Received: from lists.gnu.org ([209.51.188.17]:54728)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rsw@HIDDEN>) id 1lPrym-0000Df-Ou
 for submit <at> debbugs.gnu.org; Fri, 26 Mar 2021 15:18:45 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:47602)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rsw@HIDDEN>) id 1lPryj-0005BG-RY
 for bug-gnu-emacs@HIDDEN; Fri, 26 Mar 2021 15:18:43 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:42489)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <rsw@HIDDEN>) id 1lPryi-0006JS-SG
 for bug-gnu-emacs@HIDDEN; Fri, 26 Mar 2021 15:18:41 -0400
Received: from mail-lf1-f50.google.com ([209.85.167.50]:44725)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128)
 (Exim 4.82) (envelope-from <rsw@HIDDEN>) id 1lPryi-0000W3-Bo
 for bug-gnu-emacs@HIDDEN; Fri, 26 Mar 2021 15:18:40 -0400
Received: by mail-lf1-f50.google.com with SMTP id b83so9201869lfd.11
 for <bug-gnu-emacs@HIDDEN>; Fri, 26 Mar 2021 12:18:40 -0700 (PDT)
X-Gm-Message-State: AOAM531h9m3K6l8yQK3dwTbhln1qwF5lhxqiul1YpGvTUfWwFlBDpt1K
 xXL+7R9Ry99XF6wx0LXlm81n/QYyZn8k+x36GgQ=
X-Google-Smtp-Source: ABdhPJyJ3YzBhYKbBWWZRki8sOCIdGYqmR+fiW9u18MzJGPhH67/TwVIreNZrqhsX890cKlJtIuSy0Q2Q6wplp59s3U=
X-Received: by 2002:a05:6512:3226:: with SMTP id
 f6mr8691650lfe.171.1616786318989; 
 Fri, 26 Mar 2021 12:18:38 -0700 (PDT)
MIME-Version: 1.0
From: Robert Weiner <rsw@HIDDEN>
Date: Fri, 26 Mar 2021 15:18:26 -0400
X-Gmail-Original-Message-ID: <CA+OMD9juuWkramRh8qFbyryBvR10nxG9rzEiDdugVPMk4GnL=g@HIDDEN>
Message-ID: <CA+OMD9juuWkramRh8qFbyryBvR10nxG9rzEiDdugVPMk4GnL=g@HIDDEN>
Subject: Expand/fix use of completion-no-auto-exit flag
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000389e6f05be7566d8"
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: rswgnu@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--000000000000389e6f05be7566d8
Content-Type: text/plain; charset="UTF-8"

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.

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.

Thanks,

Bob

--000000000000389e6f05be7566d8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:monospac=
e,monospace">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.=C2=A0 Presently, this flag does i=
nhibit closure of the minibuffer when choosing a completion but it does not=
 inhibit closure of the list of completions if &#39;?&#39; has been used.=
=C2=A0 I think the two are connected and that whatever external code is use=
d to utilize the finalized completion should also handle the closure of the=
 completion window.</div><div class=3D"gmail_default" style=3D"font-family:=
monospace,monospace"><br></div><div class=3D"gmail_default" style=3D"font-f=
amily:monospace,monospace">This can be accomplished by simply wrapping the =
call to &#39;quit-window&#39; within &#39;choose-completion&#39; with an &#=
39;(unless completion-no-auto-exit...)&#39; like so:</div><div class=3D"gma=
il_default" style=3D"font-family:monospace,monospace">=C2=A0 =C2=A0<span st=
yle=3D"font-family:Arial,Helvetica,sans-serif">=C2=A0 =C2=A0 =C2=A0 (unless=
 completion-no-auto-exit=C2=A0</span><span style=3D"font-family:Arial,Helve=
tica,sans-serif">(quit-window nil (posn-window (event-start event))))</span=
></div><div class=3D"gmail_default" style=3D"font-family:monospace,monospac=
e"><span style=3D"font-family:Arial,Helvetica,sans-serif"><br></span></div>=
<div class=3D"gmail_default" style=3D"font-family:monospace,monospace"><spa=
n style=3D"font-family:Arial,Helvetica,sans-serif">Please consider adding t=
his as a quick fix.=C2=A0 Then packages like Hyperbole which requires 2 cli=
cks/presses to finalize a completion selection could use choose-completion =
without having to replace the whole function.</span></div><div class=3D"gma=
il_default" style=3D"font-family:monospace,monospace"><span style=3D"font-f=
amily:Arial,Helvetica,sans-serif"><br></span></div><div class=3D"gmail_defa=
ult" style=3D"font-family:monospace,monospace"><span style=3D"font-family:A=
rial,Helvetica,sans-serif">Thanks,</span></div><div class=3D"gmail_default"=
 style=3D"font-family:monospace,monospace"><span style=3D"font-family:Arial=
,Helvetica,sans-serif"><br></span></div><div class=3D"gmail_default" style=
=3D"font-family:monospace,monospace"><span style=3D"font-family:Arial,Helve=
tica,sans-serif">Bob</span></div><div class=3D"gmail_default" style=3D"font=
-family:monospace,monospace"><span style=3D"font-family:Arial,Helvetica,san=
s-serif"><br></span></div></div>

--000000000000389e6f05be7566d8--




Acknowledgement sent to rswgnu@HIDDEN:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#47417; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 13 Apr 2021 20:00:01 UTC

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