diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-06-01 08:55:06 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-06-01 08:55:06 +0200 |
commit | 85e17196fa2b6333fbce7fdac1e2e17b045b91ae (patch) | |
tree | fd83dd76ddb6ba859d587d5946dc3d93da99ff8b /lisp | |
parent | 78f885f3702704300531f71dc3bc3f6613d0ce72 (diff) | |
download | emacs-85e17196fa2b6333fbce7fdac1e2e17b045b91ae.tar.gz emacs-85e17196fa2b6333fbce7fdac1e2e17b045b91ae.tar.bz2 emacs-85e17196fa2b6333fbce7fdac1e2e17b045b91ae.zip |
Add a new command `mailcap-view-file'
* doc/misc/emacs-mime.texi (mailcap): Document it (bug#12972).
* lisp/net/mailcap.el (mailcap-view-file): New command.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/net/mailcap.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index 3097c9a671e..54f7f416aba 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -1156,6 +1156,29 @@ current buffer after passing its contents to the shell command." (mailcap--async-shell method file)) (funcall method)))) +(defun mailcap-view-file (file) + "View FILE according to rules given by the mailcap system. +This normally involves executing some external program to display +the file. + +See \"~/.mailcap\", `mailcap-mime-data' and related files and variables." + (interactive "fOpen file with mailcap: ") + (setq file (expand-file-name file)) + (mailcap-parse-mailcaps) + (let ((command (mailcap-mime-info + (mailcap-extension-to-mime (file-name-extension file))))) + (unless command + (error "No viewer for %s" (file-name-extension file))) + ;; Remove quotes around the file name - we'll use shell-quote-argument. + (while (string-match "['\"]%s['\"]" command) + (setq command (replace-match "%s" t t command))) + (setq command (replace-regexp-in-string + "%s" + (shell-quote-argument (convert-standard-filename file)) + command + nil t)) + (start-process-shell-command command nil command))) + (provide 'mailcap) ;;; mailcap.el ends here |