1
0
mirror of https://github.com/balkian/dotfiles.git synced 2024-11-14 16:52:29 +00:00
dotfiles/emacs.d/config/config-dired.el

26 lines
1.0 KiB
EmacsLisp
Raw Normal View History

2015-04-06 21:35:55 +00:00
(defun ergoemacs-open-in-external-app ()
"Open the current file or dired marked files in external app."
(interactive)
(let ( doIt
(myFileList
(cond
((string-equal major-mode "dired-mode") (dired-get-marked-files))
(t (list (buffer-file-name))) ) ) )
(setq doIt (if (<= (length myFileList) 5)
t
(y-or-n-p "Open more than 5 files?") ) )
(when doIt
(cond
((string-equal system-type "windows-nt")
(mapc (lambda (fPath) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" fPath t t)) ) myFileList)
)
((string-equal system-type "darwin")
(mapc (lambda (fPath) (shell-command (format "open \"%s\"" fPath)) ) myFileList) )
((string-equal system-type "gnu/linux")
(mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "xdg-open" fPath)) ) myFileList) ) ) ) ) )
(define-key dired-mode-map (kbd "e") 'ergoemacs-open-in-external-app)
(provide 'config-dired)