When I hit
RETURN on a filename in Dired, I'd like Emacs to automatically do one of several things, depending on the file's type:
1 - If it's a text file, I'd like to open the file in a new buffer in Emacs.
2 - If the filetype is listed in a user-configurable list of filetypes and external viewers, open the file in an external viewer associated with that filetype.
3 - If the filetype is not text and not in the above list, return an error saying the file is of an unknown type.
The above answers are insufficient for my needs, because:
1 - They require multiple keystrokes (at least
& and then
RETURN at the prompt), while I want this done with just a single keystroke, without any prompting.
2 - They won't open text files in Emacs, but will instead try to use external viewers for everything. I want text files opened in Emacs.
3 - They dispatch based on filename extensions, while I want to dispatch based on filetype (ie. as a result of using either the "
file" or "
mimetype" command on linux)
4 - They don't error-out if the filetype is not found in the list of known filetypes.