Sunday, April 05, 2026

No File Name Completion With org-insert-link? Try This

If you invoke org-insert-link (typically C-c C-l) in order to link to a local file, you might expect that pressing TAB will complete a partial path or file name.  Instead you’ll get the frustrating message “[No match].”

What you need to do instead is to invoke the command with a prefix argument like this: C-u C-c C-l. Then you’ll get the expected completion behavior with TAB.

But why is a prefix argument necessary?  It turns out that org-insert-link expects a link type at the "Insert link" prompt.  Some link types are file, bbdb, info, etc.  (To see a full list of link types, press TAB right after invoking the command, without entering anything.)

This is a powerful command.  You can, for example, enter bbd and press TAB to complete the bbdb: link type.  Then enter the first few characters of someone’s name or a business in your bbdb list of contacts, such as arth.  Upon pressing TAB, you should see completion fill in arthur.  Press again, you’ll get Arthur Dent and perhaps his email address.  Clicking on either will complete the entry.  Press ENTER to put the link into your buffer.1

Completion isn’t available for all link types.  A link to an info node, for example, has to be entered manually, although usually it’s created with org-store-link (C-c l) while point is in the info node of interest.

I encourage you to read the help for org-insert-link and org-store-link.  The two hyperlinks immediately below will take you to the online manual on gnus.org.  But if you copy the link text and yank into an org file, Emacs will open the Org manual at the page for handling links.

[[help:org-insert-link][Emacs help for org-insert-link]]

[[help:org-store-link][Emacs help for org-store-link]]

I dislike getting frustrated.  But when I’m frustrated with Emacs, I expect to learn something if I dig deep enough.  It hasn’t let me down yet.


1 This depends on whether bbdb has been loaded.  If you use bbdb and you’re not getting completion, invoke M-x bbdb and try again.

No comments: