emacs - dired start process
authorPeng Li <seudut@gmail.com>
Tue, 2 Aug 2016 11:50:33 +0000 (19:50 +0800)
committerPeng Li <seudut@gmail.com>
Tue, 2 Aug 2016 11:50:33 +0000 (19:50 +0800)
emacs.d/config.org

index 4bae6f0..c35e2fe 100644 (file)
@@ -1545,6 +1545,34 @@ here on Mac, just use "open" commands to pen =.pdf=,  =.html= and image files
           ("\\.html?\\'" "open")
           ("\\.dmg\\'" "open")
           ("\\.cue?\\'" "audacious")))
+
+
+  (defun sd/dired-start-process (cmd &optional file-list)
+    (interactive
+     (let ((files (dired-get-marked-files
+                   t current-prefix-arg)))
+       (list
+        (unless (eq system-type 'windows-nt)
+          (dired-read-shell-command "& on %s: "
+                                    current-prefix-arg files))
+        files)))
+    
+    (if (eq system-type 'windows-nt)
+        (dolist (file file-list)
+          (w32-shell-execute "open" (expand-file-name file)))
+      (let (list-switch)
+        (start-process
+         cmd nil shell-file-name
+         shell-command-switch
+         (format
+          "nohup 1>/dev/null 2>/dev/null %s \"%s\""
+          cmd
+          ;; (if (and (> (length file-list) 1)
+          ;;          (setq list-switch
+          ;;                (cadr (assoc cmd ora-dired-filelist-cmd))))
+          ;;     (format "%s %s" cmd list-switch)
+          ;;   cmd)
+          (mapconcat #'expand-file-name file-list "\" \""))))))
 #+END_SRC
 
 ** dired-hacks