From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: Re: Emacs needs truely useful flex matching Date: Thu, 21 Mar 2013 18:49:42 +0100 Message-ID: <877gl0od6x.fsf@wanadoo.es> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363888709 11698 80.91.229.3 (21 Mar 2013 17:58:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Mar 2013 17:58:29 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 21 18:58:55 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UIjlO-0000zm-Rc for ged-emacs-devel@m.gmane.org; Thu, 21 Mar 2013 18:58:54 +0100 Original-Received: from localhost ([::1]:36464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIjl1-0005yT-1V for ged-emacs-devel@m.gmane.org; Thu, 21 Mar 2013 13:58:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIjkx-0005xB-K1 for emacs-devel@gnu.org; Thu, 21 Mar 2013 13:58:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIjkq-0007Ii-Ga for emacs-devel@gnu.org; Thu, 21 Mar 2013 13:58:27 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:37396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIjcn-0004kb-MW for emacs-devel@gnu.org; Thu, 21 Mar 2013 13:50:01 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UIjd9-0002nT-4u for emacs-devel@gnu.org; Thu, 21 Mar 2013 18:50:23 +0100 Original-Received: from 203.red-81-38-65.dynamicip.rima-tde.net ([81.38.65.203]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 21 Mar 2013 18:50:23 +0100 Original-Received: from ofv by 203.red-81-38-65.dynamicip.rima-tde.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 21 Mar 2013 18:50:23 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 203.red-81-38-65.dynamicip.rima-tde.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:v2MgNyANue0ycnaKoG+FGruB/WM= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:158036 Archived-At: Le Wang 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. 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) but obviously it is working for that vim extension.