changeset 180:cd4e645d1207

emacs localfuncs: add advice for ido to avoid blocking in flex matching
author Augie Fackler <durin42@gmail.com>
date Wed, 13 Jan 2010 10:29:36 -0600
parents ebbbf3567a0e
children 2d8105525973
files .elisp/settings/50.localfuncs.el
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.elisp/settings/50.localfuncs.el
+++ b/.elisp/settings/50.localfuncs.el
@@ -1,3 +1,22 @@
+;; advice to prevent ido from using flex matches on huge lists of files
+;; with enough characters typed and blocking for an absurd amount of time
+;; after a stupid typo
+;; The value af-ido-flex-fuzzy-limit is the maximum value of the product
+;; of the number of characters the user has entered and the number of
+;; options in the ido list.
+;; The default value was determined experimentally and seemed to be
+;; the boundary of sane wait times when this was written.
+(defvar af-ido-flex-fuzzy-limit (* 2000 5))
+(defadvice ido-set-matches-1 (around my-ido-set-matches-1 activate)
+  "Conditionally disable flex matching if the list is huge.
+
+This is useful because when the ido list is huge, ido flex matching
+spends an eternity in a regex if you make a typo."
+  (let ((ido-enable-flex-matching (< (* (length (ad-get-arg 0)) (length ido-text))
+                                     af-ido-flex-fuzzy-limit)))
+    ad-do-it))
+
+;; Generic repository differ. Requires textmate.el and mercurial.el.
 (defun af-generic-diff-repo ()
   (interactive)
   (let ((root (textmate-project-root)))