Skip to content

danskarda/ido-speed-hack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ido-speedup-hack.el

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:

Installation

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 '
  (progn
    (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")

Optimisations

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.

License

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
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
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/].

About

Speed improvements for Emacs ido-mode-el

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published