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)
    (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)))))
    (when (stringp path)
      (setq path (mapcar #'list (split-string path path-separator t))))
    (when (or (null mailcap--computed-mime-data)
              (seq-some (lambda (f)
                          (file-has-changed-p (car f) 'mail-parse-mailcaps))
                        path))
      ;; 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)))
      ;; The ~/.mailcap entries will end up first in the resulting data.
      (dolist (spec (reverse path))
	(let ((source (cadr spec))
	      (file-name (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)))