From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#10598: 24.0.92; run dired-do-async-shell-command on multiple files individually Date: Sun, 15 Jul 2012 11:29:17 +0300 Organization: JURTA Message-ID: <87k3y51l7m.fsf@mail.jurta.org> References: <87liow9jdf.fsf@niu.edu> <87obtsqbiw.fsf@mail.jurta.org> <20255.60373.371008.208639@gargle.gargle.HOWL> <87394x8im1.fsf@mail.jurta.org> <20478.42579.593253.620476@lukas.physics.niu.edu> <871ukg9i6m.fsf@mail.jurta.org> <20479.59979.797807.988643@gargle.gargle.HOWL> <878vem8z9i.fsf@mail.jurta.org> <20482.30360.86756.671195@gargle.gargle.HOWL> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342341684 17060 80.91.229.3 (15 Jul 2012 08:41:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 15 Jul 2012 08:41:24 +0000 (UTC) Cc: 10598@debbugs.gnu.org To: "Roland Winkler" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 15 10:41:24 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SqKOH-0003IN-3W for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Jul 2012 10:41:21 +0200 Original-Received: from localhost ([::1]:37108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqKOG-0008IR-Fe for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Jul 2012 04:41:20 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqKOC-0008Ft-Ia for bug-gnu-emacs@gnu.org; Sun, 15 Jul 2012 04:41:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqKOB-0007Ae-3v for bug-gnu-emacs@gnu.org; Sun, 15 Jul 2012 04:41:16 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqKOB-0007AW-00 for bug-gnu-emacs@gnu.org; Sun, 15 Jul 2012 04:41:15 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SqKTm-0003kn-F6 for bug-gnu-emacs@gnu.org; Sun, 15 Jul 2012 04:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Jul 2012 08:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10598-submit@debbugs.gnu.org id=B10598.134234199414398 (code B ref 10598); Sun, 15 Jul 2012 08:47:02 +0000 Original-Received: (at 10598) by debbugs.gnu.org; 15 Jul 2012 08:46:34 +0000 Original-Received: from localhost ([127.0.0.1]:41691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SqKTK-0003k6-1J for submit@debbugs.gnu.org; Sun, 15 Jul 2012 04:46:34 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:40047 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SqKTE-0003jp-Rt for 10598@debbugs.gnu.org; Sun, 15 Jul 2012 04:46:30 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 7CFAA451CAE3; Sun, 15 Jul 2012 01:40:39 -0700 (PDT) In-Reply-To: <20482.30360.86756.671195@gargle.gargle.HOWL> (Roland Winkler's message of "Sun, 15 Jul 2012 02:51:52 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:61952 Archived-At: > Currently the COMMAND arg knows three special characters, *. ?, and > &. How about a fourth character ";"? More specifically: > > & means: run asynchronously, separating with & > ; means: run asynchronously, separating with ; > > I believe this should not break too much backward compatibility > because ; normally needs to be protected anyway. > > Then & becomes the default of dired-do-async-shell-command. Anyway, > & is appended only if it is not yet present. > > Or am I missing something? Would this break something? Yes, it seems this is what remains to do. It's implemented in the following patch: === modified file 'lisp/dired-aux.el' --- lisp/dired-aux.el 2012-04-17 01:52:00 +0000 +++ lisp/dired-aux.el 2012-07-15 08:27:04 +0000 @@ -546,8 +546,16 @@ (defun dired-read-shell-command (prompt (defun dired-do-async-shell-command (command &optional arg file-list) "Run a shell command COMMAND on the marked files asynchronously. -Like `dired-do-shell-command' but if COMMAND doesn't end in ampersand, -adds `* &' surrounded by whitespace and executes the command asynchronously. +Like `dired-do-shell-command', but adds `&' at the end of COMMAND +to execute it asynchronously. + +When operating on multiple files, asynchronous commands are executed +on each file in parallel. In shell syntax this means separating the +individual commands with `&'. However, when COMMAND ends in `;' or `;&' +then commands are executed in the background on each file sequentially +waiting for each command to terminate before running the next command. +In shell syntax this means separating the individual commands with `;'. + The output appears in the buffer `*Async Shell Command*'." (interactive (let ((files (dired-get-marked-files t current-prefix-arg))) @@ -556,14 +564,10 @@ (defun dired-do-async-shell-command (com (dired-read-shell-command "& on %s: " current-prefix-arg files) current-prefix-arg files))) - (unless (string-match "[*?][ \t]*\\'" command) - (setq command (concat command " *"))) (unless (string-match "&[ \t]*\\'" command) (setq command (concat command " &"))) (dired-do-shell-command command arg file-list)) -;; The in-background argument is only needed in Emacs 18 where -;; shell-command doesn't understand an appended ampersand `&'. ;;;###autoload (defun dired-do-shell-command (command &optional arg file-list) "Run a shell command COMMAND on the marked files. @@ -655,7 +656,15 @@ (defun dired-shell-stuff-it (command fil ;; Might be redefined for smarter things and could then use RAW-ARG ;; (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 ((stuff-it + (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 dired-star-subst-regexp command) (string-match dired-quark-subst-regexp command)) (lambda (x) @@ -665,13 +674,16 @@ (defun dired-shell-stuff-it (command fil (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) ";") + (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))))) + (funcall stuff-it files))) + (if in-background "&" "")))) ;; This is an extra function so that it can be redefined by ange-ftp. ;;;###autoload