I recently started using gnus to view my emails. Opening attachments is still the most annoying part for me and I am trying to address that.

The behaviour I would like is: If the attachment is text-based then open in an emacs buffer in the same instance I am using, otherwise open using the system's xdg-open.

According to emacswiki, I created a file ~/.mailcap with the single line

    application/*; xdg-open %s

But then this line is just added to the application list in /etc/mailcap, which I have no control over, and I have to select xdg-open in the list that is shown to me every time I try to open an attachment. How can I prevent gnus from reading that file and instead directly open an attachment with xdg-open?

Also, how do I get text files to open in a buffer?

Finally, is there a way to open the attachment without going all the way to the file name in the email? Perhaps by showing a list of attachment and letting me choose one of them?

1 Answer 1


So many questions at once.

  • emacs-27 will prefer ~/.mailcap entries to the system ones. See Mailcap precedence for details. You can build the emacs master branch from source to pick up those changes.

  • The answer to your third question is: Check out the K- bindings in the Summary buffer:

    K C             gnus-article-view-part-as-charset
    K E             gnus-article-encrypt-body
    K H             gnus-article-browse-html-article
    K O             gnus-article-save-part-and-strip
    K b             gnus-summary-display-buttonized
    K c             gnus-article-copy-part
    K d             gnus-article-delete-part
    K e             gnus-article-view-part-externally
    K i             gnus-article-inline-part
    K j             gnus-article-jump-to-part
    K m             gnus-summary-repair-multipart
    K o             gnus-article-save-part
    K r             gnus-article-replace-part
    K t             gnus-article-view-part-as-type
    K v             gnus-article-view-part
    K |             gnus-article-pipe-part

(they all take numerical prefix arguments to specify which part you're talking about)

  • For youre second question, you're looking for the unfortunately-named gnus-article-copy-part, which will create a buffer containing that part.

Your Answer

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

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