Gnus development mailing list
 help / color / mirror / Atom feed
From: Andrew Cohen <acohen@ust.hk>
To: ding@gnus.org
Subject: Re: View docx/doc documents from Gnus in Docview
Date: Tue, 12 Sep 2023 08:37:36 +0800	[thread overview]
Message-ID: <87ledcns4v.fsf@ust.hk> (raw)
In-Reply-To: <877cowod9g.fsf@ericabrahamsen.net>

>>>>> "EA" == Eric Abrahamsen <eric@ericabrahamsen.net> writes:

    EA> The version of `doc-view-set-doc-type` in master looks almost
    EA> exactly like what you've posted here, with the exception of the
    EA> let* for (buffer-file-name (or buffer-file-name (buffer-name
    EA> (current-buffer)))) at the top. Could someone have fixed it in
    EA> the meantime?

No, that small change is exactly the fix!

When viewing a mime part in gnus, the buffer holding the document
doesn't have an underlying file so 'buffer-file-name is nil (unlike when
invoking doc-view from dired). Thus the whole first part of the routine
is skipped, and only the first few bytes are looked at to determine the
file type (which just decides it is a zip file, and ends up with 'epub).

The change I made relies on the fact that the buffer that holds the
content for doc-view gets a name from the "filename" attribute of the
mime part in the message (i.e. the buffer gets named something like
"*mm* junk.docx") and this can be used to infer the file extension. Then
things work just like they would if doc-view had been invoked for a
buffer holding an actual file.

After some thought I believe that this is worth pushing to master, which
I'll try to do when I get some time.

Best,
Andy
-- 
Andrew Cohen



  reply	other threads:[~2023-09-12  0:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 16:18 Björn Bidar
2023-09-10 16:20 ` Eric Abrahamsen
2023-09-10 19:50   ` Björn Bidar
2023-09-10 21:43     ` Eric Abrahamsen
2023-09-11  2:53       ` Andrew Cohen
2023-09-11 17:01         ` Eric Abrahamsen
2023-09-12  0:37           ` Andrew Cohen [this message]
2023-09-12 17:59             ` Eric Abrahamsen
2023-09-11 19:01         ` Björn Bidar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ledcns4v.fsf@ust.hk \
    --to=acohen@ust.hk \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).