Discussion:
Recent Emacs doesn't respect my mailcap
Lars Ingebrigtsen
2015-01-27 02:42:56 UTC
Permalink
Is that a bug or is it supposed to be that way?
A bug, I hope!
It was just me putting a non-existent viewer into the ~/.mailcap file,
so it was filtered out again later. So that bit works.

So the issue is really whether we should keep preferring Lisp-based
(internal) viewers over external ones, even though the user has
specified this in ~/.mailcap (or otherwise).

That way of sorting seems to have been in place since 1998. But is it a
good idea?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
Eric Abrahamsen
2015-01-27 03:01:08 UTC
Permalink
Post by Lars Ingebrigtsen
Is that a bug or is it supposed to be that way?
A bug, I hope!
It was just me putting a non-existent viewer into the ~/.mailcap file,
so it was filtered out again later. So that bit works.
So the issue is really whether we should keep preferring Lisp-based
(internal) viewers over external ones, even though the user has
specified this in ~/.mailcap (or otherwise).
That way of sorting seems to have been in place since 1998. But is it a
good idea?
In my use case, I've already told Gnus to view the PDF externally by
using `gnus-article-view-part-externally'. Given that, and the fact that
I've specified an external viewer in ~/.mailcap, it seems a little
perverse that I'm still stuck seeing it in Doc View. If I wanted to do
that, I could have just called `gnus-article-view-part'!
Lars Ingebrigtsen
2015-01-27 03:01:38 UTC
Permalink
Post by Eric Abrahamsen
In my use case, I've already told Gnus to view the PDF externally by
using `gnus-article-view-part-externally'. Given that, and the fact that
I've specified an external viewer in ~/.mailcap, it seems a little
perverse that I'm still stuck seeing it in Doc View. If I wanted to do
that, I could have just called `gnus-article-view-part'!
That does sound like a bug. Perhaps that command should filter out all
Lisp functions from `mailcap-mime-data'?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
Eric Abrahamsen
2015-01-27 03:59:24 UTC
Permalink
Post by Lars Ingebrigtsen
Post by Eric Abrahamsen
In my use case, I've already told Gnus to view the PDF externally by
using `gnus-article-view-part-externally'. Given that, and the fact that
I've specified an external viewer in ~/.mailcap, it seems a little
perverse that I'm still stuck seeing it in Doc View. If I wanted to do
that, I could have just called `gnus-article-view-part'!
That does sound like a bug. Perhaps that command should filter out all
Lisp functions from `mailcap-mime-data'?
Or put ~/.mailcap stuff at the front of the list, or maybe just don't
re-sort mailcap-mime-data. I don't think anything fancy needs to be done
-- it should be enough just to *not* mess with mailcap-mime-data. At
least users will have an easier time figuring out what's happening.

Dunno, really.
Lars Ingebrigtsen
2015-01-27 04:47:03 UTC
Permalink
Post by Eric Abrahamsen
Post by Lars Ingebrigtsen
Post by Eric Abrahamsen
In my use case, I've already told Gnus to view the PDF externally by
using `gnus-article-view-part-externally'. Given that, and the fact that
I've specified an external viewer in ~/.mailcap, it seems a little
perverse that I'm still stuck seeing it in Doc View. If I wanted to do
that, I could have just called `gnus-article-view-part'!
That does sound like a bug. Perhaps that command should filter out all
Lisp functions from `mailcap-mime-data'?
Or put ~/.mailcap stuff at the front of the list, or maybe just don't
re-sort mailcap-mime-data. I don't think anything fancy needs to be done
-- it should be enough just to *not* mess with mailcap-mime-data.
The `-externally' command should work different from the other command,
shouldn't it? Otherwise, what's the point of having two of these
commands?

This code is so old it's hard to remember what the rationale for all
this may have been. Perhaps people used to have huge ~/.mailcap files
installed by other programs, and that meant that all the nice internal
Emacs commands for dealing with stuff never got called?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
Eric Abrahamsen
2015-01-27 05:08:46 UTC
Permalink
Post by Lars Ingebrigtsen
Post by Eric Abrahamsen
Post by Lars Ingebrigtsen
Post by Eric Abrahamsen
In my use case, I've already told Gnus to view the PDF externally by
using `gnus-article-view-part-externally'. Given that, and the fact that
I've specified an external viewer in ~/.mailcap, it seems a little
perverse that I'm still stuck seeing it in Doc View. If I wanted to do
that, I could have just called `gnus-article-view-part'!
That does sound like a bug. Perhaps that command should filter out all
Lisp functions from `mailcap-mime-data'?
Or put ~/.mailcap stuff at the front of the list, or maybe just don't
re-sort mailcap-mime-data. I don't think anything fancy needs to be done
-- it should be enough just to *not* mess with mailcap-mime-data.
The `-externally' command should work different from the other command,
shouldn't it? Otherwise, what's the point of having two of these
commands?
Good point!
Post by Lars Ingebrigtsen
This code is so old it's hard to remember what the rationale for all
this may have been. Perhaps people used to have huge ~/.mailcap files
installed by other programs, and that meant that all the nice internal
Emacs commands for dealing with stuff never got called?
I really have no idea. Also, how does this interact with xdg/mimeapps
stuff? For handling external applications, I basically tell Emacs to
always use xdg-open, and then do the actual configuration in
~/.config/mimeapps.list, that way I'm using the same applications
system-wide.

But I think you're right, this code is probably tuned to the desktop as
it existed a decade ago...
Dave Goldberg
2015-01-28 01:54:54 UTC
Permalink
Post by Eric Abrahamsen
Post by Lars Ingebrigtsen
Post by Eric Abrahamsen
Post by Lars Ingebrigtsen
Post by Eric Abrahamsen
In my use case, I've already told Gnus to view the PDF externally by
using `gnus-article-view-part-externally'. Given that, and the fact that
I've specified an external viewer in ~/.mailcap, it seems a little
perverse that I'm still stuck seeing it in Doc View. If I wanted to do
that, I could have just called `gnus-article-view-part'!
That does sound like a bug. Perhaps that command should filter out all
Lisp functions from `mailcap-mime-data'?
Or put ~/.mailcap stuff at the front of the list, or maybe just don't
re-sort mailcap-mime-data. I don't think anything fancy needs to be done
-- it should be enough just to *not* mess with mailcap-mime-data.
The `-externally' command should work different from the other command,
shouldn't it? Otherwise, what's the point of having two of these
commands?
Good point!
So I've been silently grumbling about this issue for a couple months, but I've just gotten used to calling ...-view-part-interactively (from the context menu) and running acrobat reader. docview is really not an option at work (where most of my PDF dealings come from) since my company uses some of the more irritating PDF features like digital signatures. Whether that's done via view-part or view-part-externally (assuming there's a strong desire to have view-part favor an internal function) doesn't bother me but it would be nice if view-part-externally did what I told it to do.

Thanks,
--
Dave Goldberg
***@verizon.net
Lars Ingebrigtsen
2015-01-29 02:21:29 UTC
Permalink
Post by Dave Goldberg
So I've been silently grumbling about this issue for a couple months,
but I've just gotten used to calling ...-view-part-interactively (from
the context menu) and running acrobat reader. docview is really not
an option at work (where most of my PDF dealings come from) since my
company uses some of the more irritating PDF features like digital
signatures. Whether that's done via view-part or view-part-externally
(assuming there's a strong desire to have view-part favor an internal
function) doesn't bother me but it would be nice if
view-part-externally did what I told it to do.
Indeed. I don't understand this function at all.

So, it gets the method from `(mailcap-mime-info type)', which has this
default in most Emacsen:

(mailcap-mime-info "application/pdf")
=> doc-view-mode

And that's obviously not a string, so it calls
`gnus-mime-view-part-as-type' with a nil type, so you get prompted for a
type?

But if it does return a string, then `mm-display-part' is called with
the default handling method? (So we get an external viewer.)

Err... Am I totally misreading this, or is it kinda nonsensical?

(defun gnus-mime-view-part-externally (&optional handle)
"View the MIME part under point with an external viewer."
(interactive)
(gnus-article-check-buffer)
(let* ((handle (or handle (get-text-property (point) 'gnus-data)))
(mm-inlined-types nil)
(mail-parse-charset gnus-newsgroup-charset)
(mail-parse-ignored-charsets
(with-current-buffer gnus-summary-buffer
gnus-newsgroup-ignored-charsets))
(type (mm-handle-media-type handle))
(method (mailcap-mime-info type))
(mm-enable-external t))
(if (not (stringp method))
(gnus-mime-view-part-as-type
nil (lambda (type) (stringp (mailcap-mime-info type))))
(when handle
(mm-display-part handle nil t)))))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
Loading...