[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 7747e23 1/2: Make it easier to use mailcap for view
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 7747e23 1/2: Make it easier to use mailcap for viewing single files |
Date: |
Fri, 05 Dec 2014 15:52:04 +0000 |
branch: master
commit 7747e23ecd6c7b140a67812ad22421ef426a7a24
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>
Make it easier to use mailcap for viewing single files
* mailcap.el (mailcap-mime-data): Add doc-view-mode as a viewer for
PDFs.
(mailcap-view-mime): New function.
---
lisp/gnus/ChangeLog | 6 ++++++
lisp/gnus/mailcap.el | 16 ++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index c526b53..0909418 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-05 Lars Magne Ingebrigtsen <address@hidden>
+
+ * mailcap.el (mailcap-mime-data): Add doc-view-mode as a viewer for
+ PDFs.
+ (mailcap-view-mime): New function.
+
2014-12-01 Glenn Morris <address@hidden>
* gnus-cloud.el (gnus-cloud): Add :version tag.
diff --git a/lisp/gnus/mailcap.el b/lisp/gnus/mailcap.el
index 4f1bdf4..1a1a992 100644
--- a/lisp/gnus/mailcap.el
+++ b/lisp/gnus/mailcap.el
@@ -153,6 +153,10 @@ This is a compatibility function for different Emacsen."
(type . "application/zip")
("copiousoutput"))
("pdf"
+ (viewer . doc-view-mode)
+ (type . "application/pdf")
+ (test . (eq window-system 'x)))
+ ("pdf"
(viewer . "gv -safer %s")
(type . "application/pdf")
(test . window-system)
@@ -1060,6 +1064,18 @@ If FORCE, re-parse even if already parsed."
common-mime-info)))))
commands))
+(defun mailcap-view-mime (type)
+ "View the data in the current buffer that has MIME type TYPE.
+`mailcap-mime-data' determines the method to use."
+ (let ((method (mailcap-mime-info type)))
+ (if (stringp method)
+ (shell-command-on-region (point-min) (point-max)
+ ;; Use stdin as the "%s".
+ (format method "-")
+ (current-buffer)
+ t)
+ (funcall method))))
+
(provide 'mailcap)
;;; mailcap.el ends here