X-Git-Url: https://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=lisp%2Fmailcap.el;h=8e491d7d312268ab492c193da1859e5ada8752be;hp=cc7c9a3a7ab397ca8fd6625f7a5784a4b210ad8d;hb=HEAD;hpb=32291a1ab2e3ed43b47810a7f7146112998893d9 diff --git a/lisp/mailcap.el b/lisp/mailcap.el index cc7c9a3a7..8e491d7d3 100644 --- a/lisp/mailcap.el +++ b/lisp/mailcap.el @@ -1,7 +1,6 @@ ;;; mailcap.el --- MIME media types configuration -;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 1998-2016 Free Software Foundation, Inc. ;; Author: William M. Perry ;; Lars Magne Ingebrigtsen @@ -9,20 +8,18 @@ ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -85,7 +82,7 @@ This is a compatibility function for different Emacsen." (list lpr-switches) lpr-switches))) " ") - "Shell command (including switches) used to print Postscript files.") + "Shell command (including switches) used to print PostScript files.") ;; Postpone using defcustom for this as it's so big and we essentially ;; have to have two copies of the data around then. Perhaps just @@ -93,17 +90,15 @@ This is a compatibility function for different Emacsen." ;; files for the rest? -- fx (defvar mailcap-mime-data `(("application" - ("vnd.ms-excel" + ("vnd\\.ms-excel" (viewer . "gnumeric %s") (test . (getenv "DISPLAY")) (type . "application/vnd.ms-excel")) ("x-x509-ca-cert" (viewer . ssl-view-site-cert) - (test . (fboundp 'ssl-view-site-cert)) (type . "application/x-x509-ca-cert")) ("x-x509-user-cert" (viewer . ssl-view-user-cert) - (test . (fboundp 'ssl-view-user-cert)) (type . "application/x-x509-user-cert")) ("octet-stream" (viewer . mailcap-save-binary-file) @@ -132,29 +127,32 @@ This is a compatibility function for different Emacsen." (type . "application/x-tar")) ("x-latex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/x-latex")) ("x-tex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/x-tex")) ("latex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/latex")) ("tex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/tex")) ("texinfo" (viewer . texinfo-mode) - (test . (fboundp 'texinfo-mode)) (type . "application/tex")) ("zip" (viewer . mailcap-save-binary-file) (non-viewer . t) (type . "application/zip") ("copiousoutput")) + ("pdf" + (viewer . pdf-view-mode) + (type . "application/pdf") + (test . (eq window-system 'x))) + ("pdf" + (viewer . doc-view-mode) + (type . "application/pdf") + (test . (eq window-system 'x))) ("pdf" (viewer . "gv -safer %s") (type . "application/pdf") @@ -195,7 +193,6 @@ This is a compatibility function for different Emacsen." ("copiousoutput")) ("sieve" (viewer . sieve-mode) - (test . (fboundp 'sieve-mode)) (type . "application/sieve")) ("pgp-keys" (viewer . "gpg --import --interactive --verbose") @@ -216,11 +213,6 @@ This is a compatibility function for different Emacsen." (type . "message/rfc822")) ("rfc-*822" (viewer . vm-mode) - (test . (fboundp 'vm-mode)) - (type . "message/rfc822")) - ("rfc-*822" - (viewer . w3-mode) - (test . (fboundp 'w3-mode)) (type . "message/rfc822")) ("rfc-*822" (viewer . view-mode) @@ -255,28 +247,17 @@ This is a compatibility function for different Emacsen." (test . (eq window-system 'x)) ("needsx11"))) ("text" - ("plain" - (viewer . w3-mode) - (test . (fboundp 'w3-mode)) - (type . "text/plain")) ("plain" (viewer . view-mode) - (test . (fboundp 'view-mode)) (type . "text/plain")) ("plain" (viewer . fundamental-mode) (type . "text/plain")) ("enriched" (viewer . enriched-decode) - (test . (fboundp 'enriched-decode)) (type . "text/enriched")) - ("html" - (viewer . mm-w3-prepare-buffer) - (test . (fboundp 'w3-prepare-buffer)) - (type . "text/html")) ("dns" (viewer . dns-mode) - (test . (fboundp 'dns-mode)) (type . "text/dns"))) ("video" ("mpeg" @@ -293,8 +274,7 @@ This is a compatibility function for different Emacsen." ("archive" ("tar" (viewer . tar-mode) - (type . "archive/tar") - (test . (fboundp 'tar-mode))))) + (type . "archive/tar")))) "The mailcap structure is an assoc list of assoc lists. 1st assoc list is keyed on the major content-type 2nd assoc list is keyed on the minor content-type (which can be a regexp) @@ -315,9 +295,9 @@ attribute name (viewer, test, etc). This looks like: FLAG) Where VIEWERINFO specifies how the content-type is viewed. Can be -a string, in which case it is run through a shell, with -appropriate parameters, or a symbol, in which case the symbol is -`funcall'ed, with the buffer as an argument. +a string, in which case it is run through a shell, with appropriate +parameters, or a symbol, in which case the symbol is `funcall'ed if +and only if it exists as a function, with the buffer as an argument. TESTINFO is a test for the viewer's applicability, or nil. If nil, it means the viewer is always valid. If it is a Lisp function, it is @@ -337,7 +317,7 @@ nil means your home directory." :group 'mailcap) (defvar mailcap-poor-system-types - '(ms-dos ms-windows windows-nt win32 w32 mswindows) + '(ms-dos windows-nt) "Systems that don't have a Unix-like directory hierarchy.") ;;; @@ -425,7 +405,7 @@ MAILCAPS if set; otherwise (on Unix) use the path from RFC 1524, plus "/usr/local/etc/mailcap")))) (let ((fnames (reverse (if (stringp path) - (delete "" (split-string path path-separator)) + (split-string path path-separator t) path))) fname) (while fnames @@ -561,8 +541,11 @@ MAILCAPS if set; otherwise (on Unix) use the path from RFC 1524, plus results))) (defun mailcap-mailcap-entry-passes-test (info) - "Return non-nil if mailcap entry INFO passes its test clause. -Also return non-nil if no test clause is present." + "Replace the test clause of INFO itself with a boolean for some cases. +This function supports only `test -n $DISPLAY' and `test -z $DISPLAY', +replaces them with t or nil. As for others or if INFO has a interactive +spec (needsterm, needsterminal, or needsx11) but DISPLAY is not set, +the test clause will be unchanged." (let ((test (assq 'test info)) ; The test clause status) (setq status (and test (split-string (cdr test) " "))) @@ -660,10 +643,12 @@ to supply to the test." (let* ((test-info (assq 'test viewer-info)) (test (cdr test-info)) (otest test) - (viewer (cdr (assoc 'viewer viewer-info))) + (viewer (cdr (assq 'viewer viewer-info))) (default-directory (expand-file-name "~/")) - status parsed-test cache result) - (cond ((setq cache (assoc test mailcap-viewer-test-cache)) + status cache result) + (cond ((not (or (stringp viewer) (fboundp viewer))) + nil) ; Non-existent Lisp function + ((setq cache (assoc test mailcap-viewer-test-cache)) (cadr cache)) ((not test-info) t) ; No test clause (t @@ -760,10 +745,10 @@ If NO-DECODE is non-nil, don't decode STRING." major ; Major encoding (text, etc) minor ; Minor encoding (html, etc) info ; Other info - save-pos ; Misc. position during parse + ; save-pos ; Misc. position during parse (unused?) major-info ; (assoc major mailcap-mime-data) - minor-info ; (assoc minor major-info) - test ; current test proc. + ; minor-info ; (assoc minor major-info) (unused?) + ; test ; current test proc. (unused?) viewers ; Possible viewers passed ; Viewers that passed the test viewer ; The one and only viewer @@ -814,7 +799,10 @@ If NO-DECODE is non-nil, don't decode STRING." ;;; (defvar mailcap-mime-extensions - '(("" . "text/plain") + '(("" . "text/plain") + (".1" . "text/plain") ;; Manual pages + (".3" . "text/plain") + (".8" . "text/plain") (".abs" . "audio/x-mpeg") (".aif" . "audio/aiff") (".aifc" . "audio/aiff") @@ -830,6 +818,7 @@ If NO-DECODE is non-nil, don't decode STRING." (".css" . "text/css") (".dvi" . "application/x-dvi") (".diff" . "text/x-patch") + (".dpatch". "test/x-patch") (".el" . "application/emacs-lisp") (".eps" . "application/postscript") (".etx" . "text/x-setext") @@ -871,6 +860,7 @@ If NO-DECODE is non-nil, don't decode STRING." (".pict" . "image/pict") (".png" . "image/png") (".pnm" . "image/x-portable-anymap") + (".pod" . "text/plain") (".ppm" . "image/portable-pixmap") (".ps" . "application/postscript") (".qt" . "video/quicktime") @@ -907,7 +897,8 @@ If NO-DECODE is non-nil, don't decode STRING." (".zip" . "application/zip") (".ai" . "application/postscript") (".jpe" . "image/jpeg") - (".jpeg" . "image/jpeg")) + (".jpeg" . "image/jpeg") + (".org" . "text/x-org")) "An alist of file extensions and corresponding MIME content-types. This exists for you to customize the information in Lisp. It is merged with values from mailcap files by `mailcap-parse-mimetypes'.") @@ -943,7 +934,7 @@ If FORCE, re-parse even if already parsed." "/usr/local/etc/mime-types" "/usr/local/www/conf/mime-types")))) (let ((fnames (reverse (if (stringp path) - (delete "" (split-string path path-separator)) + (split-string path path-separator t) path))) fname) (while fnames @@ -1069,7 +1060,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) -;; arch-tag: 1fd4f9c9-c305-4d2e-9747-3a4d45baa0bd ;;; mailcap.el ends here