Icicle Fingers

Are ten fingers really enough to become a productive coder? I don’t think so. Are there ways to compensate for our lack of fingers? Lots! TAB key, at yer service!

As programmers, we generally like to lessen the amount of typing that we do. This is why most text environments offer TAB completion. You can use TAB completion in your shell, your text editor, or your IDE. While I don’t use the TAB character for my code, I do use the TAB key alot for completion. This makes the TAB key is my next favorite key after CTRL.

Code monkey like tab and mountain dew
Emacs has a multitude of ways to make you love that TAB key of yours even more than you currently do, and if you don’t, then you will definitely learn to love it. In this post though, I’ll share you my thoughts about Icicles.

At first, I was daunted by the number of Icicles stuff that I have to put on my .emacs. This helped me decide to opt for Ido for my buffer/file completion tool instead. As my usage of emacs grew heavier and heavier, I opted for WinRing as my emacs “window manager”. This led me to the discovery that Ido does not support (or perhaps I just don't know how to do it) completion when switching between window configurations. This discovery helped me gain the courage to try out Icicles.

Icicles is well documented in the emacs wiki. Even though I haven’t personally interacted with its developers, they do seem to be a smart and friendly bunch who do care about their users. Take a peek at Icicles’ newbie friendly introduction and see for yourself.

Icicles supports all kinds of minibuffer completion. It can even complete commands and file/directory names in shell mode! For instance you have a file called foo_foo_bar_foo_foo.baz in your pwd and you want to perform some operation on it. You can type, for instance, mv bar[SHIFT+TAB] and it will expand to foo_foo_bar_foo_foo.baz if the string bar is unique within your current directory. If not, you will then be presented with a list of possible completions. You can cycle through this list, or type some more to narrow the list of possible completions. In Icicles terminology this kind of completion is called apropos completion. If you know regex, apropos is something like “.?string.“. If you know SQL, apropos is something like LIKE %string%. You get the idea.

As a previous Ido user, I came to like fuzzy completion a lot. Icicles provides this through scatter completion. You can change the mode of completion by pressing M-(. Yes, Icicles supports multiple modes of completion, but the two modes previously mentioned are usually enough for me.

Of course, Icicles is not yet the perfect (well, almost) minibuffer completion mechanism for emacs. I do use shell mode a lot and I have several shell scripts which contains several function definitions. In a regular terminal, I can just type some part of the source function name and then press TAB to complete. Icicles’ list of possible completions doesn’t know about functions from a sourced script. Perhaps I just don’t know how to configure Icicles to include sourced functions, or perhaps I should take a closer look at bash completions. One easy way to get around this is to open the script in an emacs buffer. This way, I can use the omnipresent M-/ hippie-expand for completion, which is another addicting emacs feature.

Comments

comments powered by Disqus