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, 27 Feb 2024 15:45:23 -0500 Message-ID: References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39941"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68801@debbugs.gnu.org, Juri Linkov To: sbaugh@catern.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 27 21:49:05 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 1rf4Ns-000A8j-4S for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Feb 2024 21:49:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rf4Kv-00062k-TL; Tue, 27 Feb 2024 15:46:01 -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 1rf4KX-0005ee-0g for bug-gnu-emacs@gnu.org; Tue, 27 Feb 2024 15:45:37 -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 1rf4KW-0005zV-N7 for bug-gnu-emacs@gnu.org; Tue, 27 Feb 2024 15:45:36 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rf4Kw-0002V2-E6 for bug-gnu-emacs@gnu.org; Tue, 27 Feb 2024 15:46: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, 27 Feb 2024 20:46: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.17090667579583 (code B ref 68801); Tue, 27 Feb 2024 20:46:02 +0000 Original-Received: (at 68801) by debbugs.gnu.org; 27 Feb 2024 20:45:57 +0000 Original-Received: from localhost ([127.0.0.1]:52834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rf4Kq-0002UV-QA for submit@debbugs.gnu.org; Tue, 27 Feb 2024 15:45:57 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:44329) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rf4Kp-0002U4-9r for 68801@debbugs.gnu.org; Tue, 27 Feb 2024 15:45:55 -0500 In-Reply-To: (Spencer Baugh's message of "Mon, 26 Feb 2024 11:04:59 -0500") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1709066723; bh=9sdQ9LHjTElWV3d3f7/AAA72Rb8aX6QQrBU0Hsndidw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=jH89JoQo1mujfzRvvmEslbGC6onSrWLRY6KpCUf5Y+dXcdQh50IiHmYMd0j6R7Tl6 FWyxrrSuX43ak1k3QCAdhRTVzrw6gO/usNoRLbgKsgLsyTCZTtkI4kwZj91nPak+xD 9bMqtfYAy1YEf0KWiJMMPJgaY95TavuW2xcMsm/4UOSI9Bk0Elr/YsKsBJ7FZnmISu ybweuz8qdJdAoNF5XABKV7Ukb60jlT5pL9wuuZFvgga52NzKORYb0KxufuUH2pBp+4 tFpMRSb6f5YKN2isqpvoK80ln2wTJ/hHci08ga13cgN/u/wrdEY2x5KKtZo29eItnC lsWZ9NIcnoVBQ== 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:280746 Archived-At: --=-=-= Content-Type: text/plain Spencer Baugh writes: > I'm thinking the right thing to do is just to go with my original patch > which only binds RET when there's a selected completion. That's simple > and straightforward. > > But I'm not sure how to adapt my completion-show-help change for that: I > want to hint to the user that they should hit RET, but RET is only bound > when a completion is selected, which isn't the case when *Completions* > is first displayed. Any ideas? Could we just hardcode "RET" in the > help text? The solution is obvious in retrospect, just add a defvar to force the bindings on. Complete patch attached, I think this closes the bug. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-With-visible-completions-only-bind-RET-when-completi.patch >From e81a3dccacd1ba701361d84f6d61fb244e8b81d6 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 27 Feb 2024 15:42:38 -0500 Subject: [PATCH] With visible-completions, only bind RET when completion is selected Previously, if minibuffer-visible-completions was non-nil, we bound RET whenever the *Completions* buffer was visible. This meant that RET in completion-in-region would not enter a newline, which is a somewhat annoying behavior change from minibuffer-visible-completions=nil. Now, we only bind RET when a completion is selected. This means RET will newline in completion-in-region. So that completion help continues to suggest the correct keys, we also add minibuffer-visible-completions--always-bind. When let-bound to a non-nil value, it makes the minibuffer-visible-completions binds always active. We let-bind it around substitute-command-keys. * lisp/minibuffer.el (minibuffer-visible-completions--always-bind) (minibuffer-visible-completions--filter): Add. (minibuffer-visible-completions-bind): Use minibuffer-visible-completions--filter. (bug#68801) * lisp/simple.el (minibuffer-visible-completions--always-bind) (completion-setup-function): Let-bind minibuffer-visible-completions--always-bind so the completion help is correct. --- lisp/minibuffer.el | 24 ++++++++++++++++++------ lisp/simple.el | 19 +++++++++++-------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 708f3684d11..3a06baddeae 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3163,18 +3163,30 @@ minibuffer-visible-completions :type 'boolean :version "30.1") +(defvar minibuffer-visible-completions--always-bind nil + "If non-nil, force the `minibuffer-visible-completions' bindings on.") + +(defun minibuffer-visible-completions--filter (cmd) + "Return CMD if `minibuffer-visible-completions' bindings should be active." + (if minibuffer-visible-completions--always-bind + cmd + (when-let ((window (get-buffer-window "*Completions*" 0))) + (when (and (eq (buffer-local-value 'completion-reference-buffer + (window-buffer window)) + (window-buffer (active-minibuffer-window))) + (if (eq cmd #'minibuffer-choose-completion-or-exit) + (with-current-buffer (window-buffer window) + (get-text-property (point) 'completion--string)) + t)) + cmd)))) + (defun minibuffer-visible-completions-bind (binding) "Use BINDING when completions are visible. Return an item that is enabled only when a window displaying the *Completions* buffer exists." `(menu-item "" ,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))) - cmd))))) + :filter ,#'minibuffer-visible-completions--filter)) (defvar-keymap minibuffer-visible-completions-map :doc "Local keymap for minibuffer input with visible completions." diff --git a/lisp/simple.el b/lisp/simple.el index 9a33049f4ca..ac2e1f9f1c9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10298,6 +10298,8 @@ completion-show-help :version "22.1" :group 'completion) +(defvar minibuffer-visible-completions--always-bind) + ;; This function goes in completion-setup-hook, so that it is called ;; after the text of the completion list buffer is written. (defun completion-setup-function () @@ -10338,15 +10340,16 @@ completion-setup-function (if minibuffer-visible-completions (let ((helps (with-current-buffer (window-buffer (active-minibuffer-window)) - (list - (substitute-command-keys - (if (display-mouse-p) - "Click or type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n" - "Type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n")) - (substitute-command-keys - "Type \\[minibuffer-next-completion], \\[minibuffer-previous-completion], \ + (let ((minibuffer-visible-completions--always-bind t)) + (list + (substitute-command-keys + (if (display-mouse-p) + "Click or type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n" + "Type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n")) + (substitute-command-keys + "Type \\[minibuffer-next-completion], \\[minibuffer-previous-completion], \ \\[minibuffer-next-line-completion], \\[minibuffer-previous-line-completion] \ -to move point between completions.\n\n"))))) +to move point between completions.\n\n")))))) (dolist (help helps) (insert help))) (insert (substitute-command-keys -- 2.39.3 --=-=-=--