unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Le Wang <l26wang@gmail.com>
To: "Óscar Fuentes" <ofv@wanadoo.es>
Cc: emacs-devel@gnu.org
Subject: Re: Emacs needs truely useful flex matching
Date: Fri, 22 Mar 2013 07:34:07 +0800	[thread overview]
Message-ID: <CAM=K+iotF2wn_83NYhuQgW1cn4HrQCY8M1-LeBfXKtq6yaYwYA@mail.gmail.com> (raw)
In-Reply-To: <877gl0od6x.fsf@wanadoo.es>

On Fri, Mar 22, 2013 at 1:49 AM, Óscar Fuentes <ofv@wanadoo.es> wrote:
> Le Wang <l26wang@gmail.com> writes:
>
>> Since there is a big thread about a standard way to recognise project roots, I
>> want to bring up another area in which Emacs is falling behind other
>> Editors (Sublime Text, Textmate, and Vim).
>> Choosing from a very large list of files (or any strings for that matter) with
>> a minimum of keystrokes.
>>
>> ido-mode has `ido-enable-flex-matching', but that does not do the smart
>> sorting required.
>>
>> Vim has this through the Command-T plugin.  The best way to "get it" is by
>> watching it in action:
>> https://s3.amazonaws.com/s3.wincent.com/command-t/screencasts/command-t-demo.mov
>>
>> Skip to 6 minutes to see it in action in a large project with
>> repetitive path segments.
>>
>> Homepage here: https://wincent.com/products/command-t
>>
>> The matching engine is implemented in C and it interfaces with Vim through the
>> Ruby bridge.  I think in order to sort a large list of strings (> 10k), this
>> will also have to be implemented in C to be fast enough if done for Emacs.
>>
>> The sorting algorithm is roughly this for a query: "abcd"
>>
>> 1. Get all matches for "a.*b.*c.*c"
>> 2. Calculate score of each match
>>     - contiguous matched chars gets a boost
>>     - matches at word and camelCase boundaries (abbreviation) get a boost
>>     - matches with smallest starting index gets a boost
>> 2. Sort list according to score.
>>
>> A lot of my colleagues use this kind of flex matching to navigate around our
>> large code base in Sublime Text and I'm very jealous that with so few
>> keystrokes the most useful
>> matches just float to the top.
>>
>> This navigation could be implemented with Helm if Emacs had a builtin
>> fast smart flex sorting engine.
>
> IIUC the vim plugin you mention depends on a pre-built list of files. In
> that regard, how is it better than GNU Global, which allows to search
> files with a regex (and much more)? Maybe the algorithm you describe
> can be implemented on GNU Global and then use an Emacs interface.

The type of smart matching + sorting would be useful for files, M-x,
C-h v, all kinds of completion where large lists are involved.  GNU
globals maybe should support it, but Emacs shouldn't depend on
external dependency to offer something this useful.

> I agree that it would be nice to have such a feature native on Emacs,
> though. IIRC someone mentioned a few days ago that a regex of the type
> you descibe has very high execution complexity (-> is slow)

That is true, and speed is of the utmost essence, so emacs-lisp is
probably too slow.

> but obviously it is working for that vim extension.

Textmate has had this for a while, and I see Sublime Text do it very
well every day, of course.  :(

These editors are moving the ball for what people expect a modern
editor to provide.

Honestly when I first tried `ido-enable-flex-matchine', I thought it
was strange,  So it's entirely possible I haven't made the strongest
case for the usefulness of this feature.  Please let me know if you
aren't convinced..


-- 
Le



  reply	other threads:[~2013-03-21 23:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21 15:02 Emacs needs truely useful flex matching Le Wang
2013-03-21 17:49 ` Óscar Fuentes
2013-03-21 23:34   ` Le Wang [this message]
2013-03-21 23:58   ` Stefan Monnier
2013-03-22  1:00     ` Le Wang
2013-03-22  8:24       ` Eli Zaretskii
2013-03-22 11:18         ` Dmitry Gutov
2013-04-14 16:48       ` Le Wang
2013-04-14 18:18         ` Stefan Monnier
2013-04-15  0:14           ` Le Wang
2013-04-15 13:50             ` Stefan Monnier
2013-03-22  2:36 ` Richard Stallman

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='CAM=K+iotF2wn_83NYhuQgW1cn4HrQCY8M1-LeBfXKtq6yaYwYA@mail.gmail.com' \
    --to=l26wang@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=ofv@wanadoo.es \
    /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).