Speed improvements for Emacs ido-mode-el
Emacs Lisp
Switch branches/tags
Nothing to show
Latest commit 325082a Nov 30, 2012 @danskarda Text corrections
Failed to load latest commit information.
benchmark Benchmark and results Nov 30, 2012
README.md Update README.md - describe installation Nov 20, 2012
results.md Text corrections Nov 30, 2012



Speed optimisations for Emacs IDO mode. It makes ido completion fast and interactive even with large sets of completions (eg. list of all commands in M-x, or large Info index files like Elisp or Emacs manual).

To achieve maximum speed, download following optimisations:


To get the best performance, install both ido-speed-hack and ido-mode-el (and optionally ido-better-flex).

First get latest version from GitHub:

mkdir ~/emacs-hacks
cd ~/emacs-hacks
git clone https://github.com/orfelyus/ido-mode-el.git
git clone https://github.com/orfelyus/ido-speed-hack.git

# and optionally
git clone https://github.com/orfelyus/ido-better-flex.git

Then bytecompile all files for better performance:

emacs --batch --eval '
    (byte-compile-file "ido-mode-el/ido.el" t)
    (byte-compile-file "ido-speed-hack/ido-speed-hack.el" t)
    (byte-compile-file "ido-better-flex/ido-better-flex.el" t))

And finally load from your ~/.emacs file:

(load "~/emacs-hacks/ido-mode-el/ido.elc")
(load "~/emacs-hacks/ido-better-flex/ido-better-flex.elc")
(load "~/emacs-hacks/ido-speed-hack/ido-speed-hack.elc")


ido-speed-hack increases ido performance in several ways:

  • function inlining (defsubst)
  • disabling ido-case-fold for some completions (all commands are lowercase anyway)
  • prunning collections based on character bitmaps
  • caching character bitmaps during completion or for same completions
  • caching intermediate completion lists when adding new characters

Last three optimisations works only when regular expressions are disabled.

Character bitmaps

List of completions are prefiltered based on character bitmaps Character bitmap is computed in function ido-string-to-bitmask.

Each character from a .. z (regardless case) is assigned one bit. Numbers, special characters - and * has also one bit assigned. 30 bits are enought to store all flags.

Character bitmap of a string is or of each individual string characters.

Before ido starts to examine completion list, ido-speed-hack prefilters the list and removes all words which miss some characters in ido-text. The filter is based on bitmap comparision.

Bitmap caching

All bitmaps are cached during an execution of completing-read. For special commands (execute-extended-command, describe-function, smex etc) this cache is shared between executions.

Result caching

If previous completion is a prefix of current completion, speed hack reuses results from previous call so ido does not start from original (long) list.


Copyright (C) 2012  Daniel Skarda

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see [http://www.gnu.org/licenses/].