a3daa34336da158555d96d670077eedb9eaeeb9cdiff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index d29abf3..f351d79 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -722,33 +722,43 @@ dired-shell-stuff-it ;; (coming from interactive P and currently ignored) to decide what to do. ;; Smart would be a way to access basename or extension of file names. (let* ((in-background (string-match "[ \t]*&[ \t]*\\'" command)) - (command (if in-background - (substring command 0 (match-beginning 0)) - command)) - (sequentially (string-match "[ \t]*;[ \t]*\\'" command)) - (command (if sequentially - (substring command 0 (match-beginning 0)) - command)) - (stuff-it - (if (or (string-match-p dired-star-subst-regexp command) - (string-match-p dired-quark-subst-regexp command)) - (lambda (x) - (let ((retval command)) - (while (string-match - "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval) - (setq retval (replace-match x t t retval 2))) - retval)) - (lambda (x) (concat command dired-mark-separator x))))) + (command (if in-background + (let ((cmd command)) + (while (string-match "[ \t]*[&]+[ \t]*\\'" cmd) + (setq cmd (substring cmd 0 (match-beginning 0)))) cmd) + command)) + (sequentially (string-match "[ \t]*;[ \t]*\\'" command)) + (command (if sequentially + (let ((cmd command)) + (while (string-match "[ \t]*[;]+[ \t]*\\'" cmd) + (setq cmd (substring cmd 0 (match-beginning 0)))) cmd) + command)) + (in-back-no-seq (and in-background (not sequentially))) + (stuff-it + (if (or (string-match-p dired-star-subst-regexp command) + (string-match-p dired-quark-subst-regexp command)) + (lambda (x) + (let ((retval command)) + (while (string-match + "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval) + (setq retval (replace-match x t t retval 2))) + retval)) + (lambda (x) (concat command dired-mark-separator x))))) (concat - (if on-each - (mapconcat stuff-it (mapcar 'shell-quote-argument file-list) - (if (and in-background (not sequentially)) "&" ";")) - (let ((files (mapconcat 'shell-quote-argument - file-list dired-mark-separator))) - (if (> (length file-list) 1) - (setq files (concat dired-mark-prefix files dired-mark-postfix))) - (funcall stuff-it files))) - (if in-background "&" "")))) + (cond (on-each + (format "%s%s" + (mapconcat stuff-it (mapcar 'shell-quote-argument file-list) + (or (and in-back-no-seq "&") + ";")) + (or (and in-back-no-seq "&\nwait"); Wait for background jobs finish. + ""))) + (t + (let ((files (mapconcat 'shell-quote-argument + file-list dired-mark-separator))) + (when (cdr file-list) + (setq files (concat dired-mark-prefix files dired-mark-postfix))) + (funcall stuff-it files)))) + (or (and in-background "&") "")))) ;; This is an extra function so that it can be redefined by ange-ftp. ;;;###autoload