From f341074dd889e9d175bec1daff36920aed0f1750 Mon Sep 17 00:00:00 2001
From: Bozhidar Batsov <bozhidar@tradeo.com>
Date: Sat, 13 Jul 2013 10:01:19 +0300
Subject: [PATCH] Add flx to list of default packages

---
 README.md                | 12 ++++++++++++
 core/prelude-editor.el   |  5 +++++
 core/prelude-packages.el |  2 +-
 init.el                  |  4 ++++
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 98893e2..85488dc 100644
--- a/README.md
+++ b/README.md
@@ -430,6 +430,18 @@ you don't like that simply add this to your personal config:
                 'move-beginning-of-line)
 ```
 
+### Poor ido matching performance on large datasets
+
+Prelude swaps the default `ido` flex matching with the more powerful
+[ido-flx](https://github.com/lewang/flx). This might introduce some
+performance problems with huge datasets. If you experience lag in
+`ido`, please, report an issue upstream. You can always disable the
+improved matching algorithm like this:
+
+```lisp
+(flx-ido-mode -1)
+```
+
 ### Windows compatibility
 
 While everything in Prelude should work fine in Windows, I test it only
diff --git a/core/prelude-editor.el b/core/prelude-editor.el
index 2c9832f..117e797 100644
--- a/core/prelude-editor.el
+++ b/core/prelude-editor.el
@@ -213,6 +213,7 @@ Will only occur if prelude-whitespace is also enabled."
 ;; ido-mode
 (require 'ido)
 (require 'ido-ubiquitous)
+(require 'flx-ido)
 (setq ido-enable-prefix nil
       ido-enable-flex-matching t
       ido-create-new-buffer 'always
@@ -222,6 +223,10 @@ Will only occur if prelude-whitespace is also enabled."
       ido-default-file-method 'selected-window)
 (ido-mode +1)
 (ido-ubiquitous +1)
+;; smarter fuzzy matching for ido
+(flx-ido-mode +1)
+;; disable ido faces to see flx highlights
+(setq ido-use-faces nil)
 
 ;; smex, remember recently and most frequently used commands
 (require 'smex)
diff --git a/core/prelude-packages.el b/core/prelude-packages.el
index b023ac8..f357645 100644
--- a/core/prelude-packages.el
+++ b/core/prelude-packages.el
@@ -42,7 +42,7 @@
 
 (defvar prelude-packages
   '(ace-jump-mode ack-and-a-half dash diminish elisp-slime-nav
-    expand-region flycheck gist
+    expand-region flx flycheck gist
     git-commit-mode gitconfig-mode gitignore-mode grizzl
     guru-mode helm helm-projectile ido-ubiquitous
     key-chord magit rainbow-mode
diff --git a/init.el b/init.el
index 6a411f1..1ecf49c 100644
--- a/init.el
+++ b/init.el
@@ -72,6 +72,10 @@ by Prelude.")
 (add-to-list 'load-path prelude-vendor-dir)
 (prelude-add-subfolders-to-load-path prelude-vendor-dir)
 
+;; reduce the frequency of garbage collection by making it happen on
+;; each 50MB of allocated data (the default is on every 0.76MB)
+(setq gc-cons-threshold 50000000)
+
 ;; the core stuff
 (require 'prelude-packages)
 (require 'prelude-ui)