Emacs already has decent completion capabilities. Any time there's a list of possible answers, you can press Tab for completion. When there's more than one possible completion, it brings up a list for you.
I like to see the list of possible completions without pressing Tab or ?. In XEmacs, I use two packages, iswitchb
and icomplete
to get a list of completions as I type, at least for switching buffers and for minibuffer inputs:
(require 'iswitchb) (setq iswitchb-buffer-ignore '("^ " "*Buffer")) (add-hook 'iswitchb-define-mode-map-hook '(lambda () (define-key iswitchb-mode-map " " 'iswitchb-next-match) (define-key iswitchb-mode-map [del] 'iswitchb-prev-match) (define-key iswitchb-mode-map [bs] 'iswitchb-prev-match) (define-key iswitchb-mode-map [right] 'iswitchb-next-match) (define-key iswitchb-mode-map [left] 'iswitchb-prev-match))) (icomplete-mode 1)
In Emacs22, I use ido
instead of iswitchb
. It works for both switching buffers and for opening files:
(setq ido-confirm-unique-completion t) (setq ido-default-buffer-method 'samewindow) (setq ido-use-filename-at-point t) (ido-mode t) (ido-everywhere t) (set-face-background 'ido-first-match "white") (set-face-foreground 'ido-subdir "blue3") (icomplete-mode 1)
If you're really into the power of completion, be sure to check out the icicles
package by Drew Adams. It has a lot more features, and it has some things that look incredibly useful. It works for buffers, files, and the minibuffer, and it allows you to chain together multiple commands in powerful ways.
If icicles
looks so good, why am I using ido
and icomplete
? It's because they come with Emacs22. The bar is higher for third party packages because it's an added dependency. I can't just tell a friend to put something into their .emacs
; I have to tell them to download it and add to their load-path
and so on. I wish there was a standard Emacs package system. I do plan to try out icicles
and other packages once I've finished exploring the standard set of packages that comes with Emacs22.
Update [2015]: I now use helm
, even though it's a third party dependency. Since I wrote this post in 2007, emacs added a package system so it's much easier to try out third party packages.
Labels: emacs
elpa seems promising, except for the fact that it doesn't actually contain very many packages :)
/J
I was using icicles for a while and I really liked it a lot. I think the interface is a lot simpler and more intuitive than ido. Unfortunately, I accidentally erased the 9 or so required files for icicles and haven't bothered to re-install them. I'm wish you that a package system would be great.
If you use iswitchb, check out isearchb too. It can save typing if the buffers you switch amongst have unique letters combinations in them.
how do I use ido in a text buffer, I just want to see completions in another buffer as I type.
Anonymous, if you're looking for matched lines in a buffer, try hidesearch.
For installing emacs packages, prefer ELPA if it contains what you want, but then go with auto-install.el (grab it from emacswiki). It has functions for installing any file off of emacswiki, any file on your filesystem, and any file you can get at via url. And a bunch of other stuff.
Very useful info. I was looking for a very long time for something like iswitchb.
elpa seems promising, except for the fact that it doesn't actually contain very many packages :)
/J
Post a Comment