Commit 85e17196 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen
Browse files

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.
parent 78f885f3
......@@ -1870,6 +1870,11 @@ A customizable list of viewers that take preference over
Interface functions:
@table @code
@item mailcap-view-file
@findex mailcap-view-file
Prompt for a file name, and start a viewer applicable for the file
type in question.
@item mailcap-parse-mailcaps
@findex mailcap-parse-mailcaps
@vindex mailcap-prefer-mailcap-viewers
......@@ -1991,6 +1991,10 @@ Shift while typing 'C-a', i.e. 'C-S-a', will now highlight the text.
** Miscellaneous
*** New command 'mailcap-view-file'.
This command will open a viewer based on the file type, as determined
by ~/.mailcap and related files and variables.
*** New command 'C-x C-k Q' to force redisplay in keyboard macros.
......@@ -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))
(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
(shell-quote-argument (convert-standard-filename file))
nil t))
(start-process-shell-command command nil command)))
(provide 'mailcap)
;;; mailcap.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment