unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <f92capac@gmail.com>
To: 23206@debbugs.gnu.org
Subject: bug#23206: 25.0.92; dired-shell-stuff-it: wait until all parallel jobs finish
Date: Sun, 3 Apr 2016 22:02:17 +0900 (JST)	[thread overview]
Message-ID: <alpine.LRH.2.20.1604032154180.28935@calancha-ilc.kek.jp> (raw)

[-- 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

             reply	other threads:[~2016-04-03 13:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-03 13:02 Tino Calancha [this message]
2016-04-03 15:03 ` bug#23206: 25.0.92; dired-shell-stuff-it: wait until all parallel jobs finish 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.20.1604032154180.28935@calancha-ilc.kek.jp \
    --to=f92capac@gmail.com \
    --cc=23206@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).