Avoiding the Issue

25/12/2015

Mailcap files are commonly used to tell your MUA how to open
attachments. In Emacs this mechanism is used by Gnus, but outside of
it as well, like in Org’s “Open exported file” export option. I
wasn’t amused about it picking gv of all the things to open PDF
files, so I’ve edited ~/.mailcap and expected that to solve the
problem once and for all. Except it didn’t.

(defvarmailcap-parsed-pnil)(defunmailcap-parse-mailcaps(&optionalpathforce)"Parse out all the mailcaps specified in a path string PATH.
Components of PATH are separated by the `path-separator' character
appropriate for this system. If FORCE, re-parse even if already
parsed. If PATH is omitted, use the value of environment variable
MAILCAPS if set; otherwise (on Unix) use the path from RFC 1524, plus
/usr/local/etc/mailcap."(interactive(listnilt))(when(or(notmailcap-parsed-p)force)(cond(pathnil)((getenv"MAILCAPS")(setqpath(getenv"MAILCAPS")))((memqsystem-typemailcap-poor-system-types)(setqpath'("~/.mailcap""~/mail.cap""~/etc/mail.cap")))(t(setqpath;; This is per RFC 1524, specifically;; with /usr before /usr/local.'("~/.mailcap""/etc/mailcap""/usr/etc/mailcap""/usr/local/etc/mailcap"))))(let((fnames(reverse(if(stringppath)(split-stringpathpath-separatort)path)))fname)(whilefnames(setqfname(carfnames))(if(and(file-readable-pfname)(file-regular-pfname))(mailcap-parse-mailcapfname))(setqfnames(cdrfnames))))(setqmailcap-parsed-pt)))