all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
@ 2014-11-12 12:31 Ole Laursen
  2014-11-15 23:08 ` Matthew Leach
  0 siblings, 1 reply; 10+ messages in thread
From: Ole Laursen @ 2014-11-12 12:31 UTC (permalink / raw)
  To: 19032

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.


Ole





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Matthew Leach @ 2014-11-15 23:08 UTC (permalink / raw)
  To: Ole Laursen; +Cc: 19032

[-- 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)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  2014-11-15 23:08 ` Matthew Leach
@ 2020-08-13  9:34   ` Lars Ingebrigtsen
  2020-08-13 10:00     ` Ole Laursen
  2020-08-13 13:43     ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-13  9:34 UTC (permalink / raw)
  To: Matthew Leach; +Cc: Ole Laursen, Stefan Monnier, 19032

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





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  2020-08-13  9:34   ` Lars Ingebrigtsen
@ 2020-08-13 10:00     ` Ole Laursen
  2020-08-13 13:43     ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Ole Laursen @ 2020-08-13 10:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Matthew Leach, Stefan Monnier, 19032

Thanks!

I'm a former iswitchb user, and this problem keeps me from switching
to icomplete (I'm currently on ido-switch-buffer), even though I would
like to have access to more advanced completion.


Ole

Den tor. 13. aug. 2020 kl. 11.34 skrev Lars Ingebrigtsen <larsi@gnus.org>:
>
> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  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
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2020-08-13 13:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Matthew Leach, 19032, Ole Laursen

> +(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))

Would it be cleaner to have the following instead?

      ;; Allow user to specify null string.  Obey `completion-content-when-empty`.
      ((= beg end)
       (when completion-content-when-empty
         (completion--replace beg end completion-content-when-empty))
       (funcall exit-function))

So icomplete would be in charge of setting that var to the `car` of
`completion-all-sorted-completions`.


        Stefan






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  2020-08-13 13:43     ` Stefan Monnier
@ 2020-08-14 11:03       ` Lars Ingebrigtsen
  2020-08-14 11:30         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-14 11:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Matthew Leach, 19032, Ole Laursen

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Would it be cleaner to have the following instead?
>
>       ;; Allow user to specify null string.  Obey `completion-content-when-empty`.
>       ((= beg end)
>        (when completion-content-when-empty
>          (completion--replace beg end completion-content-when-empty))
>        (funcall exit-function))
>
> So icomplete would be in charge of setting that var to the `car` of
> `completion-all-sorted-completions`.

Yeah, that makes sense.  I'll take a stab at implementing it that way.

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  2020-08-14 11:03       ` Lars Ingebrigtsen
@ 2020-08-14 11:30         ` Lars Ingebrigtsen
  2020-08-14 12:33           ` Ole Laursen
  2020-08-18 18:00           ` Matthew Leach
  0 siblings, 2 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-14 11:30 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Matthew Leach, 19032, Ole Laursen

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Yeah, that makes sense.  I'll take a stab at implementing it that way.

I think I found where in the icomplete machinery to set this variable,
so I've now pushed this change.  It would be nice if others could test
this, too, and see whether it works.  :-)

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  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
  1 sibling, 1 reply; 10+ messages in thread
From: Ole Laursen @ 2020-08-14 12:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Matthew Leach, Stefan Monnier, 19032

I just built from trunk, and it now works! Flawless victory. :)

Thanks again to all involved!


Ole

Den fre. 14. aug. 2020 kl. 13.31 skrev Lars Ingebrigtsen <larsi@gnus.org>:
>
> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> > Yeah, that makes sense.  I'll take a stab at implementing it that way.
>
> I think I found where in the icomplete machinery to set this variable,
> so I've now pushed this change.  It would be nice if others could test
> this, too, and see whether it works.  :-)
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  2020-08-14 12:33           ` Ole Laursen
@ 2020-08-14 12:35             ` Lars Ingebrigtsen
  0 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-14 12:35 UTC (permalink / raw)
  To: Ole Laursen; +Cc: Matthew Leach, Stefan Monnier, 19032

Ole Laursen <olau@iola.dk> writes:

> I just built from trunk, and it now works! Flawless victory. :)

Thanks for testing.  :-)

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#19032: 24.4; icomplete cannot select matches with C-x b with no input
  2020-08-14 11:30         ` Lars Ingebrigtsen
  2020-08-14 12:33           ` Ole Laursen
@ 2020-08-18 18:00           ` Matthew Leach
  1 sibling, 0 replies; 10+ messages in thread
From: Matthew Leach @ 2020-08-18 18:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Ole Laursen, Stefan Monnier, 19032


Lars Ingebrigtsen <larsi@gnus.org> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> Yeah, that makes sense.  I'll take a stab at implementing it 
>> that way.
>
> I think I found where in the icomplete machinery to set this 
> variable,
> so I've now pushed this change.  It would be nice if others 
> could test
> this, too, and see whether it works.  :-)

Thanks for fixing this Lars.  Much appreciated!
--
Matt





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-08-18 18:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.