open with now works on files with spaces

This commit is contained in:
petrucci4prez 2018-08-28 17:48:27 -04:00
parent c2bbfdbda0
commit 354b73ea95
1 changed files with 34 additions and 31 deletions

View File

@ -290,8 +290,10 @@ multiple files at once for given MIMETYPE."
(seq-filter (lambda (a) (string-match ".*%[FU].*" (car a))) (nd/get-apps-from-mime mimetype))))
(defun nd/execute-desktop-command (cmd file)
"Opens FILE using CMD in separate process."
(call-process-shell-command (concat (replace-regexp-in-string "%[fuFU]" file cmd t) " &")))
"Opens FILE using CMD in separate process where CMD is from a
desktop file exec directive."
(let* ((cmd-arg (replace-regexp-in-string "%[fuFU]" file cmd t t)))
(call-process-shell-command (concat cmd-arg " &"))))
(defun nd/get-mime-type (file)
"Get the mime type of FILE."
@ -493,8 +495,9 @@ Keeping confirmation enabled does weird stuff with helm. Not ideal at the moment
"Open marked non-text files in external app via open-with dialog
according to mime types as listed in all available desktop files."
(interactive)
(let* ((marked-files (seq-filter #'file-regular-p (dired-get-marked-files)))
(file-mime-list (mapcar (lambda (f) (list f (nd/get-mime-type f))) marked-files)))
(let* ((mf (seq-filter #'file-regular-p (dired-get-marked-files)))
(qmf (mapcar #'shell-quote-argument mf))
(file-mime-list (mapcar (lambda (f) (list f (nd/get-mime-type f))) qmf)))
(if (= (length file-mime-list) 0)
(message "No files selected")