2

Linux Mint 19, Emacs 26.1 I has different app to show image.Like Drawing, Image Viewer, XnView.

And from Nemo file manager I success open any images by this app. Nice.

But I want to open image in Dired mode. So in my init.el I has this:

(when (require 'openwith nil 'noerror)
  (setq openwith-associations
        (list 
     (list (openwith-make-extension-regexp '("doc" "docx" "rtf")) "word" '(file))
     (list (openwith-make-extension-regexp '("mpg" "mpeg" "mp3" "mp4" "avi" "wmv" "wav" "mov" "mkv")) "vlc" '(file))
     (list (openwith-make-extension-regexp '("pdf")) "FoxitReader" '(file))
     (list (openwith-make-extension-regexp '("bmp" "gif" "jpeg" "jpg" "png" "tif")) "xnview" '(file))
     (list (openwith-make-extension-regexp '("rdp")) "Remote Desctop Connection" '(file))
     (list (openwith-make-extension-regexp '("xls" "xlsx")) "excel" '(file))
         ))
  (openwith-mode 1))

So when I'm in dired mode and press Enter over image file I get the next message and nothing happend:

openwith-file-handler: Opened DEEPSP_little.JPG in external program

I want to open image by external app when I'm in dired mode.

1

Just load standard library dired-x.el, customize option dired-guess-shell-alist-user, and use ! in Dired, to open whatever program you want, by default on the marked files or a single file, for whatever image-file extensions you want.

C-x v dired-guess-shell-alist-user:

dired-guess-shell-alist-user is a variable defined in dired-x.el.

Its value is nil

Documentation:

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

(REGEXP COMMAND...)

where each COMMAND can 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 file.

If several 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 M-x previous-history-element (M-p) .

The variable dired-guess-shell-case-fold-search controls whether REGEXP is matched case-sensitively.

You can customize this variable.

| improve this answer | |
0

I found solution.

I must install app XnView by terminal like this:

sudo apt-get install gdebi

wget http://download.xnview.com/XnViewMP-linux-x64.deb

sudo gdebi XnViewMP-linux-x64.deb

And then image success open in Dired mode. And open image by XnView app.

Nice.

Not need to do any additional setting in init.el

This is enough:

(when (require 'openwith nil 'noerror)
  (setq openwith-associations
        (list 
     (list (openwith-make-extension-regexp '("doc" "docx" "rtf")) "word" '(file))
     (list (openwith-make-extension-regexp '("mpg" "mpeg" "mp3" "mp4" "avi" "wmv" "wav" "mov" "mkv")) "vlc" '(file))
     (list (openwith-make-extension-regexp '("pdf")) "FoxitReader" '(file))
     (list (openwith-make-extension-regexp '("bmp" "gif" "jpeg" "jpg" "png" "tif")) "xnview" '(file))
     (list (openwith-make-extension-regexp '("rdp")) "Remote Desctop Connection" '(file))
     (list (openwith-make-extension-regexp '("xls" "xlsx")) "excel" '(file))
         ))
  (openwith-mode 1))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.