Function: mailcap-parse-mailcaps
mailcap-parse-mailcaps is an interactive and byte-compiled function
defined in mailcap.el.gz.
Signature
(mailcap-parse-mailcaps &optional PATH FORCE)
Documentation
Parse out all the mailcaps specified in a path string PATH.
Components of PATH are separated by the path-separator(var)/path-separator(fun) 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.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/net/mailcap.el.gz
(defun mailcap-parse-mailcaps (&optional path force)
"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 (list nil t))
(when (or (not mailcap-parsed-p)
force)
;; Clear out all old data.
(setq mailcap--computed-mime-data nil)
;; Add the Emacs-distributed defaults (which will be used as
;; fallbacks). Do it this way instead of just copying the list,
;; since entries are destructively modified.
(cl-loop for (major . minors) in mailcap-mime-data
do (cl-loop for (minor . entry) in minors
do (mailcap-add-mailcap-entry major minor entry)))
(cond
(path nil)
((getenv "MAILCAPS")
(setq path (getenv "MAILCAPS")))
((memq system-type mailcap-poor-system-types)
(setq path '(("~/.mailcap" user)
("~/mail.cap" user)
("~/etc/mail.cap" user))))
(t
(setq path
;; This is per RFC 1524, specifically with /usr before
;; /usr/local.
'(("~/.mailcap" user)
("/etc/mailcap" system)
("/usr/etc/mailcap" system)
("/usr/local/etc/mailcap" system)))))
;; The ~/.mailcap entries will end up first in the resulting data.
(dolist (spec (reverse
(if (stringp path)
(split-string path path-separator t)
path)))
(let ((source (and (consp spec) (cadr spec)))
(file-name (if (stringp spec)
spec
(car spec))))
(when (and (file-readable-p file-name)
(file-regular-p file-name))
(mailcap-parse-mailcap file-name source))))
(setq mailcap-parsed-p t)))