# HG changeset patch # User Augie Fackler # Date 1263400176 21600 # Node ID cd4e645d1207df8690279c7f372f1af67ebd78c8 # Parent ebbbf3567a0e1981c7812b1349253f32f202f7c3 emacs localfuncs: add advice for ido to avoid blocking in flex matching diff --git a/.elisp/settings/50.localfuncs.el b/.elisp/settings/50.localfuncs.el --- 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)))