Function: mailcap-add-mailcap-entry

mailcap-add-mailcap-entry is a byte-compiled function defined in mailcap.el.gz.

Signature

(mailcap-add-mailcap-entry MAJOR MINOR INFO &optional STORAGE)

Documentation

Add handler INFO for mime type MAJOR/MINOR to STORAGE.

MAJOR and MINOR should be strings. MINOR is treated as a regexp in later lookups, and, therefore, you may need to escape it appropriately.

The format of INFO is described in mailcap-mime-data.

STORAGE should be a symbol referring to a variable. The value of this variable should have the same format as mailcap-mime-data. STORAGE defaults to mailcap--computed-mime-data.

None of this is enforced.

Source Code

;; Defined in /usr/src/emacs/lisp/net/mailcap.el.gz
(defun mailcap-add-mailcap-entry (major minor info &optional storage)
  "Add handler INFO for mime type MAJOR/MINOR to STORAGE.

MAJOR and MINOR should be strings.  MINOR is treated as a regexp
in later lookups, and, therefore, you may need to escape it
appropriately.

The format of INFO is described in `mailcap-mime-data'.

STORAGE should be a symbol referring to a variable.  The value of
this variable should have the same format as `mailcap-mime-data'.
STORAGE defaults to `mailcap--computed-mime-data'.

None of this is enforced."
  (let* ((storage (or storage 'mailcap--computed-mime-data))
	 (major-entry (assoc major (symbol-value storage)))
	 (new-minor-entry (cons minor info))
	 minor-entry)
    (cond
     ((null major-entry)
      ;; Add a new major entry containing the new minor entry.
      (setf major-entry (list major new-minor-entry))
      (push major-entry (symbol-value storage)))
     ((and (setf minor-entry (assoc minor major-entry))
	   (not (assq 'test info))
	   (not (assq 'test minor-entry))
	   (equal (assq 'viewer info)
		  (assq 'viewer minor-entry)))
      ;; Replace a previous MINOR entry if it and the entry to be
      ;; added both do *not* have a ‘test’ associated in their info
      ;; alist and both use the same ‘viewer’ command.  This ignores
      ;; other fields in the previous entryʼs info alist: they will be
      ;; lost when the info alist in the cdr of the previous entry is
      ;; replaced with the new INFO alist.
      (setf (cdr minor-entry) info))
     (t
      ;; Add the new minor entry to the existing major entry.
      (push new-minor-entry (cdr major-entry))))))