From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#19032: bug#43120: 28.0.50; fido-mode: M-j before completions appear selects wrong choice Date: Sun, 06 Sep 2020 19:26:47 +0100 Message-ID: <87tuwaoj6g.fsf@gmail.com> References: <8736433l4c.fsf@iris.silentflame.com> <87o8mpd1fw.fsf@gnus.org> <87tuwewik5.fsf@iris.silentflame.com> <87zh66qoi9.fsf@gnus.org> <87pn72w7j2.fsf@iris.silentflame.com> <87eenifcgr.fsf@gnus.org> <87mu25wqdf.fsf@iris.silentflame.com> <87k0x876ls.fsf@gnus.org> <87k0x8tf1n.fsf@iris.silentflame.com> <87363w2ajd.fsf@gnus.org> 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="3890"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 43120@debbugs.gnu.org, 19032@debbugs.gnu.org, Sean Whitton To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 06 20:28:11 2020 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 1kEzOc-0000ts-Uk for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Sep 2020 20:28:11 +0200 Original-Received: from localhost ([::1]:39730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEzOc-0004qZ-0O for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Sep 2020 14:28:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEzOU-0004qF-Ks for bug-gnu-emacs@gnu.org; Sun, 06 Sep 2020 14:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kEzOU-0003qM-0x for bug-gnu-emacs@gnu.org; Sun, 06 Sep 2020 14:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kEzOT-0005Fp-U9 for bug-gnu-emacs@gnu.org; Sun, 06 Sep 2020 14:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Sep 2020 18:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19032 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch fixed Original-Received: via spool by 19032-submit@debbugs.gnu.org id=B19032.159941682220027 (code B ref 19032); Sun, 06 Sep 2020 18:28:01 +0000 Original-Received: (at 19032) by debbugs.gnu.org; 6 Sep 2020 18:27:02 +0000 Original-Received: from localhost ([127.0.0.1]:47144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEzNV-0005Cr-Qj for submit@debbugs.gnu.org; Sun, 06 Sep 2020 14:27:02 -0400 Original-Received: from mail-wr1-f41.google.com ([209.85.221.41]:38095) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEzNU-0005CY-9k; Sun, 06 Sep 2020 14:27:00 -0400 Original-Received: by mail-wr1-f41.google.com with SMTP id g4so12778903wrs.5; Sun, 06 Sep 2020 11:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=r+mR28t0SILD0wD+2BPqgIhAzAmRzpvV9cLqZalhMj8=; b=bA0z6avjrIjnPNI9rYGYf2cCdtkI5pvZGzqdAGapVzIlPfltH0DoqCPO/0uxreN6hK XNJqhOHmvVt5nISEBzqB7Jwy7dk54YBSBFRPkARJmTL5KpdDfHK+SeclYhGmhzW7XWl1 9KVViX7RwPQ032JGUfrd7xLw5ukjTf89ktml1SiKDiCoEhmJ6UgdGP4x2296eordIIJ6 LZRr6KPDsIJ3pwv0j+Vu5RtRHzqhoz7uzFQchFKdq9QLSv2V7Eo+S3kUk/BcDEBXqDsh sCJH6SGamgXrgkr0ZkZ+Lvee8WEIJNPa4MoCVOu7Oe8r2Yhoq+X44MiwDexCZ9lic7MS s/eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=r+mR28t0SILD0wD+2BPqgIhAzAmRzpvV9cLqZalhMj8=; b=g49KcZLr4XnCQHUGx1puxWueUMvVbWMDruM6hPxbNaN+hYtMPI2tkDK+xa/FzVNOMb ZjRdxwV/znq1pM+/jZBnpJshx1otghjGW4ZucHuxwdNAYp/FzSnXJzS0dK7nXFulGaP0 /SSTErH92iaCMDFODiDie51dc3+6zM+v3amC9s4EWvycw2P3uLdw+eWpPFBCZ56y95u5 WXhaXlPpw2ItDw3c2fMLq7vWsCZoZUx4TO5009+LKvMFOgIp9VXKBoKg1Xw4l/fdcEzo ojI8YOXWfIkspgAXbxHEKKTwGt4LdL5YjTFesVmjk5xHSoFVAHm7gf2ulNLaZ5vFagaQ UySA== X-Gm-Message-State: AOAM533DioKRa3Lfc9Aao9mcBR8Dcm6UQtBHPdYjkPkw+gEoty4HZ9EG jkQRlFXzNDVILDnM9CMnHEe1/CLSoDM= X-Google-Smtp-Source: ABdhPJwCspVhfctmQVKNFAvZN5Cp/Ib6qYmVdBlVClTC31VOiECmGrfwj0yaVBFtOGnT0uq9EWJMZg== X-Received: by 2002:adf:f903:: with SMTP id b3mr18471983wrr.142.1599416814135; Sun, 06 Sep 2020 11:26:54 -0700 (PDT) Original-Received: from krug (93.102.201.41.rev.optimus.pt. [93.102.201.41]) by smtp.gmail.com with ESMTPSA id w15sm24038800wro.46.2020.09.06.11.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 11:26:53 -0700 (PDT) In-Reply-To: <87363w2ajd.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 05 Sep 2020 23:12:06 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:187372 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Lars Ingebrigtsen writes: > Sean Whitton writes: > >> On Sat 05 Sep 2020 at 02:25PM +02, Lars Ingebrigtsen wrote: >> >>> In which case -- does the following fix this problem? >> >> It does indeed. Hope this patch can be applied. > > Thanks for testing; I've now applied the patch. I've had a look at the original problem that triggered this, and I wonder if this much simpler patch wouldn't be preferable. For one, it doesn't touch the minibuffer.el machinery (which is complicated as it is) or has any kind of complicated caching semantics. It just binds a different command to RET in icomplete-minibuffer-map, presumably solving 19032 (in my limited testing). It's also guaranteed not to affect fido-mode. I think something like this is the way to go for a behaviour change such as this. Jo=C3=A3o --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Change-icomplete-show-matches-on-no-input-behaviour-.patch >From f4dc81e0c7be75ace3766ca16e2be8bdcc8f0627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 6 Sep 2020 19:03:52 +0100 Subject: [PATCH] Change icomplete-show-matches-on-no-input behaviour for Icomplete only Fixes: bug#19032, bug#43120 Previous fixes to bug#19032 introduced bugs in Fido mode. This fix relies on a new command bound to RET. * etc/NEWS (Miscellaneous): Mention icomplete-show-matches-on-no-input. * lisp/icomplete.el (icomplete-show-matches-on-no-input): Add comment. (icomplete-minibuffer-map): Bind icomplete-ret. (icomplete-ret): New command. --- etc/NEWS | 6 ++++++ lisp/icomplete.el | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 749b28ac3f..d40a4807ec 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -938,6 +938,12 @@ window after starting). This variable defaults to nil. ** Miscellaneous +--- +*** 'icomplete-show-matches-on-no-input' behavior change +Previously, choosing a different completion with commands like 'C-.' +and then hitting enter would choose the default completion. Doing +this will now choose the completion under point. + +++ *** The user can now customize how "default" values are prompted for. The new utility function 'format-prompt' has been added which uses the diff --git a/lisp/icomplete.el b/lisp/icomplete.el index f76ab28fb8..c4d5012af9 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -75,7 +75,11 @@ icomplete-tidy-shadowed-file-names selection process starts again from the user's $HOME.") (defcustom icomplete-show-matches-on-no-input nil - "When non-nil, show completions when first prompting for input." + "When non-nil, show completions when first prompting for input. +This also means that if you traverse the list of completions with +commands like `C-.' and just hit RET without typing any +characters, the match under point will be chosen instead of the +default." :type 'boolean :version "24.4") @@ -153,12 +157,22 @@ icomplete-post-command-hook (defvar icomplete-minibuffer-map (let ((map (make-sparse-keymap))) (define-key map [?\M-\t] 'icomplete-force-complete) + (define-key map (kbd "RET") 'icomplete-ret) (define-key map [?\C-j] 'icomplete-force-complete-and-exit) (define-key map [?\C-.] 'icomplete-forward-completions) (define-key map [?\C-,] 'icomplete-backward-completions) map) "Keymap used by `icomplete-mode' in the minibuffer.") +(defun icomplete-ret () + "Exit minibuffer for icomplete." + (interactive) + (if (and icomplete-show-matches-on-no-input + (car completion-all-sorted-completions) + (eql (icomplete--field-end) (icomplete--field-beg))) + (icomplete-force-complete-and-exit) + (exit-minibuffer))) + (defun icomplete-force-complete-and-exit () "Complete the minibuffer with the longest possible match and exit. Use the first of the matches if there are any displayed, and use -- 2.25.1 --=-=-=--