mirror of
https://github.com/balkian/dotfiles.git
synced 2024-11-22 04:02:28 +00:00
26 lines
1.0 KiB
EmacsLisp
26 lines
1.0 KiB
EmacsLisp
(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)
|