1

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
  • Omar, take a look at my edited reply below. Thanks.
    – aadcg
    Nov 10, 2020 at 7:24

2 Answers 2

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))))))

Edit: I'm on GNU Emacs 27.1 and I'm facing the same issue that you describe. I tried to have a look at the git repository to try to understand what happened but I couldn't figure out. Anyway you can find a possible solution below:

(use-package gnus-art
  :commands gnus-mime-button-map
  :bind (:map gnus-mime-button-map
              ("RET" . gnus-mime-copy-part)))
1
  • Thanks for the edit. I don't think I need it anymore since I've grown accustomed to the default binding of c for gnus-mime-copy-part.
    – Omar
    Nov 11, 2020 at 3:32
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.
2
  • 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, 2020 at 7:16
  • mailcap-parse-mailcaps can parse ~/.mailcap so Emacs Gnus knows which application should run when opening attachment.
    – chen bin
    Apr 2, 2020 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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