Hacking Emacs File Completion

James Dyer has another in his series of posts describing the sanding down of his workflow. This time he troubleshoots and resolves a problem with minibuffer file completion. His specific problem was that he didn’t like the way fuzzy file completion was working.

The default behavior was to have whatever he entered match any file name that had the same letters in the same order even if they weren’t consecutive. What he wanted was to match any files whose name had a substring that matched his input.

As usual, Emacs has you covered. There’s a completion-styles parameter that you can set to get the exact behavior he wanted. Except it didn’t work. It turned out that another function in the call path was resetting completion-styles to the behavior he was trying to avoid.

It wasn’t too hard to fix this and you see how he did it in his post. There was another small issue that he also fixed. Again, see Dyer’s post.

The meat of his post for me was his three conclusions at the end:

  1. The source code is always easily available and you can solve most problems by looking to see what is actually happening.
  2. Be wary of local versus global settings.
  3. With Emacs, there’s always another way. If you don’t like the way something works, Emacs probably provides another way of achieving the same end.

Most people probably aren’t going to care about the issue Dyer was fixing—at least I don’t care about it—but the point is that whatever Emacs is doing that’s not quite right for you, it’s almost always pretty easy to fix it.

This entry was posted in General and tagged . Bookmark the permalink.