aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2016-04-08 17:45:16 +0300
committerEli Zaretskii2016-04-08 17:45:16 +0300
commitb2746dbf562dc4821bc111488b0e5b6ca5fc6061 (patch)
treefed336ff2aa107e3dacc34c771b647128a78cad5
parent102b643a00333ce70fbd7e1cee33de57fff40535 (diff)
downloademacs-b2746dbf562dc4821bc111488b0e5b6ca5fc6061.tar.gz
emacs-b2746dbf562dc4821bc111488b0e5b6ca5fc6061.zip
Teach Dired support parallel execution of commands on MS-Windows
* lisp/dired-aux.el (dired-shell-stuff-it): Support parallel-in-background execution of commands on MS-Windows. Test 'w32-shell-dos-semantics' instead of the underlying OS when determining whether addition of 'wait' is needed.
-rw-r--r--lisp/dired-aux.el23
1 files changed, 17 insertions, 6 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 52d3f061ec7..aafceeaa9e0 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -730,22 +730,34 @@ can be produced by `dired-get-marked-files', for example."
730 (command (if sequentially 730 (command (if sequentially
731 (substring command 0 (match-beginning 0)) 731 (substring command 0 (match-beginning 0))
732 command)) 732 command))
733 (parallel-in-background (and in-background (not sequentially))) 733 (parallel-in-background
734 (and in-background (not sequentially) (not (eq system-type 'ms-dos))))
735 (w32-shell (and (fboundp 'w32-shell-dos-semantics)
736 (w32-shell-dos-semantics)))
737 ;; The way to run a command in background in Windows shells
738 ;; is to use the START command. The /B switch means not to
739 ;; create a new window for the command.
740 (cmd-prefix (if w32-shell "start /b " ""))
741 ;; Windows shells don't support chaining with ";", they use
742 ;; "&" instead.
743 (cmd-sep (if (and (not w32-shell) (not parallel-in-background))
744 ";"
745 "&"))
734 (stuff-it 746 (stuff-it
735 (if (or (string-match-p dired-star-subst-regexp command) 747 (if (or (string-match-p dired-star-subst-regexp command)
736 (string-match-p dired-quark-subst-regexp command)) 748 (string-match-p dired-quark-subst-regexp command))
737 (lambda (x) 749 (lambda (x)
738 (let ((retval command)) 750 (let ((retval (concat cmd-prefix command)))
739 (while (string-match 751 (while (string-match
740 "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval) 752 "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval)
741 (setq retval (replace-match x t t retval 2))) 753 (setq retval (replace-match x t t retval 2)))
742 retval)) 754 retval))
743 (lambda (x) (concat command dired-mark-separator x))))) 755 (lambda (x) (concat cmd-prefix command dired-mark-separator x)))))
744 (concat 756 (concat
745 (cond (on-each 757 (cond (on-each
746 (format "%s%s" 758 (format "%s%s"
747 (mapconcat stuff-it (mapcar 'shell-quote-argument file-list) 759 (mapconcat stuff-it (mapcar 'shell-quote-argument file-list)
748 (or (and parallel-in-background "&") ";")) 760 cmd-sep)
749 ;; POSIX shells running a list of commands in the background 761 ;; POSIX shells running a list of commands in the background
750 ;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &]) 762 ;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &])
751 ;; return once cmd_N ends, i.e., the shell does not 763 ;; return once cmd_N ends, i.e., the shell does not
@@ -754,8 +766,7 @@ can be produced by `dired-get-marked-files', for example."
754 ;; the output of all the commands (Bug#23206). 766 ;; the output of all the commands (Bug#23206).
755 ;; Add 'wait' to force those POSIX shells to wait until 767 ;; Add 'wait' to force those POSIX shells to wait until
756 ;; all commands finish. 768 ;; all commands finish.
757 (or (and parallel-in-background 769 (or (and parallel-in-background (not w32-shell)
758 (not (memq system-type '(ms-dos windows-nt)))
759 "&wait") 770 "&wait")
760 ""))) 771 "")))
761 (t 772 (t