Diredで外部アプリケーションを使って画像ファイルを開く方法は?
Linux Mint 19、Emacs 26.1画像を表示するための別のアプリがあります。描画、画像ビューア、XnViewなど。
そして、Nemoファイルマネージャーから、このアプリで画像を開くことに成功しました。いいね。
しかし、私はDiredモードで画像を開きたいです。だから私のinit.elにはこれがあります:
(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))
したがって、diredモードで画像ファイルの上にEnterキーを押すと、次のメッセージが表示され、何も起こりません。
openwith-file-handler: Opened DEEPSP_little.JPG in external program
Diredモードのときに外部アプリで画像を開きたい。
回答
標準ライブラリをロードしdired-x.el
、オプションをカスタマイズし、Diredでdired-guess-shell-alist-user
使用するだけ!
で、必要なプログラムを開くことができます。デフォルトでは、マークされたファイルまたは単一のファイルで、必要な画像ファイル拡張子を開くことができます。
C-x v dired-guess-shell-alist-user
:
dired-guess-shell-alist-user
で定義された変数ですdired-x.el
。その値はゼロです
ドキュメンテーション:
提案されたコマンドのルールのユーザー定義リスト。
これらのルールは、変数内の事前定義されたルール
dired-guess-shell-alist-default
(先頭に追加される)よりも優先されます。このリストの各要素は次のようになります
(REGEXP COMMAND...)
ここで、それぞれ
COMMAND
は文字列または文字列に評価されるLisp式のいずれかです。この式は、シェルコマンドが要求されているファイルの名前を参照する必要がある場合、変数としてそのファイル名にアクセスできますfile
。複数
COMMAND
のが指定されている場合、最初のものがデフォルトになり、残りは一時的に履歴に追加され、M-x previous-history-element
(M-p
)で取得できます。この変数
dired-guess-shell-case-fold-search
は、REGEXPが大文字と小文字を区別して一致するかどうかを制御します。この変数はカスタマイズできます。
私は解決策を見つけました。
次のようなターミナルでアプリXnViewをインストールする必要があります。
sudo apt-get install gdebi
wget http://download.xnview.com/XnViewMP-linux-x64.deb
sudo gdebi XnViewMP-linux-x64.deb
そして、画像の成功はDiredモードで開きます。そして、XnViewアプリで画像を開きます。
いいね。
init.elで追加の設定を行う必要はありません
これで十分です:
(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))