@table @code
@item mailcap-parse-mailcaps
@findex mailcap-parse-mailcaps
+@vindex mailcap-prefer-mailcap-viewers
Parse the @file{~/.mailcap} file.
@item mailcap-mime-info
Takes a @acronym{MIME} type as its argument and returns the matching viewer.
+The @code{mailcap-prefer-mailcap-viewers} variable controls which
+viewer is chosen. The default non-@code{nil} value means that
+settings from @file{~/.mailcap} is preferred over system-wide or
+Emacs-provided viewer settings.
+
+If @code{nil}, Emacs-provided viewer settings have precedence. Next,
+the most specific viewer has precedence over less specific settings,
+no matter if they're system-provided or private, so @string{image/gif}
+in @file{/etc/mailcap} will ``win'' over a @string{image/*} setting in
+@file{~/.mailcap}.
+
@end table
'json-insert', 'json-parse-string', and 'json-parse-buffer'. These
are implemented in C using the Jansson library.
+** Mailcap
+
---
-** The new function `mailcap-file-name-to-mime-type' has been added.
+*** The new function `mailcap-file-name-to-mime-type' has been added.
It's a simple convenience function for looking up MIME types based on
file name extensions.
+*** The default way the list of possible external viewers for MIME
+types is sorted and chosen has changed. Earlier, the most specific
+viewer was chosen, even if there was a general override in ~/.mailcap.
+For instance, if /etc/mailcap has an entry for image/gif, that one
+will be chosen even if you have an entry for image/* in your
+~/.mailcap file. But with the new method, entries from ~/.mailcap
+overrides all system and Emacs-provided defaults. To get the old
+method back, set `mailcap-prefer-mailcap-viewers' to nil
+
+
+++
** The new function 'read-answer' accepts either long or short answers
depending on the new customizable variable 'read-answer-short'.
:version "21.1"
:group 'mime)
+(defcustom mailcap-prefer-mailcap-viewers t
+ "If non-nil, prefer viewers specified in ~/.mailcap.
+If nil, the most specific viewer will be chosen, even if there is
+a general override in ~/.mailcap. For instance, if /etc/mailcap
+has an entry for \"image/gif\", that one will be chosen even if
+you have an entry for \"image/*\" in your ~/.mailcap file."
+ :type 'boolean)
+
(defvar mailcap-parse-args-syntax-table
(let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
(modify-syntax-entry ?' "\"" table)
(setq passed (list viewer))
;; None found, so heuristically select some applicable viewer
;; from `mailcap-mime-data'.
+ (mailcap-parse-mailcaps)
(setq major (split-string (car ctl) "/"))
(setq minor (cadr major)
major (car major))
(when (setq major-info (cdr (assoc major mailcap-mime-data)))
(when (setq viewers (mailcap-possible-viewers major-info minor))
- (setq info (mapcar (lambda (a) (cons (symbol-name (car a))
- (cdr a)))
+ (setq info (mapcar (lambda (a)
+ (cons (symbol-name (car a)) (cdr a)))
(cdr ctl)))
(dolist (entry viewers)
(when (mailcap-viewer-passes-test entry info)
(push entry passed)))
- (setq passed (sort passed 'mailcap-viewer-lessp))
+ ;; The data is in "logical" order; entries from ~/.mailcap
+ ;; are first, so we don't need to do any sorting if the
+ ;; user wants ~/.mailcap to be preferred.
+ (unless mailcap-prefer-mailcap-viewers
+ (setq passed (sort passed 'mailcap-viewer-lessp)))
(setq viewer (car passed))))
(when (and (stringp (cdr (assq 'viewer viewer)))
passed)