danskarda/ido-speed-hack
{ "createdAt": "2012-04-05T15:17:44Z", "defaultBranch": "master", "description": "Speed improvements for Emacs ido-mode-el", "fullName": "danskarda/ido-speed-hack", "homepage": "", "language": "Emacs Lisp", "name": "ido-speed-hack", "pushedAt": "2012-11-30T13:37:06Z", "stargazersCount": 10, "topics": [], "updatedAt": "2020-01-27T13:46:54Z", "url": "https://github.com/danskarda/ido-speed-hack"}ido-speedup-hack.el
Section titled “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:
- [ido-mode-el][] original ido.el
- [ido-better-flex][] optional package with better flexible suggestions.
Installation
Section titled “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-hackscd ~/emacs-hacks
git clone https://github.com/orfelyus/ido-mode-el.gitgit clone https://github.com/orfelyus/ido-speed-hack.git
# and optionallygit clone https://github.com/orfelyus/ido-better-flex.gitThen 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
Section titled “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
Section titled “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
Section titled “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
Section titled “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
Section titled “License”Copyright (C) 2012 Daniel Skarda
This program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.
You should have received a copy of the GNU General Public Licensealong with this program. If not, see [http://www.gnu.org/licenses/].[ido-mode-el] !: https://github.com/orfelyus/ido-mode-el [ido-better-flex] !: https://github.com/orfelyus/ido-better-flex