On 04/06/2022 20:42, Ihor Radchenko wrote:
Should we change the default file handlers to Emacs globally (unless
user customizes otherwise)? Should we continue efforts to work around
mailcap issues? Maybe there is yet another alternative generic way to
open files?
Ihor, back to your patch introducing invocation of the "file" utility.
To get consistent behavior it should be done much earlier, when it
becomes known that the file is not a remote one, not only as a part of
mailcap code path (perhaps as a fallback for a file with no extension).
Unfortunately it requires more work since Emacs mostly uses file
suffixes, not MIME types, so the determined type should be converted to
file extension to query e.g. auto-mode-alist.
Ideally both MIME type and file suffix should be taken into account
since e.g. .xpi mozilla extensions are recognized as regular zip archives.
Ihor Radchenko. [PATCH v3] Re: Bug in 9.5.3 org--file-default-apps. Mon,
30 May 2022 22:00:27 +0800.
https://list.orgmode.org/8735gr15ok.fsf@localhost
((remote . emacs)
(system . mailcap)
(t . mailcap))
So, is (3) following what you would expect from mailcap (regardless
whether it is incorrectly configured or not)? Wrong configuration of
mailcap is none of Org business - we need not to be "smart" and fix user
"errors". They may be deliberate.
I was trying to say that mailcap.el has some predefined associations
that are intended to handle some file types by Emacs instead of external
handlers configured in mailcap files, unless `mailcap-user-mime-data' or
`mailcap-prefer-mailcap-viewers' prescribes another behavior.
Max Nikulin writes:
I read implementation of `org-open-file' once more and now I see that
currently remote files can not be processed by mailcap code path even
with custom `org-file-apps', so thank you for explanation. In some cases
it may be handy to launch remote viewer from a host accessed through
ssh, but let's leave it aside.
This is exactly why you can always customize org-file-apps.
Have I missed something of `org-file-apps' are ignored for remote files?
P.S. Earlier it was discussed whether run-mailcap inspects file content
or relies solely on file suffix. A side note: originally mailcap
processes parts of mail messages and MIME type is specified by the
Cotntent-Type header. So handling of standalone files with no original
MIME type is not a really native way to use mailcap. On the other hand
sometimes there is no better way than reusing existing database.