From: "João Távora" <joaotavora@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 43120@debbugs.gnu.org, 19032@debbugs.gnu.org,
Sean Whitton <spwhitton@spwhitton.name>
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 [thread overview]
Message-ID: <87tuwaoj6g.fsf@gmail.com> (raw)
In-Reply-To: <87363w2ajd.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 05 Sep 2020 23:12:06 +0200")
[-- Attachment #1: Type: text/plain, Size: 874 bytes --]
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Sean Whitton <spwhitton@spwhitton.name> 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ão
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Change-icomplete-show-matches-on-no-input-behaviour-.patch --]
[-- Type: text/x-diff, Size: 3013 bytes --]
From f4dc81e0c7be75ace3766ca16e2be8bdcc8f0627 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= <joaotavora@gmail.com>
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
next prev parent reply other threads:[~2020-09-06 18:26 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-30 21:00 bug#43120: 28.0.50; fido-mode: M-j before completions appear selects wrong choice Sean Whitton
2020-08-30 23:50 ` João Távora
2020-08-31 16:37 ` Sean Whitton
2020-09-01 14:16 ` Lars Ingebrigtsen
2020-09-01 18:27 ` João Távora
2020-09-03 12:40 ` João Távora
2020-09-03 13:11 ` Lars Ingebrigtsen
2020-09-03 13:13 ` João Távora
2020-09-03 13:51 ` Lars Ingebrigtsen
2020-09-03 13:55 ` João Távora
2020-09-01 14:19 ` Lars Ingebrigtsen
2020-09-03 23:23 ` Sean Whitton
2020-09-04 2:11 ` Lars Ingebrigtsen
2020-09-04 3:22 ` Sean Whitton
2020-09-04 3:27 ` Lars Ingebrigtsen
2020-09-04 14:47 ` Sean Whitton
2020-09-05 12:25 ` Lars Ingebrigtsen
2020-09-05 15:32 ` Sean Whitton
2020-09-05 21:12 ` Lars Ingebrigtsen
2020-09-06 18:26 ` João Távora [this message]
2020-09-07 10:30 ` Lars Ingebrigtsen
2020-09-07 10:37 ` bug#19032: " João Távora
2020-09-07 11:43 ` Lars Ingebrigtsen
2020-09-07 17:30 ` Stefan Monnier
2020-09-08 6:52 ` João Távora
2020-09-08 8:59 ` bug#19032: " João Távora
2020-09-09 14:01 ` OGAWA Hirofumi
2020-09-09 16:11 ` bug#19032: " João Távora
2020-09-09 17:52 ` Stefan Monnier
2020-09-09 19:13 ` bug#19032: " João Távora
2020-09-09 19:52 ` Stefan Monnier
2020-09-09 19:54 ` bug#19032: " João Távora
2020-09-09 19:57 ` João Távora
2020-09-09 20:35 ` bug#19032: " Stefan Monnier
2020-09-09 22:08 ` João Távora
2020-09-10 4:36 ` Stefan Monnier
2020-09-10 18:51 ` bug#19032: " Juri Linkov
2020-09-10 19:15 ` João Távora
2020-09-09 18:58 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tuwaoj6g.fsf@gmail.com \
--to=joaotavora@gmail.com \
--cc=19032@debbugs.gnu.org \
--cc=43120@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=spwhitton@spwhitton.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).