mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-30 18:23:20 -07:00
Prefer settings from ~/.mailcap over system and Emacs settings
* doc/misc/emacs-mime.texi (mailcap): Document the variable and how mailcap chooses which viewer to use. * lisp/net/mailcap.el (mailcap-prefer-mailcap-viewers): New variable. (mailcap-mime-info): Use it.
This commit is contained in:
parent
712607b05a
commit
7e47d44da4
3 changed files with 41 additions and 4 deletions
|
|
@ -1845,11 +1845,23 @@ Interface functions:
|
|||
@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
|
||||
|
||||
|
||||
|
|
|
|||
14
etc/NEWS
14
etc/NEWS
|
|
@ -526,11 +526,23 @@ does not fit in a machine integer (Bug#30408).
|
|||
'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'.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,14 @@
|
|||
: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)
|
||||
|
|
@ -784,18 +792,23 @@ If NO-DECODE is non-nil, don't decode STRING."
|
|||
(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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue