unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Matthew Leach <matthew@mattleach.net>
Cc: Ole Laursen <olau@iola.dk>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	19032@debbugs.gnu.org
Subject: bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
Date: Thu, 13 Aug 2020 11:34:22 +0200	[thread overview]
Message-ID: <874kp6hotd.fsf@gnus.org> (raw)
In-Reply-To: <8761egqcyr.fsf@matt-desktop.home> (Matthew Leach's message of "Sat, 15 Nov 2014 23:08:12 +0000")

Matthew Leach <matthew@mattleach.net> writes:

>> Run emacs -Q, evaluate
>>
>>   (icomplete-mode 1)
>>   (setq icomplete-show-matches-on-no-input t)
>>
>> Make sure you have three buffers, e.g. by finding three files. Then
>> hit C-x b which should immediately show all buffers and use C-. or C-,
>> to select any other buffer than  what the modeline declares to be the
>> default, and hit C-j or RET.
>>
>> Emacs then switches to the default buffer instead of the selected buffer.
>
> I'm not sure if this is expected behaviour, since the "default" prompt
> in the minibuffer doesn't disappear when cycling through results.
> Nevertheless attached is a patch that fixes this.

I've respun the patch for Emacs 28, and I think the new behaviour makes
a lot more sense than the old behaviour, which I couldn't understand the
point of at all.

But I'm not an icomplete user, so perhaps the old behaviour is what
people want?

This also has possible ramifications for other completion styles
(although only icomplete enables it with this patch), so I wonder
whether Stefan has any comments here?

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 3747ae3d28..e3f7043e2c 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -432,6 +432,8 @@ icomplete-minibuffer-setup
     					 (current-local-map)))
     (add-hook 'pre-command-hook  #'icomplete-pre-command-hook  nil t)
     (add-hook 'post-command-hook #'icomplete-post-command-hook nil t)
+    (when icomplete-show-matches-on-no-input
+      (setq-local completion-use-stored-completions-when-no-input t))
     (run-hooks 'icomplete-minibuffer-setup-hook)))
 
 (defvar icomplete--in-region-buffer nil)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index d2c3f9045e..c3e5440956 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1126,6 +1126,7 @@ completion--cycle-threshold
 (defvar-local completion-all-sorted-completions nil)
 (defvar-local completion--all-sorted-completions-location nil)
 (defvar completion-cycling nil)      ;Function that takes down the cycling map.
+(defvar completion-use-stored-completions-when-no-input nil)
 
 (defvar completion-fail-discreetly nil
   "If non-nil, stay quiet when there  is no match.")
@@ -1510,8 +1511,15 @@ completion--complete-and-exit
 COMPLETION-FUNCTION is called if the current buffer's content does not
 appear to be a match."
     (cond
-     ;; Allow user to specify null string
-   ((= beg end) (funcall exit-function))
+     ;; Allow user to specify null string.  In the case that
+     ;; `completion-use-stored-completions-when-no-input' is t, use
+     ;; the car of `completion-all-sorted-completions' as the
+     ;; candidate.
+     ((= beg end)
+      (when completion-use-stored-completions-when-no-input
+        (completion--replace beg end (car completion-all-sorted-completions)))
+      (funcall exit-function))
+
      ((test-completion (buffer-substring beg end)
                        minibuffer-completion-table
                        minibuffer-completion-predicate)


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





  reply	other threads:[~2020-08-13  9:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 12:31 bug#19032: 24.4; icomplete cannot select matches with C-x b with no input Ole Laursen
2014-11-15 23:08 ` Matthew Leach
2020-08-13  9:34   ` Lars Ingebrigtsen [this message]
2020-08-13 10:00     ` Ole Laursen
2020-08-13 13:43     ` Stefan Monnier
2020-08-14 11:03       ` Lars Ingebrigtsen
2020-08-14 11:30         ` Lars Ingebrigtsen
2020-08-14 12:33           ` Ole Laursen
2020-08-14 12:35             ` Lars Ingebrigtsen
2020-08-18 18:00           ` Matthew Leach

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=874kp6hotd.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=19032@debbugs.gnu.org \
    --cc=matthew@mattleach.net \
    --cc=monnier@iro.umontreal.ca \
    --cc=olau@iola.dk \
    /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).