From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected Date: Tue, 30 Jan 2024 15:21:53 -0500 Message-ID: References: <86y1c6688u.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24439"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68801@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 30 21:23:16 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rUudY-00067Y-6f for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 30 Jan 2024 21:23:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUudD-0006Jk-RA; Tue, 30 Jan 2024 15:22:55 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUudC-0006Hl-0v for bug-gnu-emacs@gnu.org; Tue, 30 Jan 2024 15:22:54 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUudB-0007RX-Ol for bug-gnu-emacs@gnu.org; Tue, 30 Jan 2024 15:22:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rUudK-0004aK-Dr for bug-gnu-emacs@gnu.org; Tue, 30 Jan 2024 15:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Jan 2024 20:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68801 X-GNU-PR-Package: emacs Original-Received: via spool by 68801-submit@debbugs.gnu.org id=B68801.170664613117562 (code B ref 68801); Tue, 30 Jan 2024 20:23:02 +0000 Original-Received: (at 68801) by debbugs.gnu.org; 30 Jan 2024 20:22:11 +0000 Original-Received: from localhost ([127.0.0.1]:36962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUucU-0004ZC-LM for submit@debbugs.gnu.org; Tue, 30 Jan 2024 15:22:11 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:47483) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUucS-0004Yx-3l for 68801@debbugs.gnu.org; Tue, 30 Jan 2024 15:22:09 -0500 In-Reply-To: <86y1c6688u.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 30 Jan 2024 19:28:33 +0200") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1706646113; bh=jFybG6Pj8TB4tava2LYb0H0IATekVhI+xXmA4tvRsgE=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=MNhedafyYg3NcRdbRb0OR8boKjZivzpofAVLN2NBGFlzchAQpLerfy2fNAowdNgnL bDBvNMyyPPxDWhVkuvjD3PfUCryCLsexi2lxhG6J1Ols4tEV8/7NRnCgKFsiCJRQ6a Cct9RQOW7EBDxoPKzGDTY0UvXkfu5zisVA+PeO3+s1/0QrKk1lP1F7eSURyZNJ21fN ax9ywXVa6rgp/rX4fuMMkv3lhe7AaI8UZyZFQPy1nLV7vroXexlwJIczK8EvTEGGYg KTQtSEsaY+HhNjThJt9A6+Jk/rydKeyA5C3n+k8nvKHaHPaTR/CILIWrxYYLOD2Bfn 7eqA7KNtIcvUg== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279204 Archived-At: Juri Linkov writes: >> Since there are a few alternatives, perhaps we could have a defcustom >> for the RET behavior in completion-in-region. I think the default >> should be closing *Completions* and inserting a newline, since that >> matches minibuffer-visible-completions=nil. >> >> If this sounds reasonable I can write a patch implementing these. > > Sorry, I have no opinion - this is such a gray area, I never tried > to type RET with an unselected completion candidate. > > But at least the current behavior makes sense since it's like > in Isearch mode where RET just exits Isearch, whereas some other > keys exit Isearch and do their usual job. Fair. So that may make sense as an optional behavior. Still, I think the behavior of completion-in-region with minibuffer-visible-completions=nil is more relevant, and the default should match that. Here's a simple patch: What if minibuffer-visible-completions just only overrides RET when there's a selected completion? See below. Could this make sense? In general, now RET with minibuffer-visible-completions=t will do whatever RET did when minibuffer-visible-completions=nil, except that when there's a selected completion RET will choose it. That seems simple and easy to understand to me. (Really, I think something like this behavior for RET could be made the default, even when minibuffer-visible-completions=nil) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 45aab398078..688018fd07f 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3161,7 +3161,7 @@ minibuffer-visible-completions :type 'boolean :version "30.1") -(defun minibuffer-visible-completions-bind (binding) +(defun minibuffer-visible-completions-bind (binding &optional require-selected) "Use BINDING when completions are visible. Return an item that is enabled only when a window displaying the *Completions* buffer exists." @@ -3169,9 +3169,13 @@ minibuffer-visible-completions-bind "" ,binding :filter ,(lambda (cmd) (when-let ((window (get-buffer-window "*Completions*" 0))) - (when (eq (buffer-local-value 'completion-reference-buffer - (window-buffer window)) - (window-buffer (active-minibuffer-window))) + (when (and (eq (buffer-local-value 'completion-reference-buffer + (window-buffer window)) + (window-buffer (active-minibuffer-window))) + (if require-selected + (with-current-buffer (window-buffer window) + (get-text-property (point) 'completion--string)) + t)) cmd))))) (defvar-keymap minibuffer-visible-completions-map @@ -3180,7 +3184,7 @@ minibuffer-visible-completions-map "" (minibuffer-visible-completions-bind #'minibuffer-next-completion) "" (minibuffer-visible-completions-bind #'minibuffer-previous-line-completion) "" (minibuffer-visible-completions-bind #'minibuffer-next-line-completion) - "RET" (minibuffer-visible-completions-bind #'minibuffer-choose-completion-or-exit) + "RET" (minibuffer-visible-completions-bind #'minibuffer-choose-completion-or-exit t) "C-g" (minibuffer-visible-completions-bind #'minibuffer-hide-completions)) ;;; Completion tables.