unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23206: 25.0.92; dired-shell-stuff-it: wait until all parallel jobs finish
@ 2016-04-03 13:02 Tino Calancha
  2016-04-03 15:03 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Tino Calancha @ 2016-04-03 13:02 UTC (permalink / raw)
  To: 23206

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]


Good (or morning afternoon evening night)

When `dired-do-shell-command' runs COMMAND over FILES in
parallel, the `shell-command' process may finish before all the
files have being processed.

emacs -Q ~

* / & du SPC -s RET
; If the number of lines in #<buffer *Async Shell Command*> is less
; than (1+ (length (dired-get-marked-files))) then NOT all files
; has being processed.

Attached patch fix this issue adding 'wait' at the end of COMMAND
when FILES are procesed in parallel.

In GNU Emacs 25.0.92.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
  of 2016-04-01 built on calancha-pc
Repository revision: a3daa34336da158555d96d670077eedb9eaeeb9c

[-- Attachment #2: Type: text/plain, Size: 3537 bytes --]

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-04-08 14:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-03 13:02 bug#23206: 25.0.92; dired-shell-stuff-it: wait until all parallel jobs finish Tino Calancha
2016-04-03 15:03 ` Eli Zaretskii
2016-04-03 16:38   ` Tino Calancha
2016-04-04  6:20     ` Tino Calancha
2016-04-04 17:25     ` Eli Zaretskii
2016-04-05  5:24       ` Tino Calancha
2016-04-05 14:59         ` Eli Zaretskii
2016-04-05 15:58           ` Tino Calancha
2016-04-08 14:06             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).