unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs should provide more modern item completion out of the box
@ 2020-01-02 13:44 ndame
  2020-01-02 22:31 ` Dmitry Gutov
  0 siblings, 1 reply; 17+ messages in thread
From: ndame @ 2020-01-02 13:44 UTC (permalink / raw)
  To: emacs-devel@gnu.org

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



These days popular modern tools (IntelliJ, VSCode, etc.) all provide
quick and efficient methods to select items from a set of possible
completions. These completion tools have two main attributes:


1. The completion is some kind of flex completion where you don't have
to know and type the searched item exactly, it's enough to type parts
of it with or withouth spaces.

E.g. to execute "recover-this-file" you'd just type "M-x recfile" and
it's listed among the matches. Or to find "sort-numeric-fields" you
type "nufi" or "sofi".

The listing of matches usually involves some kind of recency bias, so
items you used before are listed first which makes it very convenient
to access your often used items, because in the list of matches they
are listed before the ones you rarely or never use.


2. The other thing is that selecting from a set of items gives you
instant feedback (maybe with a delay of a few hundred milliseconds),
so you don't have to press TAB or other keys for completion, the
matching items are listed immediately. (If there are too many matches
then the first, say, 50 is listed and the completion indicates you
have to keep typing in order to narrow down the number of matches
more.)


Emacs' current built in completion is kind of old fashined. Surely,
there are people who prefer it, but most people according to my
experience prefer completion systems like described above which
provide instant feedback with flex matching.

Emacs already has such packages which provide that experience. I'm
aware that integrating an external package for built in completion
involves copyright issues and extra work, so let's put those issues
aside for the moment, I'm more interested in the user interface angle
here.

Do you agree that Emacs could benefit from such a modern completion
system (for M-x, etc.) by providing a more attractive out of the box
experience?

[-- Attachment #2: Type: text/html, Size: 2216 bytes --]

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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-02 13:44 Emacs should provide more modern item completion out of the box ndame
@ 2020-01-02 22:31 ` Dmitry Gutov
  2020-01-03  5:39   ` ndame
  2020-01-03  9:18   ` Andrea Corallo
  0 siblings, 2 replies; 17+ messages in thread
From: Dmitry Gutov @ 2020-01-02 22:31 UTC (permalink / raw)
  To: ndame, emacs-devel@gnu.org

Hi!

On 02.01.2020 15:44, ndame wrote:
> Do you agree that Emacs could benefit from such a modern completion
> system (for M-x, etc.) by providing a more attractive out of the box
> experience?

There are several.

For M-x, the easiest one to try out is 'M-x icomplete-mode'. Turn it on 
and see how you like the new 'M-x' experience.

And when Emacs 27 comes out, or if you can install a recent snapshot, 
try out 'M-x fido-mode'. It's a somewhat tweaked version of the former.



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-02 22:31 ` Dmitry Gutov
@ 2020-01-03  5:39   ` ndame
  2020-01-28 21:54     ` Juri Linkov
  2020-01-03  9:18   ` Andrea Corallo
  1 sibling, 1 reply; 17+ messages in thread
From: ndame @ 2020-01-03  5:39 UTC (permalink / raw)
  To: emacs-devel@gnu.org, Dmitry Gutov

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

> There are several. For M-x, the easiest one to try out is 'M-x icomplete-mode'.
> Turn it on and see how you like the new 'M-x' experience.

I tried it. It has the immediate feedback, but it still requires
pressing TABs, lacks flex matching and has no recency bias.

So it has only one of the things which modern completion systems provide.

Also, the horizontal format makes it only suitable for selecting from
short items. When you have long items in your candidate list
(e.g. different long paths from all over the file sytem) then it
doesn't work. That's why modern systems use a vertical display,
or support it also, besides the horizontal format.

> And when Emacs 27 comes out, or if you can install a recent snapshot,
> try out 'M-x fido-mode'. It's a somewhat tweaked version of the former.

I'll check it out. I see from the docs it has flex matching, which is better.
 

[-- Attachment #2: Type: text/html, Size: 1056 bytes --]

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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-02 22:31 ` Dmitry Gutov
  2020-01-03  5:39   ` ndame
@ 2020-01-03  9:18   ` Andrea Corallo
  2020-01-03  9:45     ` ndame
                       ` (4 more replies)
  1 sibling, 5 replies; 17+ messages in thread
From: Andrea Corallo @ 2020-01-03  9:18 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: ndame, emacs-devel@gnu.org

Dmitry Gutov <dgutov@yandex.ru> writes:

> Hi!
>
> On 02.01.2020 15:44, ndame wrote:
>> Do you agree that Emacs could benefit from such a modern completion
>> system (for M-x, etc.) by providing a more attractive out of the box
>> experience?
>
> There are several.
>
> For M-x, the easiest one to try out is 'M-x icomplete-mode'. Turn it
> on and see how you like the new 'M-x' experience.
>
> And when Emacs 27 comes out, or if you can install a recent snapshot,
> try out 'M-x fido-mode'. It's a somewhat tweaked version of the
> former.

Hi, in my opinion despite completion the other feature that is really
killer in helm-M-x is that it suggests the key bindings associated with
the listed commands.

This is extremely helpful for learning new Emacs key bindings with
almost no effort.

Is there a way to have that with fido-mode or icomplete-mode?

Thanks

Andrea

--
akrl@sdf.org



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-03  9:18   ` Andrea Corallo
@ 2020-01-03  9:45     ` ndame
  2020-01-03 12:57     ` Dmitry Gutov
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: ndame @ 2020-01-03  9:45 UTC (permalink / raw)
  To: Andrea Corallo, Dmitry Gutov; +Cc: emacs-devel@gnu.org

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

> Hi, in my opinion despite completion the other feature that is really
> killer in helm-M-x is that it suggests the key bindings associated with
> the listed commands.
 >This is extremely helpful for learning new Emacs key bindings with
> almost no effort.

Good point. Intellij also shows the keybindings and even the menu items through 
which the command can be accessed.

It would be nice to have a default completion display in emacs with an easy to read
pleasant format like this:

https://www.jetbrains.com/help/img/idea/2019.3/gotoAction.png

[-- Attachment #2: Type: text/html, Size: 651 bytes --]

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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-03  9:18   ` Andrea Corallo
  2020-01-03  9:45     ` ndame
@ 2020-01-03 12:57     ` Dmitry Gutov
  2020-01-03 22:37     ` jeremyb
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Dmitry Gutov @ 2020-01-03 12:57 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: ndame, emacs-devel@gnu.org

On 03.01.2020 11:18, Andrea Corallo wrote:
> Hi, in my opinion despite completion the other feature that is really
> killer in helm-M-x is that it suggests the key bindings associated with
> the listed commands.
> 
> This is extremely helpful for learning new Emacs key bindings with
> almost no effort.
> 
> Is there a way to have that with fido-mode or icomplete-mode?

Not exactly.

But you can go the third-party packages route and install counsel and 
ivy-posframe. Here's a screenshot of how they can be configured together:

https://www.reddit.com/r/emacs/comments/ehjcu2/screenshot_polishing_my_emacs_who_said_an_old/



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-03  9:18   ` Andrea Corallo
  2020-01-03  9:45     ` ndame
  2020-01-03 12:57     ` Dmitry Gutov
@ 2020-01-03 22:37     ` jeremyb
  2020-01-04 18:16       ` Andrea Corallo
  2020-01-04 20:52     ` Stefan Monnier
  2020-01-08 10:22     ` Stefan Kangas
  4 siblings, 1 reply; 17+ messages in thread
From: jeremyb @ 2020-01-03 22:37 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: ndame, emacs-devel@gnu.org, Dmitry Gutov


Andrea

For this,
> This is extremely helpful for learning new Emacs key bindings with
> almost no effort.
you also have which-key-mode



Andrea Corallo <akrl@sdf.org> writes:

> Dmitry Gutov <dgutov@yandex.ru> writes:
>
>> Hi!
>>
>> On 02.01.2020 15:44, ndame wrote:
>>> Do you agree that Emacs could benefit from such a modern completion
>>> system (for M-x, etc.) by providing a more attractive out of the box
>>> experience?
>>
>> There are several.
>>
>> For M-x, the easiest one to try out is 'M-x icomplete-mode'. Turn it
>> on and see how you like the new 'M-x' experience.
>>
>> And when Emacs 27 comes out, or if you can install a recent snapshot,
>> try out 'M-x fido-mode'. It's a somewhat tweaked version of the
>> former.
>
> Hi, in my opinion despite completion the other feature that is really
> killer in helm-M-x is that it suggests the key bindings associated with
> the listed commands.
>
> This is extremely helpful for learning new Emacs key bindings with
> almost no effort.
>
> Is there a way to have that with fido-mode or icomplete-mode?
>
> Thanks
>
> Andrea




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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-03 22:37     ` jeremyb
@ 2020-01-04 18:16       ` Andrea Corallo
  2020-01-08 10:28         ` Stefan Kangas
  0 siblings, 1 reply; 17+ messages in thread
From: Andrea Corallo @ 2020-01-04 18:16 UTC (permalink / raw)
  To: jeremyb; +Cc: ndame, Dmitry Gutov, emacs-devel@gnu.org

jeremyb <jb@jeremybryant.net> writes:

> Andrea
>
> For this,
>> This is extremely helpful for learning new Emacs key bindings with
>> almost no effort.
> you also have which-key-mode

Yes but that is a different thing.  which-key-mode helps during the
execution of a key stroke while helm-M-x let you discover new
interactive commands and associated bindings.  Both are useful for
learning but at the time I've found the later more effective.

Andrea

-- 
akrl@sdf.org



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-03  9:18   ` Andrea Corallo
                       ` (2 preceding siblings ...)
  2020-01-03 22:37     ` jeremyb
@ 2020-01-04 20:52     ` Stefan Monnier
  2020-01-06 15:27       ` Dmitry Gutov
  2020-01-08 10:22     ` Stefan Kangas
  4 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2020-01-04 20:52 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: ndame, emacs-devel@gnu.org, Dmitry Gutov

[ About the general idea: I do think we should include company-mode in
  the tarball, yes.  Hopefully even enable it by default.  There's no
  copyright hurdle on this one, only technical&political ones.  ]

> Hi, in my opinion despite completion the other feature that is really
> killer in helm-M-x is that it suggests the key bindings associated with
> the listed commands.

This is specific to `M-x`.  I re-implemented `execute-extended-command` in
Elisp, specifically so it would be easier to extend&modify.

It should be very easy to change `execute-extended-command` such that
the *Completion* buffer lists things like

    execute-extended-command (M-x)
    save-buffer (C-x C-s)
    ...


-- Stefan




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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-04 20:52     ` Stefan Monnier
@ 2020-01-06 15:27       ` Dmitry Gutov
  2020-01-06 15:52         ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2020-01-06 15:27 UTC (permalink / raw)
  To: Stefan Monnier, Andrea Corallo; +Cc: ndame, emacs-devel@gnu.org

On 04.01.2020 22:52, Stefan Monnier wrote:
> [ About the general idea: I do think we should include company-mode in
>    the tarball, yes.  Hopefully even enable it by default.  There's no
>    copyright hurdle on this one, only technical&political ones.  ]

The first part of the question was about M-x, and company-mode doesn't 
work in the minibuffer at all at the moment.

Maybe we could start with providing a non-overlay-based popup library 
which works everywhere, and could be used by both company and 
execute-extended-command (and its replacements).



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-06 15:27       ` Dmitry Gutov
@ 2020-01-06 15:52         ` Stefan Monnier
  0 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2020-01-06 15:52 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: ndame, emacs-devel@gnu.org, Andrea Corallo

> Maybe we could start with providing a non-overlay-based popup library which
> works everywhere, and could be used by both company and
> execute-extended-command (and its replacements).

Yes, please,


        Stefan




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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-03  9:18   ` Andrea Corallo
                       ` (3 preceding siblings ...)
  2020-01-04 20:52     ` Stefan Monnier
@ 2020-01-08 10:22     ` Stefan Kangas
  4 siblings, 0 replies; 17+ messages in thread
From: Stefan Kangas @ 2020-01-08 10:22 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: ndame, emacs-devel@gnu.org, Dmitry Gutov

Andrea Corallo <akrl@sdf.org> writes:

> Hi, in my opinion despite completion the other feature that is really
> killer in helm-M-x is that it suggests the key bindings associated with
> the listed commands.
>
> This is extremely helpful for learning new Emacs key bindings with
> almost no effort.

I think this is an excellent feature suggestion, and have therefore
filed a wishlist bug report for it:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39035

Best regards,
Stefan Kangas



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-04 18:16       ` Andrea Corallo
@ 2020-01-08 10:28         ` Stefan Kangas
  0 siblings, 0 replies; 17+ messages in thread
From: Stefan Kangas @ 2020-01-08 10:28 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: jeremyb, ndame, emacs-devel@gnu.org, Dmitry Gutov

Andrea Corallo <akrl@sdf.org> writes:

> Yes but that is a different thing.  which-key-mode helps during the
> execution of a key stroke while helm-M-x let you discover new
> interactive commands and associated bindings.  Both are useful for
> learning but at the time I've found the later more effective.

Agreed, and I happen to also use both.  (But I use swiper instead of helm.)

FWIW, which-key is useful enough that I think it should be part of Emacs.

Best regards,
Stefan Kangas



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-03  5:39   ` ndame
@ 2020-01-28 21:54     ` Juri Linkov
  2020-01-29  3:09       ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2020-01-28 21:54 UTC (permalink / raw)
  To: ndame; +Cc: Dmitry Gutov, emacs-devel@gnu.org

>> There are several. For M-x, the easiest one to try out is 'M-x icomplete-mode'.
>> Turn it on and see how you like the new 'M-x' experience.
>
> I tried it. It has the immediate feedback, but it still requires
> pressing TABs, lacks flex matching and has no recency bias.

Indeed, flex matching should be customized separately for icomplete-mode
(tho fido-mode uses it by default), but actually none of them requires
pressing TABs, and both have recency bias.

> Also, the horizontal format makes it only suitable for selecting from
> short items. When you have long items in your candidate list
> (e.g. different long paths from all over the file sytem) then it
> doesn't work. That's why modern systems use a vertical display,
> or support it also, besides the horizontal format.

Using a vertical display while keeping instant feedback of icomplete-mode
that doesn't require pressing TABs should be easy to do as well:

#+BEGIN_SRC emacs-lisp

(define-minor-mode minibuffer-quick-mode
  "Toggle minibuffer quick completion mode."
  :global t
  :group 'minibuffer
  (if minibuffer-quick-mode
      (add-hook 'minibuffer-setup-hook 'minibuffer-quick-setup)
    (remove-hook 'minibuffer-setup-hook 'minibuffer-quick-setup)))

(defun minibuffer-quick-setup ()
  (add-hook 'post-command-hook #'minibuffer-quick-update nil t))

(defvar minibuffer-quick-min 1
  "Minimal length of minibuffer contents to show completion.")

(defun minibuffer-quick-update ()
  (when (>= (length (minibuffer-contents)) minibuffer-quick-min)
    (let ((completion-styles '(flex))
          (last-command nil))
      (minibuffer-complete))))

(minibuffer-quick-mode)

#+END_SRC



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-28 21:54     ` Juri Linkov
@ 2020-01-29  3:09       ` Stefan Monnier
  2020-01-29 23:00         ` Juri Linkov
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2020-01-29  3:09 UTC (permalink / raw)
  To: Juri Linkov; +Cc: ndame, emacs-devel@gnu.org, Dmitry Gutov

> Using a vertical display while keeping instant feedback of icomplete-mode
> that doesn't require pressing TABs should be easy to do as well:
[,,,]
> (defun minibuffer-quick-update ()
>   (when (>= (length (minibuffer-contents)) minibuffer-quick-min)
>     (let ((completion-styles '(flex))
>           (last-command nil))
>       (minibuffer-complete))))

Why `minibuffer-complete`?  This will actually perform completion
(i.e. it may modify the content of the minibuffer).  I think you want to
use `minibuffer-completion-help` instead (and I'm not sure why you bind
`completion-styles` since it will only take effect during the display
but not when the user finally hits RET).  Also, you probably want to run
this within a `while-no-input` of some kind.


        Stefan




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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-29  3:09       ` Stefan Monnier
@ 2020-01-29 23:00         ` Juri Linkov
  2020-01-29 23:57           ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2020-01-29 23:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: ndame, emacs-devel@gnu.org, Dmitry Gutov

>> Using a vertical display while keeping instant feedback of icomplete-mode
>> that doesn't require pressing TABs should be easy to do as well:
> [,,,]
>> (defun minibuffer-quick-update ()
>>   (when (>= (length (minibuffer-contents)) minibuffer-quick-min)
>>     (let ((completion-styles '(flex))
>>           (last-command nil))
>>       (minibuffer-complete))))
>
> Why `minibuffer-complete`?  This will actually perform completion
> (i.e. it may modify the content of the minibuffer).  I think you want to
> use `minibuffer-completion-help` instead

Ah, I completely forgot about the key `?'
(never used it since TAB is more DWIM-ish).

> (and I'm not sure why you bind `completion-styles` since it will only
> take effect during the display but not when the user finally hits RET).

This part I don't understand - it seems its main point is to take effect
during the display.

But anyway completion styles should be customized separately,
e.g. I think 'partial-completion' is more usable than 'flex' :)

> Also, you probably want to run this within a `while-no-input` of some kind.

'while-no-input' feels still too laggy when tried with this:

(defun minibuffer-quick-update ()
  (when (and minibuffer-completion-table
             (>= (length (minibuffer-contents)) minibuffer-quick-min))
    (let ((non-essential t))
      (while-no-input
        (minibuffer-completion-help)))))

Maybe better to use run-with-idle-timer that could be customized with
a number of seconds to delay.



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

* Re: Emacs should provide more modern item completion out of the box
  2020-01-29 23:00         ` Juri Linkov
@ 2020-01-29 23:57           ` Stefan Monnier
  0 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2020-01-29 23:57 UTC (permalink / raw)
  To: Juri Linkov; +Cc: ndame, emacs-devel@gnu.org, Dmitry Gutov

>> (and I'm not sure why you bind `completion-styles` since it will only
>> take effect during the display but not when the user finally hits RET).
>
> This part I don't understand - it seems its main point is to take effect
> during the display.

But with the code you proposed, the display list won't be in-sync with
the completion candidates used for RET, so you can get for example the
display to say that `rename-uniquely` is the only matching candidate and
then RET to reject saying there's "no match".

> But anyway completion styles should be customized separately,

Exactly.

>> Also, you probably want to run this within a `while-no-input` of some kind.
> 'while-no-input' feels still too laggy when tried with this:
> (defun minibuffer-quick-update ()
>   (when (and minibuffer-completion-table
>              (>= (length (minibuffer-contents)) minibuffer-quick-min))
>     (let ((non-essential t))
>       (while-no-input
>         (minibuffer-completion-help)))))
>
> Maybe better to use run-with-idle-timer that could be customized with
> a number of seconds to delay.

Probably,


        Stefan




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

end of thread, other threads:[~2020-01-29 23:57 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-02 13:44 Emacs should provide more modern item completion out of the box ndame
2020-01-02 22:31 ` Dmitry Gutov
2020-01-03  5:39   ` ndame
2020-01-28 21:54     ` Juri Linkov
2020-01-29  3:09       ` Stefan Monnier
2020-01-29 23:00         ` Juri Linkov
2020-01-29 23:57           ` Stefan Monnier
2020-01-03  9:18   ` Andrea Corallo
2020-01-03  9:45     ` ndame
2020-01-03 12:57     ` Dmitry Gutov
2020-01-03 22:37     ` jeremyb
2020-01-04 18:16       ` Andrea Corallo
2020-01-08 10:28         ` Stefan Kangas
2020-01-04 20:52     ` Stefan Monnier
2020-01-06 15:27       ` Dmitry Gutov
2020-01-06 15:52         ` Stefan Monnier
2020-01-08 10:22     ` Stefan Kangas

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