Getting a custom Info directory working with Emacs

I’ve just had a frustrating 15 minutes trying to get a custom “Info” directory working with Emacs on my Mac. I like to have my own texinfo files in a ~/my/doc/info directory. Unfortunately, I was having a hard job getting Emacs to incorporate the directory whenever I hit Ctl-h i.

It turns out - as I found out when I invoked (getenv INFOPATH) - that emacs on the Mac sets the INFOPATH environment variable. By adding the following code to my .emacs file, I’ve added my own info directory and corresponding files to the top of my help info page.

(setenv "INFOPATH" (concat (expand-file-name "~/my/doc/info:") (getenv "INFOPATH")))

Don’t forget to add a dir file in your custom info directory. Additional information can be found on the Emacs Wiki.