diff options
| author | Lars Ingebrigtsen | 2021-06-01 08:55:06 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-06-01 08:55:06 +0200 |
| commit | 85e17196fa2b6333fbce7fdac1e2e17b045b91ae (patch) | |
| tree | fd83dd76ddb6ba859d587d5946dc3d93da99ff8b | |
| parent | 78f885f3702704300531f71dc3bc3f6613d0ce72 (diff) | |
| download | emacs-85e17196fa2b6333fbce7fdac1e2e17b045b91ae.tar.gz 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.
| -rw-r--r-- | doc/misc/emacs-mime.texi | 5 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/net/mailcap.el | 23 |
3 files changed, 32 insertions, 0 deletions
diff --git a/doc/misc/emacs-mime.texi b/doc/misc/emacs-mime.texi index 0cf5ba96506..7cd3e5f5828 100644 --- a/doc/misc/emacs-mime.texi +++ b/doc/misc/emacs-mime.texi | |||
| @@ -1870,6 +1870,11 @@ A customizable list of viewers that take preference over | |||
| 1870 | Interface functions: | 1870 | Interface functions: |
| 1871 | 1871 | ||
| 1872 | @table @code | 1872 | @table @code |
| 1873 | @item mailcap-view-file | ||
| 1874 | @findex mailcap-view-file | ||
| 1875 | Prompt for a file name, and start a viewer applicable for the file | ||
| 1876 | type in question. | ||
| 1877 | |||
| 1873 | @item mailcap-parse-mailcaps | 1878 | @item mailcap-parse-mailcaps |
| 1874 | @findex mailcap-parse-mailcaps | 1879 | @findex mailcap-parse-mailcaps |
| 1875 | @vindex mailcap-prefer-mailcap-viewers | 1880 | @vindex mailcap-prefer-mailcap-viewers |
| @@ -1991,6 +1991,10 @@ Shift while typing 'C-a', i.e. 'C-S-a', will now highlight the text. | |||
| 1991 | 1991 | ||
| 1992 | ** Miscellaneous | 1992 | ** Miscellaneous |
| 1993 | 1993 | ||
| 1994 | *** New command 'mailcap-view-file'. | ||
| 1995 | This command will open a viewer based on the file type, as determined | ||
| 1996 | by ~/.mailcap and related files and variables. | ||
| 1997 | |||
| 1994 | +++ | 1998 | +++ |
| 1995 | *** New command 'C-x C-k Q' to force redisplay in keyboard macros. | 1999 | *** New command 'C-x C-k Q' to force redisplay in keyboard macros. |
| 1996 | 2000 | ||
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." | |||
| 1156 | (mailcap--async-shell method file)) | 1156 | (mailcap--async-shell method file)) |
| 1157 | (funcall method)))) | 1157 | (funcall method)))) |
| 1158 | 1158 | ||
| 1159 | (defun mailcap-view-file (file) | ||
| 1160 | "View FILE according to rules given by the mailcap system. | ||
| 1161 | This normally involves executing some external program to display | ||
| 1162 | the file. | ||
| 1163 | |||
| 1164 | See \"~/.mailcap\", `mailcap-mime-data' and related files and variables." | ||
| 1165 | (interactive "fOpen file with mailcap: ") | ||
| 1166 | (setq file (expand-file-name file)) | ||
| 1167 | (mailcap-parse-mailcaps) | ||
| 1168 | (let ((command (mailcap-mime-info | ||
| 1169 | (mailcap-extension-to-mime (file-name-extension file))))) | ||
| 1170 | (unless command | ||
| 1171 | (error "No viewer for %s" (file-name-extension file))) | ||
| 1172 | ;; Remove quotes around the file name - we'll use shell-quote-argument. | ||
| 1173 | (while (string-match "['\"]%s['\"]" command) | ||
| 1174 | (setq command (replace-match "%s" t t command))) | ||
| 1175 | (setq command (replace-regexp-in-string | ||
| 1176 | "%s" | ||
| 1177 | (shell-quote-argument (convert-standard-filename file)) | ||
| 1178 | command | ||
| 1179 | nil t)) | ||
| 1180 | (start-process-shell-command command nil command))) | ||
| 1181 | |||
| 1159 | (provide 'mailcap) | 1182 | (provide 'mailcap) |
| 1160 | 1183 | ||
| 1161 | ;;; mailcap.el ends here | 1184 | ;;; mailcap.el ends here |