From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: sbaugh@catern.com 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: Sun, 11 Feb 2024 21:02:26 +0000 (UTC) Message-ID: <87zfw6ogt2.fsf@catern.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4425"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68801@debbugs.gnu.org, Spencer Baugh To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 11 22:03:12 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 1rZGyk-0000qh-FM for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 11 Feb 2024 22:03:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZGyN-0003qp-8x; Sun, 11 Feb 2024 16:02:47 -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 1rZGyM-0003qc-1L for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2024 16:02:46 -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 1rZGyL-0003TH-Q7 for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2024 16:02:45 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZGyb-0002Fh-Su for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2024 16:03:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Feb 2024 21:03:01 +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.17076853718626 (code B ref 68801); Sun, 11 Feb 2024 21:03:01 +0000 Original-Received: (at 68801) by debbugs.gnu.org; 11 Feb 2024 21:02:51 +0000 Original-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 Original-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== Original-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 Original-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 Original-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) In-Reply-To: <867cjax4oc.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 11 Feb 2024 19:59:47 +0200") X-SG-EID: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbLM7kH/i0DRuVS0ww27ppSUPnMKkwhFmZZFcq0qk+5Gw5SYE4PfGBcjSZghLPHL0STteeA5Kca3qQGUXEUOI9tpwECxLreZRPcSTRHyov7fZA8dmAF3CcLL7m3+rwM8scdTob804J2Py3GYpiRybelhh0tFFrrHKz0KOIoOaayJvg== X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== 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:279870 Archived-At: 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)