From unknown Fri Jun 20 19:48:20 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#68801 <68801@debbugs.gnu.org> To: bug#68801 <68801@debbugs.gnu.org> Subject: Status: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected Reply-To: bug#68801 <68801@debbugs.gnu.org> Date: Sat, 21 Jun 2025 02:48:20 +0000 retitle 68801 30.0.50; minibuffer-visible-completions=3Dt makes RET in comp= letion-in-region a no-op with nothing selected reassign 68801 emacs submitter 68801 Spencer Baugh severity 68801 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 29 13:50:13 2024 Received: (at submit) by debbugs.gnu.org; 29 Jan 2024 18:50:14 +0000 Received: from localhost ([127.0.0.1]:33469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUWhx-0001ob-CM for submit@debbugs.gnu.org; Mon, 29 Jan 2024 13:50:13 -0500 Received: from lists.gnu.org ([2001:470:142::17]:33886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUWhu-0001oL-Sm for submit@debbugs.gnu.org; Mon, 29 Jan 2024 13:50:11 -0500 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 1rUWhg-0002wH-SM for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 13:49:56 -0500 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUWhe-0005GM-Ts for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 13:49:56 -0500 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected X-Debbugs-Cc: Date: Mon, 29 Jan 2024 13:49:53 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1706554193; bh=2i0xob/uXWEnczp1uTOMspE+GGEN3vXcTRr1su9MgH0=; h=From:To:Cc:Subject:Date; b=ObI1Us/VCE/5QVD3tD//spJlwrNHPc2/EU1MkKYdhveEnpSuXTqq/tSq+y9owlsST ltOrWEK9qy+wWQ5zXr3mA9U3xuMKdUDBxQcwcN80ywVZp5gjODsECnuOoaydCozQkX g3xgXKZYunhZIMf3vYcmtvDPKRmP2uMhcuyXkrrkbWKBNDusvVXjbXWH7noQHRmohS MU13CZtbzkL7NEs1cUg5mQtCVEYsJ1WpGngVjrJEWX4/Hw1OgNX7g1tZ+Eepj+R4AO chM6dI9Ml6tD3PT1ZZLeuxSf4FnQtsGP9vRLuq+FsaAbLqhGl3J5DjTdruQ5Rws++Q CQkTkyHZ4tUwQ== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) 1. emacs -Q 2. In scratch: (current- M- 3. Observe *Completions* pops up. 4. RET 5. *Completions* goes away and a newline is inserted. Compare: 1. emacs -Q --eval '(setq minibuffer-visible-completions t)' 2. In scratch: (current- M- 3. Observe *Completions* pops up. 4. RET 5. *Completions* goes away but no newline is inserted, and "No match" is printed. I think the behavior with minibuffer-visible-completions=t is unintuitive. And it just duplicates what you can achieve with C-g (closes *Completions*), so it's not very useful. Even if I do: (current- M- buf RET which is sufficient to uniquely identify current-buffer, RET does not complete to current-buffer, instead it just says "No match". With minibuffer-visible-completions=t, I suggest RET with no completion selected in completion-in-region should exit completion and insert a newline. Or maybe, slightly more radically, RET with no completion selected in completion-in-region should select the first matching completion given the current completion region? At least one user expected that behavior. Another alternative is that RET doesn't close *Completions* at all, which would match minibuffer behavior better. I'm not a huge fan of that, but it's more useful than the current behavior of RET. 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. In GNU Emacs 30.0.50 (build 24, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-01-29 built on igm-qws-u22796a Repository revision: cbc8bdc1386a4bc9c420d8ab06b844c6f6928c35 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.9 (Green Obsidian) Configured using: 'configure -C 'CFLAGS=-O0 -g3' --with-gif=ifavailable --with-x-toolkit=lucid' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t minibuffer-regexp-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr dabbrev emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar make-network-process emacs) Memory information: ((conses 16 65716 19738) (symbols 48 9598 0) (strings 32 22938 2513) (string-bytes 1 684815) (vectors 16 9358) (vector-slots 8 112024 10425) (floats 8 42 15) (intervals 56 264 0) (buffers 976 10)) From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 30 12:40:58 2024 Received: (at 68801) by debbugs.gnu.org; 30 Jan 2024 17:40:58 +0000 Received: from localhost ([127.0.0.1]:36642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUs6U-00008p-4X for submit@debbugs.gnu.org; Tue, 30 Jan 2024 12:40:58 -0500 Received: from relay1-d.mail.gandi.net ([2001:4b98:dc4:8::221]:43691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUs6S-00008X-9w for 68801@debbugs.gnu.org; Tue, 30 Jan 2024 12:40:56 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id C7329240004; Tue, 30 Jan 2024 17:40:38 +0000 (UTC) From: Juri Linkov To: Spencer Baugh Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: (Spencer Baugh's message of "Mon, 29 Jan 2024 13:49:53 -0500") Organization: LINKOV.NET References: Date: Tue, 30 Jan 2024 19:28:33 +0200 Message-ID: <86y1c6688u.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 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. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 30 15:22:11 2024 Received: (at 68801) by debbugs.gnu.org; 30 Jan 2024 20:22:11 +0000 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 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 From: Spencer Baugh To: Juri Linkov Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <86y1c6688u.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 30 Jan 2024 19:28:33 +0200") References: <86y1c6688u.fsf@mail.linkov.net> Date: Tue, 30 Jan 2024 15:21:53 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain 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-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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. From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 31 03:00:28 2024 Received: (at 68801) by debbugs.gnu.org; 31 Jan 2024 08:00:28 +0000 Received: from localhost ([127.0.0.1]:37380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rV5WG-0006sW-6r for submit@debbugs.gnu.org; Wed, 31 Jan 2024 03:00:28 -0500 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:48539) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rV5WD-0006sH-HI for 68801@debbugs.gnu.org; Wed, 31 Jan 2024 03:00:26 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id DB99BC0015; Wed, 31 Jan 2024 08:00:08 +0000 (UTC) From: Juri Linkov To: Spencer Baugh Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: (Spencer Baugh's message of "Tue, 30 Jan 2024 15:21:53 -0500") Organization: LINKOV.NET References: <86y1c6688u.fsf@mail.linkov.net> Date: Wed, 31 Jan 2024 09:58:20 +0200 Message-ID: <86plxiq6hv.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 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? Yes, this makes sense. I'll try your patch for a while. > (Really, I think something like this behavior for RET could be made the > default, even when minibuffer-visible-completions=nil) I don't understand what would this mean for minibuffer-visible-completions=nil. From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 09 02:22:27 2024 Received: (at 68801) by debbugs.gnu.org; 9 Feb 2024 07:22:27 +0000 Received: from localhost ([127.0.0.1]:41438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYLDP-0007Uu-GF for submit@debbugs.gnu.org; Fri, 09 Feb 2024 02:22:27 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:48499) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYLDN-0007Ty-7w for 68801@debbugs.gnu.org; Fri, 09 Feb 2024 02:22:25 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id D78EAFF808; Fri, 9 Feb 2024 07:22:03 +0000 (UTC) From: Juri Linkov To: Spencer Baugh Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <86plxiq6hv.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 31 Jan 2024 09:58:20 +0200") Organization: LINKOV.NET References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> Date: Fri, 09 Feb 2024 09:17:20 +0200 Message-ID: <867cjejfan.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> 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? > > Yes, this makes sense. I'll try your patch for a while. Thanks for the patch, it works nicely. Could you please write a commit message for this patch. From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 10 13:14:50 2024 Received: (at 68801) by debbugs.gnu.org; 10 Feb 2024 18:14:50 +0000 Received: from localhost ([127.0.0.1]:59314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYrsH-0001tI-V4 for submit@debbugs.gnu.org; Sat, 10 Feb 2024 13:14:50 -0500 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:2920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rYrsF-0001t2-TR for 68801@debbugs.gnu.org; Sat, 10 Feb 2024 13:14:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=b38Xuc1ALCv/czT4RUzdTsxeV0fs17gQh6k53N1EOiw=; b=G95nysqse8urzKy+OOSmDq8yqyqiCdv1fBHJpy4SqYvb16bEfYx8seavTnRe6Wb+qzhM rx6cLuo4toQmnxRl/1s+Q/sjfZtNdt2Gjw2JbgTcqjHYlICP6np8muFakH+198vA+rjWwb jNVI+v91DMtpywvTarYZE7maPfdXH4s+q9WWD04JwplPf2IjlHRDzJbMB+6HuRlqcvLs3M myqiRZTXmMZj+pz7tcSAVXSDyM2+p/NS4nbF5pIn3zKuJRW0NtMQE6lz96vkNBw4cLFfyN W1a6oqOBriDXc358v3AXoueAbOtOKS3uimhm77lLyqxgCHwsBagM9SMv1XNMLHcA== Received: by filterdrecv-656b5b4c75-wlz7f with SMTP id filterdrecv-656b5b4c75-wlz7f-1-65C7BD02-C 2024-02-10 18:14:26.492121813 +0000 UTC m=+1396630.447906879 Received: from earth.catern.com (unknown) by geopod-ismtpd-28 (SG) with ESMTP id to8ySr3TQAi4WJrRrCnfBA Sat, 10 Feb 2024 18:14:26.403 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=74.101.51.129; helo=localhost; envelope-from=sbaugh@catern.com; receiver=linkov.net Received: from localhost (unknown [74.101.51.129]) by earth.catern.com (Postfix) with ESMTPSA id 57D8E63444; Sat, 10 Feb 2024 18:11:39 +0000 (UTC) From: sbaugh@catern.com Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <867cjejfan.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 09 Feb 2024 09:17:20 +0200") References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> Date: Sat, 10 Feb 2024 18:14:26 +0000 (UTC) Message-ID: <871q9k6vfo.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbKn=2F3vd7G53NgS2Chyzfj?= =?us-ascii?Q?G663Rl9NBOuqMKrhPGa01yCxjEdl62oapTqFewM?= =?us-ascii?Q?AjJaBlQnXmDT53ui7Q+lTS1ls7tlalVI7vfZXMY?= =?us-ascii?Q?4sG9MsKfoot53fA=2F9zjcQrmiMl+ZYrp3ncbBEPI?= =?us-ascii?Q?kwHCdd4Tgcv1edYZGA1tykoZwmgCt9uPwjg=3D=3D?= To: Juri Linkov X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, Spencer Baugh X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: >>> 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? >> >> Yes, this makes sense. I'll try your patch for a while. > > Thanks for the patch, it works nicely. > > Could you please write a commit message for this patch. The annoying thing is that this breaks the enhancement to completion-show-help I recently made. When a completion is not selected, RET isn't bound, so the help shows "Click or type M-x minibuffer-choose-completion-or-exit on a completion to select it." I'm not sure the right way to fix that. Selectively binding RET based on whether a completion is selected feels sketchy anyway, it may confuse users because e.g. C-h c RET won't work. Maybe instead we should always bind RET, but if no completion is selected, we run the command that RET was bound to before completion-in-region-mode started? Alternatively... as a completely separate point, I'd like completion-in-region to select the first completion candidate by default. I think that's useful in some cases and, for completion-in-region, doesn't have any negatives: we couldn't do it in the minibuffer because it would interfere with accepting the default, but there are no defaults in completion-in-region. If we make c-i-r select the first completion candidate by default, that would both: - Make the completion-show-help help render correctly with the "only override RET when there's a selected completion" patch. - Partially mitigate the RET issue all on its own Wdyt? From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 11 13:01:41 2024 Received: (at 68801) by debbugs.gnu.org; 11 Feb 2024 18:01:41 +0000 Received: from localhost ([127.0.0.1]:35983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZE97-0002DG-13 for submit@debbugs.gnu.org; Sun, 11 Feb 2024 13:01:41 -0500 Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]:43949) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZE94-0002Cl-Ev for 68801@debbugs.gnu.org; Sun, 11 Feb 2024 13:01:39 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 2676320002; Sun, 11 Feb 2024 18:01:13 +0000 (UTC) From: Juri Linkov To: sbaugh@catern.com Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <871q9k6vfo.fsf@catern.com> (sbaugh@catern.com's message of "Sat, 10 Feb 2024 18:14:26 +0000 (UTC)") Organization: LINKOV.NET References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> Date: Sun, 11 Feb 2024 19:59:47 +0200 Message-ID: <867cjax4oc.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, Spencer Baugh X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > The annoying thing is that this breaks the enhancement to > completion-show-help I recently made. When a completion is not > selected, RET isn't bound, so the help shows "Click or type M-x > minibuffer-choose-completion-or-exit on a completion to select it." > > I'm not sure the right way to fix that. Selectively binding RET based > on whether a completion is selected feels sketchy anyway, it may confuse > users because e.g. C-h c RET won't work. > > Maybe instead we should always bind RET, but if no completion is > selected, we run the command that RET was bound to before > completion-in-region-mode started? Then 'minibuffer-choose-completion-or-exit' could be more smart to run whatever command was bound to RET initially, instead of using the hard-coded 'minibuffer-complete-and-exit'. But this might require juggling with keymaps. > Alternatively... as a completely separate point, I'd like > completion-in-region to select the first completion candidate by > default. I think that's useful in some cases and, for > completion-in-region, doesn't have any negatives: we couldn't do it in > the minibuffer because it would interfere with accepting the default, > but there are no defaults in completion-in-region. > > If we make c-i-r select the first completion candidate by default, that > would both: > > - Make the completion-show-help help render correctly with the "only > override RET when there's a selected completion" patch. > > - Partially mitigate the RET issue all on its own Calling 'first-completion' makes sense even for the minibuffer, at least optionally. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 11 16:02:51 2024 Received: (at 68801) by debbugs.gnu.org; 11 Feb 2024 21:02:51 +0000 Received: from localhost ([127.0.0.1]:48176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZGyR-0002F3-14 for submit@debbugs.gnu.org; Sun, 11 Feb 2024 16:02:51 -0500 Received: from s.wrqvtbkv.outbound-mail.sendgrid.net ([149.72.123.24]:43964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZGyP-0002Ef-0h for 68801@debbugs.gnu.org; Sun, 11 Feb 2024 16:02:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=bpPvzIRsgxl4Q3DMeBTSiw/duS6S/NSbYDJAC02GUz4=; b=eCHUs3jqiyvGw2x+mq6LGvFyDXHdBx24rani/rz86sOC7D19ZCAFwllOnOz5wNSMMWYq c7X2uANUfYbDsCyGhuiKv59H01xPSjFDn7n8SQQOSBm44yUijk3l/WvIPMPSTEBuXGsCS0 eFr2PVJ4VCaUQflakFZtuOlciNiNk77sbeATzgg9Rjo+KNqY5p+Gl58fbnTvYma9LBgs8s t8Wk+E5mY4rfnOFKe4hdJkYCczxOKEfZ0PGuuUH2H45q2UIMw98YCo66tHqaUjhxNDml8O sgtfjfCtRC5QM8gc5CvxVDmMx+IMKXKxmdRvWm6uiTfL+gHV+2xq1aptxZBJOJnw== Received: by filterdrecv-58bfc74dd6-dgkl4 with SMTP id filterdrecv-58bfc74dd6-dgkl4-1-65C935E2-35 2024-02-11 21:02:26.65188053 +0000 UTC m=+1493150.685993704 Received: from earth.catern.com (unknown) by geopod-ismtpd-10 (SG) with ESMTP id kQgeBXH8T_6YWoenqCFPqA Sun, 11 Feb 2024 21:02:26.594 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=74.101.51.129; helo=localhost; envelope-from=sbaugh@catern.com; receiver=linkov.net Received: from localhost (unknown [74.101.51.129]) by earth.catern.com (Postfix) with ESMTPSA id 8B9956252E; Sun, 11 Feb 2024 21:02:33 +0000 (UTC) From: sbaugh@catern.com Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <867cjax4oc.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 11 Feb 2024 19:59:47 +0200") References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> <867cjax4oc.fsf@mail.linkov.net> Date: Sun, 11 Feb 2024 21:02:26 +0000 (UTC) Message-ID: <87zfw6ogt2.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbLM7kH=2Fi0DRuVS0ww27pp?= =?us-ascii?Q?SUPnMKkwhFmZZFcq0qk+5Gw5SYE4PfGBcjSZghL?= =?us-ascii?Q?PHL0STteeA5Kca3qQGUXEUOI9tpwECxLreZRPcS?= =?us-ascii?Q?TRHyov7fZA8dmAF3CcLL7m3+rwM8scdTob804J2?= =?us-ascii?Q?Py3GYpiRybelhh0tFFrrHKz0KOIoOaayJvg=3D=3D?= To: Juri Linkov X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, Spencer Baugh X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: >> The annoying thing is that this breaks the enhancement to >> completion-show-help I recently made. When a completion is not >> selected, RET isn't bound, so the help shows "Click or type M-x >> minibuffer-choose-completion-or-exit on a completion to select it." >> >> I'm not sure the right way to fix that. Selectively binding RET based >> on whether a completion is selected feels sketchy anyway, it may confuse >> users because e.g. C-h c RET won't work. >> >> Maybe instead we should always bind RET, but if no completion is >> selected, we run the command that RET was bound to before >> completion-in-region-mode started? > > Then 'minibuffer-choose-completion-or-exit' could be more smart > to run whatever command was bound to RET initially, instead of > using the hard-coded 'minibuffer-complete-and-exit'. > But this might require juggling with keymaps. Indeed, tricky. And since minibuffer-choose-completion-or-exit could be bound to other keys, not just RET, we shouldn't hardcode it to run what was bound to RET, too - it should run whatever it replaced. Maybe if there's no completion selected, it could push this-command-keys back on to unread-command-events, then disable completion-in-region-mode? Then Emacs would just do key lookup again for us. >> Alternatively... as a completely separate point, I'd like >> completion-in-region to select the first completion candidate by >> default. I think that's useful in some cases and, for >> completion-in-region, doesn't have any negatives: we couldn't do it in >> the minibuffer because it would interfere with accepting the default, >> but there are no defaults in completion-in-region. >> >> If we make c-i-r select the first completion candidate by default, that >> would both: >> >> - Make the completion-show-help help render correctly with the "only >> override RET when there's a selected completion" patch. >> >> - Partially mitigate the RET issue all on its own > > Calling 'first-completion' makes sense even for the minibuffer, > at least optionally. What about this simple patch? If minibuffer-visible-completions=nil, it just calls first-completion. This doesn't meaningfully change anything, since previously M-RET would just no-op in that situation. And it's actually quite useful, because it makes M-RET useful without having to ever actually do M-; one can just type text to narrow the completions and then hit M-RET. Which is sometimes nice. If minibuffer-visible-completions=t, it calls first-completion only when there's no minibuffer-default; that way a simple RET will still select the minibuffer default. diff --git a/lisp/simple.el b/lisp/simple.el index 8246b9cab81..715ab672655 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10355,7 +10355,10 @@ completion-setup-function "Type \\[minibuffer-choose-completion] on a completion to select it.\n"))) (insert (substitute-command-keys "Type \\[minibuffer-next-completion] or \\[minibuffer-previous-completion] \ -to move point between completions.\n\n"))))))) +to move point between completions.\n\n")))) + (unless (and minibuffer-visible-completions minibuffer-default) + (with-minibuffer-completions-window + (first-completion)))))) (add-hook 'completion-setup-hook #'completion-setup-function) From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 16 09:34:45 2024 Received: (at 68801) by debbugs.gnu.org; 16 Feb 2024 14:34:45 +0000 Received: from localhost ([127.0.0.1]:58138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1razIb-0002hF-0D for submit@debbugs.gnu.org; Fri, 16 Feb 2024 09:34:45 -0500 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:36215) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1razIY-0002h1-Qj for 68801@debbugs.gnu.org; Fri, 16 Feb 2024 09:34:43 -0500 From: Spencer Baugh To: sbaugh@catern.com Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <87zfw6ogt2.fsf@catern.com> (sbaugh@catern.com's message of "Sun, 11 Feb 2024 21:02:26 +0000 (UTC)") References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> <867cjax4oc.fsf@mail.linkov.net> <87zfw6ogt2.fsf@catern.com> Date: Fri, 16 Feb 2024 09:34:17 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1708094058; bh=hvCYgHzp20EDx1OihCTHSIbQ3V3WzksTVqBcrrUqtgw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=KUA6ffy0Jvddo2yNnYZUHbVxHCGiflEp5Jx1VIm8G2SB7c/6lN3m79BpvC4qOqYtG 9Gms2SPKuZ/iEGMzaeRQe9OkGf5vxK8NAuj7GDE792/CvlmBzT5XBqTCz7aWWRD5z/ /c6eiLk/403V+5DGUYkJQWcnwr8gfzSpLiwhqhl0KY9xg7IhoUuu0Lux5MP9E+lxvX IYOceWBZnIsYbxaFkXLRNHATgCyxWT5bwJrsQH4LTHB+wn/svbsXCMDyW7StemKWQ4 KXO2ynBSnp9ibz97IEN4i5u6NjTCmrplC6Pl0fQzho4M5L6n3NrB3xrk82+jXu5k4V nI3umXJ3jXajw== X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.9 (--) sbaugh@catern.com writes: >>> Alternatively... as a completely separate point, I'd like >>> completion-in-region to select the first completion candidate by >>> default. I think that's useful in some cases and, for >>> completion-in-region, doesn't have any negatives: we couldn't do it in >>> the minibuffer because it would interfere with accepting the default, >>> but there are no defaults in completion-in-region. >>> >>> If we make c-i-r select the first completion candidate by default, that >>> would both: >>> >>> - Make the completion-show-help help render correctly with the "only >>> override RET when there's a selected completion" patch. >>> >>> - Partially mitigate the RET issue all on its own >> >> Calling 'first-completion' makes sense even for the minibuffer, >> at least optionally. > > What about this simple patch? > > If minibuffer-visible-completions=nil, it just calls first-completion. > This doesn't meaningfully change anything, since previously M-RET would > just no-op in that situation. And it's actually quite useful, because > it makes M-RET useful without having to ever actually do M-; one > can just type text to narrow the completions and then hit M-RET. Which > is sometimes nice. > > If minibuffer-visible-completions=t, it calls first-completion only when > there's no minibuffer-default; that way a simple RET will still select > the minibuffer default. > > diff --git a/lisp/simple.el b/lisp/simple.el > index 8246b9cab81..715ab672655 100644 > --- a/lisp/simple.el > +++ b/lisp/simple.el > @@ -10355,7 +10355,10 @@ completion-setup-function > "Type \\[minibuffer-choose-completion] on a completion to select it.\n"))) > (insert (substitute-command-keys > "Type \\[minibuffer-next-completion] or \\[minibuffer-previous-completion] \ > -to move point between completions.\n\n"))))))) > +to move point between completions.\n\n")))) > + (unless (and minibuffer-visible-completions minibuffer-default) > + (with-minibuffer-completions-window > + (first-completion)))))) > > (add-hook 'completion-setup-hook #'completion-setup-function) > I found selecting first-completion in the minibuffer to be annoying, so now I'm trying with the following instead (which also fixes the highlight to actually be shown): (defun minibuffer-cir-first-completion () "Move point to the first completion in the *Completions* window." (when completion-in-region-mode (with-selected-window (get-buffer-window standard-output 0) (when completions-highlight-face (setq-local cursor-face-highlight-nonselected-window t)) (first-completion)))) (add-hook 'completion-setup-hook #'minibuffer-cir-first-completion 90) From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 18 02:47:49 2024 Received: (at 68801) by debbugs.gnu.org; 18 Feb 2024 07:47:49 +0000 Received: from localhost ([127.0.0.1]:34116 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbbtt-0003hG-7L for submit@debbugs.gnu.org; Sun, 18 Feb 2024 02:47:49 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:50187) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbbtq-0003gw-W2 for 68801@debbugs.gnu.org; Sun, 18 Feb 2024 02:47:48 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 669C3E0002; Sun, 18 Feb 2024 07:47:19 +0000 (UTC) From: Juri Linkov To: Spencer Baugh Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: (Spencer Baugh's message of "Fri, 16 Feb 2024 09:34:17 -0500") Organization: LINKOV.NET References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> <867cjax4oc.fsf@mail.linkov.net> <87zfw6ogt2.fsf@catern.com> Date: Sun, 18 Feb 2024 09:46:35 +0200 Message-ID: <86a5nyw768.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, sbaugh@catern.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.6 (---) > I found selecting first-completion in the minibuffer to be annoying, so > now I'm trying with the following instead (which also fixes the > highlight to actually be shown): > > (defun minibuffer-cir-first-completion () > "Move point to the first completion in the *Completions* window." > (when completion-in-region-mode > (with-selected-window (get-buffer-window standard-output 0) > (when completions-highlight-face > (setq-local cursor-face-highlight-nonselected-window t)) > (first-completion)))) > (add-hook 'completion-setup-hook #'minibuffer-cir-first-completion 90) I noticed the problem with highlighting in your previous patch too. Although I'm not sure why 'first-completion' didn't update the highlighting in your previous patch. 'completion-setup-function' enables 'completions-highlight': ;; Maybe enable cursor completions-highlight. (when completions-highlight-face (cursor-face-highlight-mode 1)) before you called 'first-completion' at the end of 'completion-setup-function'. From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 26 11:16:16 2024 Received: (at 68801) by debbugs.gnu.org; 26 Feb 2024 16:16:16 +0000 Received: from localhost ([127.0.0.1]:47026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1redeJ-0007iI-TK for submit@debbugs.gnu.org; Mon, 26 Feb 2024 11:16:16 -0500 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:41245) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1redeH-0007Ym-4z for 68801@debbugs.gnu.org; Mon, 26 Feb 2024 11:16:15 -0500 From: Spencer Baugh To: sbaugh@catern.com Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <871q9k6vfo.fsf@catern.com> (sbaugh@catern.com's message of "Sat, 10 Feb 2024 18:14:26 +0000 (UTC)") References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> Date: Mon, 26 Feb 2024 11:04:59 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1708963499; bh=pF4ya57az4brIBn95OZFwIb98ntaAGZTYlhoXOJhir0=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=CDiSHISoWZgr/LGWCMCVlRLt00w4lITdEXR2Hi/szzEw7yGEyxox507d2JtOAnjLO DMVpNs/BH7YgH7s4BSdNT4YfwTri2wvjxpa+H15TwzBL+SpKhhfJv4vAYUWpwqwy8o PoPUiBgD3Efmu0pvN6uFcVnmTvBjqDR5cSPnxPfDyUKCcbxKKJ573bYNrMKskCD0CG 0VyiqCCdHw/AXq/1bRoFO6X5XSDtLYy582Z4gYI0h+dVB+4tBx9zWgpza5xGcD8Bdq 0SDUZOTrMDS+Jo3czwDemccC1N8tXN8g6YaNOQVr0ZzONL9GUIbC4LGPiUcL7oP6hw Bgk0tGZZWCLaA== X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) sbaugh@catern.com writes: > Juri Linkov writes: >>>> 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? >>> >>> Yes, this makes sense. I'll try your patch for a while. >> >> Thanks for the patch, it works nicely. >> >> Could you please write a commit message for this patch. > > The annoying thing is that this breaks the enhancement to > completion-show-help I recently made. When a completion is not > selected, RET isn't bound, so the help shows "Click or type M-x > minibuffer-choose-completion-or-exit on a completion to select it." > > I'm not sure the right way to fix that. Selectively binding RET based > on whether a completion is selected feels sketchy anyway, it may confuse > users because e.g. C-h c RET won't work. > > Maybe instead we should always bind RET, but if no completion is > selected, we run the command that RET was bound to before > completion-in-region-mode started? > > Alternatively... as a completely separate point, I'd like > completion-in-region to select the first completion candidate by > default. Okay, after running with my patch doing this for a while, I don't think it's a good idea. It makes cir too different from minibuffer completion, and it just generally makes things a bit more unpredictable. Maybe we can think of a way to do it later. So anyway, this brings me back to wanting RET to insert a newline. I tried changing minibuffer-choose-completion-or-exit like so: diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 2a8439e03dd..cbf340f1dd6 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -4664,14 +4664,18 @@ minibuffer-choose-completion (defun minibuffer-choose-completion-or-exit (&optional no-exit no-quit) "Choose the completion from the minibuffer or exit the minibuffer. -When `minibuffer-choose-completion' can't find a completion candidate -in the completions window, then exit the minibuffer using its present -contents." +When `minibuffer-choose-completion' can't find a completion +candidate in the completions window, then hide the completions +window (which disables `minibuffer-visible-completions') and run +the command which this key was previously bound to, usually +exiting the minibuffer using its present contents." (interactive "P") (condition-case nil (let ((choose-completion-deselect-if-after t)) (minibuffer-choose-completion no-exit no-quit)) - (error (minibuffer-complete-and-exit)))) + (error (minibuffer-hide-completions) + (mapc (lambda (key) (push key unread-command-events)) + (this-command-keys-vector))))) (defun minibuffer-complete-history () "Complete the minibuffer history as far as possible. but it doesn't work in a few situations. Maybe there's a better way to do it though? 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? From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 27 15:45:57 2024 Received: (at 68801) by debbugs.gnu.org; 27 Feb 2024 20:45:57 +0000 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 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 From: Spencer Baugh To: sbaugh@catern.com Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: (Spencer Baugh's message of "Mon, 26 Feb 2024 11:04:59 -0500") References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> Date: Tue, 27 Feb 2024 15:45:23 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= 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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 29 12:57:59 2024 Received: (at 68801) by debbugs.gnu.org; 29 Feb 2024 17:57:59 +0000 Received: from localhost ([127.0.0.1]:35314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rfkfP-0003Ra-4g for submit@debbugs.gnu.org; Thu, 29 Feb 2024 12:57:59 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:55863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rfkfN-0003RM-6V for 68801@debbugs.gnu.org; Thu, 29 Feb 2024 12:57:57 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 403E91C0008; Thu, 29 Feb 2024 17:57:01 +0000 (UTC) From: Juri Linkov To: Spencer Baugh Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: (Spencer Baugh's message of "Tue, 27 Feb 2024 15:45:23 -0500") Organization: LINKOV.NET References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> Date: Thu, 29 Feb 2024 19:56:31 +0200 Message-ID: <86r0gvi27k.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, sbaugh@catern.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 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. Good idea, thanks. I will test your patch for a while. From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 15 03:44:26 2024 Received: (at 68801) by debbugs.gnu.org; 15 Mar 2024 07:44:26 +0000 Received: from localhost ([127.0.0.1]:51830 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rl2Er-00064V-VG for submit@debbugs.gnu.org; Fri, 15 Mar 2024 03:44:26 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:59527) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rl2Eq-00064E-Bj; Fri, 15 Mar 2024 03:44:25 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id A790560004; Fri, 15 Mar 2024 07:43:40 +0000 (UTC) From: Juri Linkov To: Spencer Baugh Subject: Re: bug#68801: 30.0.50; minibuffer-visible-completions=t makes RET in completion-in-region a no-op with nothing selected In-Reply-To: <86r0gvi27k.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 29 Feb 2024 19:56:31 +0200") Organization: LINKOV.NET References: <86y1c6688u.fsf@mail.linkov.net> <86plxiq6hv.fsf@mail.linkov.net> <867cjejfan.fsf@mail.linkov.net> <871q9k6vfo.fsf@catern.com> <86r0gvi27k.fsf@mail.linkov.net> Date: Fri, 15 Mar 2024 09:41:20 +0200 Message-ID: <86a5n00wnt.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68801 Cc: 68801@debbugs.gnu.org, sbaugh@catern.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 68801 30.0.50 thanks >> Complete patch attached, I think this closes the bug. > > Good idea, thanks. I will test your patch for a while. Thanks for the patch. Now pushed and closed. Or could reopen this request if you want also to add here a new option to auto-select the first completion. From unknown Fri Jun 20 19:48:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 12 Apr 2024 11:24:13 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator