Ben Bacarisse
2018-09-23 02:52:03 UTC
Short version:
How can I get Emacs (specifically mailcap.el) to prioritise my system's
or my personal mailcap settings?
Gnus, for example, opens PDF files in doc-view-mode rather than using
the program specified in /etc/mailcap or ~/.mailcap.
In more detail...
From an quick examination of mailcap.el it seems that an initial set of
mailcap data, given an explicit list assigned to mailcap-mime-data, is
augmented by reading the system's mailcap files along with the user's
mailcap. However, the initial data do not simply provide a default
back-stop because many of them use Emacs modes that are, for most
people, to be preferred. This is achieved by sorting the list of
possible matches with a predicate that favours Lisp symbols over strings
(mailcap-viewer-lessp). Thus '(viewer doc-view-mode) will win over
'(viewer "/usr/bin/mupdf %s") or, indeed, over any setting from the
parsed files.
I have a crude solution. If, after mailcap is loaded, I manually
execute
(setq mailcap-mime-data nil)
(mailcap-parse-mailcaps nil t)
only the parsed entries will be seen as the initial value of
mailcap-mime-data is lost. But this is not a good solution not least
because I may want some of these "built-in" handlers -- I haven't
checked them all.
What is the proper way to deal with this?
If there isn't a neat solution, maybe I can hook into the mailcap system
to get the behaviour I want. What's the best way to do that? Do I need
to resort to advice-add?
How can I get Emacs (specifically mailcap.el) to prioritise my system's
or my personal mailcap settings?
Gnus, for example, opens PDF files in doc-view-mode rather than using
the program specified in /etc/mailcap or ~/.mailcap.
In more detail...
From an quick examination of mailcap.el it seems that an initial set of
mailcap data, given an explicit list assigned to mailcap-mime-data, is
augmented by reading the system's mailcap files along with the user's
mailcap. However, the initial data do not simply provide a default
back-stop because many of them use Emacs modes that are, for most
people, to be preferred. This is achieved by sorting the list of
possible matches with a predicate that favours Lisp symbols over strings
(mailcap-viewer-lessp). Thus '(viewer doc-view-mode) will win over
'(viewer "/usr/bin/mupdf %s") or, indeed, over any setting from the
parsed files.
I have a crude solution. If, after mailcap is loaded, I manually
execute
(setq mailcap-mime-data nil)
(mailcap-parse-mailcaps nil t)
only the parsed entries will be seen as the initial value of
mailcap-mime-data is lost. But this is not a good solution not least
because I may want some of these "built-in" handlers -- I haven't
checked them all.
What is the proper way to deal with this?
If there isn't a neat solution, maybe I can hook into the mailcap system
to get the behaviour I want. What's the best way to do that? Do I need
to resort to advice-add?
--
Ben.
Ben.