0

I seem to remember that I used to be able to press RET on a PDF attachment button in a Gnus article and have it open with pdf-tools. It's not working now, when I press RET I get prompted to save the PDF somewhere (after which I can use find-file to view it with pdf-tools). The prompt says "Save MIME part to:", just like when pressing o on the button (which runs gnus-mime-save-part). The same thing happens with E (gnus-mime-view-part-internally), which I also wouldn't expect.

Using either c or K c (the oddly named gnus-mime-copy-part and gnus-copy-article-part) does open the PDF attachment in a new buffer using pdf-tools, so a simple workaround would be to just use c instead of RET or E. But I really seem to remember that RET used to work (but I don't remember when it worked: I stopped using Gnus for a while, I'm probably not on the same versions of Emacs, Gnus and pdf-tools) and I don't know what changed.

Am I misremembering? Did this work at some point? How can I fix it?

I'm using Emacs 28.0.50, Gnus 5.13 and pdf-tools-20200214 from MELPA.

1

I just tested this on my setup and everything works the way you remember. I pressed RET on a pdf attachment from gnus (which runs gnus-article-press-button) and it got opened in a pdf-tools buffer.

I'm on GNU Emacs 26.3, Gnus 5.13 and pdf-tools 0.90 - all of them provided by the Guix package manager.

Let me share with you my pdf-tools config (in case that can be of any help).

(use-package pdf-tools
  :when window-system
  :custom (pdf-view-midnight-colors '("#ffffff" . "#000000"))
  :config
  ;; (setq image-scaling-factor 1) ; Emacs 27 needs this
  ;; this is a hack so that I can use docview links in org-mode
  (defalias 'doc-view-goto-page 'pdf-view-goto-page)
  :mode ("\\.pdf\\'" . pdf-view-mode)
  :hook
  ((pdf-view-mode-hook . pdf-view-fit-height-to-window)
   (pdf-view-mode-hook . pdf-links-minor-mode)
   (pdf-view-mode-hook . pdf-annot-minor-mode)
   (pdf-view-mode-hook . pdf-view-auto-slice-minor-mode)
   (pdf-view-mode-hook . (lambda ()
                           (when (eq
                                  (frame-parameter nil 'background-mode)
                                  'dark)
                             (pdf-view-midnight-minor-mode))))))
| improve this answer | |
0

See https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/master/gnus-guide-en.org#open-attachment

Quoted from article,

Move focus over the attachment and press Enter or M-x gnus-article-press-button.

The variable mailcap-mime-data defines the program to open the attachment.

You can tweak the variable on Windows or macOS.

On Linux, run M-x mailcap-parse-mailcaps to load data from ~/.mailcap into mailcap-mime-data instead of modifying mailcap-mime-data directly.
| improve this answer | |
  • Are you suggesting I add a line to ~/.mailcap using emacsclient to open PDFs? That sounds like it would work but I'm pretty sure I didn't do that before. – Omar Apr 2 at 7:16
  • mailcap-parse-mailcaps can parse ~/.mailcap so Emacs Gnus knows which application should run when opening attachment. – chen bin Apr 2 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.