comparison lisp/dired-aux.el @ 97087:535cfa18fb6d

(dired-do-async-shell-command): New command.
author Juri Linkov <juri@jurta.org>
date Tue, 29 Jul 2008 16:36:42 +0000
parents 7c116c0a454b
children 9880fe3905f7
comparison
equal deleted inserted replaced
97086:c38003f850b5 97087:535cfa18fb6d
487 (dired-mark-pop-up 487 (dired-mark-pop-up
488 nil 'shell files 488 nil 'shell files
489 #'read-shell-command 489 #'read-shell-command
490 (format prompt (dired-mark-prompt arg files)) 490 (format prompt (dired-mark-prompt arg files))
491 nil nil))) 491 nil nil)))
492
493 ;;;###autoload
494 (defun dired-do-async-shell-command (command &optional arg file-list)
495 "Run a shell command COMMAND on the marked files asynchronously.
496
497 Like `dired-do-shell-command' but if COMMAND doesn't end in ampersand,
498 adds `* &' surrounded by whitespace and executes the command asynchronously.
499 The output appears in the buffer `*Async Shell Command*'."
500 (interactive
501 (let ((files (dired-get-marked-files t current-prefix-arg)))
502 (list
503 ;; Want to give feedback whether this file or marked files are used:
504 (dired-read-shell-command "& on %s: " current-prefix-arg files)
505 current-prefix-arg
506 files)))
507 (unless (string-match "[*?][ \t]*\\'" command)
508 (setq command (concat command " *")))
509 (unless (string-match "&[ \t]*\\'" command)
510 (setq command (concat command " &")))
511 (dired-do-shell-command command arg file-list))
492 512
493 ;; The in-background argument is only needed in Emacs 18 where 513 ;; The in-background argument is only needed in Emacs 18 where
494 ;; shell-command doesn't understand an appended ampersand `&'. 514 ;; shell-command doesn't understand an appended ampersand `&'.
495 ;;;###autoload 515 ;;;###autoload
496 (defun dired-do-shell-command (command &optional arg file-list) 516 (defun dired-do-shell-command (command &optional arg file-list)