I want to open several types of files in Dired by different external applications.
.docfiles with LibreOffice
.jpgfiles with pinta
How do i configure this?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
Use Dired-x (standard library
(require 'dired-x) in your init file).
C-h v tells you:
dired-guess-shell-alist-useris a variable defined in
Its value is
User-defined alist of rules for suggested commands.
These rules take precedence over the predefined rules in the variable
dired-guess-shell-alist-default(to which they are prepended).
Each element of this list looks like
COMMANDcan either be a string or a Lisp expression that evaluates to a string.
If this expression needs to consult the name of the file for which the shell commands are being requested, it can access that file name as the variable
COMMANDs are given, the first one will be the default and the rest will be added temporarily to the history and can be retrieved with
REGEXPis matched case-sensitively.
You can customize this variable.
Then just use
& on files in Dired. Use
M-n to retrieve the default value of the program to run, which will come from your entries in the option value.
Using & from dired prompts to open each file with an external application.
Searching and trying, these elisp lines made it work:
(setq dired-guess-shell-alist-user '(("\\.pdf\\'" "evince") ("\\.doc\\'" "libreoffice") ("\\.docx\\'" "libreoffice") ("\\.ppt\\'" "libreoffice") ("\\.pptx\\'" "libreoffice") ("\\.xls\\'" "libreoffice") ("\\.xlsx\\'" "libreoffice") ("\\.jpg\\'" "pinta") ("\\.png\\'" "pinta") ("\\.java\\'" "idea")))