unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthew Leach <matthew@mattleach.net>
To: Ole Laursen <olau@iola.dk>
Cc: 19032@debbugs.gnu.org
Subject: bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
Date: Sat, 15 Nov 2014 23:08:12 +0000	[thread overview]
Message-ID: <8761egqcyr.fsf@matt-desktop.home> (raw)
In-Reply-To: <CANb2Ov+GMZ6qjaE7Of49n2dckT-1D9hAXPG7aQzarOLxphTUcA@mail.gmail.com> (Ole Laursen's message of "Wed, 12 Nov 2014 13:31:33 +0100")

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]

Hello,

Ole Laursen <olau@iola.dk> 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.
-- 
Matt

lisp/ChangeLog:

2014-11-15  Matthew Leach  <matthew@mattleach.net>

	* minibuffer.el
	(completion-use-stored-completions-when-no-input): New.
	(completion--complete-and-exit): Use the above to decide whether
	to use the car of `completion-all-sorted-completions' as the
	candidate.

	* icomplete.el (icomplete-minibuffer-setup): set
	`completion-use-stored-completions-when-no-input' when
	`icomplete-show-matches-on-no-input' is t.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: icomplete-cycle-fix.patch --]
[-- Type: text/x-diff, Size: 1860 bytes --]

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 95a6e1b..dc90f0e 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -262,6 +262,7 @@ Usually run by inclusion in `minibuffer-setup-hook'."
     (add-hook 'post-command-hook #'icomplete-post-command-hook nil t)
     (run-hooks 'icomplete-minibuffer-setup-hook)
     (when icomplete-show-matches-on-no-input
+      (setq completion-use-stored-completions-when-no-input t)
       (icomplete-exhibit))))
 
 (defvar icomplete--in-region-buffer nil)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c9ce381..4ea0530 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -969,6 +969,7 @@ completion candidates than this number."
 (defvar-local completion-all-sorted-completions nil)
 (defvar-local completion--all-sorted-completions-location nil)
 (defvar completion-cycling nil)
+(defvar completion-use-stored-completions-when-no-input nil)
 
 (defvar completion-fail-discreetly nil
   "If non-nil, stay quiet when there  is no match.")
@@ -1332,8 +1333,15 @@ If `minibuffer-completion-confirm' is `confirm-after-completion',
 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)

  reply	other threads:[~2014-11-15 23:08 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 [this message]
2020-08-13  9:34   ` Lars Ingebrigtsen
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=8761egqcyr.fsf@matt-desktop.home \
    --to=matthew@mattleach.net \
    --cc=19032@debbugs.gnu.org \
    --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).