Dmitry Dolzhenko RSS Feed

File name completion in Emacs

The Emacs Carnival for February is hosted by Sacha Chua and its topic is “Completion”. Below is my entry for this month's carnival.

Emacs has a myriad of ways to complete things for you in different contexts.

While the one I’d like to share with you may seem trivial, the feature is so ingrained into my workflow so that I even forgot that it’s not part of the core Emacs functionality.

I often switch from IntelliJ IDEA to Emacs (using a convenient shortcut) just to use the feature.

The feature provided by a wonderful cape.el package which extends the Emacs’ standard completion-at-point function with a bunch of handy completion functions or Capfs, one of which is cape-file.

What’s good about it is that it works in any mode, programming or not, and in any context be it a string literal or a comment.

Here is a snippet from my init.el:

(use-package cape
  :ensure t
  :init
  (add-to-list 'completion-at-point-functions #'cape-abbrev)
  (add-to-list 'completion-at-point-functions #'cape-file)
  (add-to-list 'completion-at-point-functions #'cape-elisp-block)
  (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster))
Reply by email