diff options
| author | Juri Linkov | 2012-07-17 21:40:15 +0300 |
|---|---|---|
| committer | Juri Linkov | 2012-07-17 21:40:15 +0300 |
| commit | 6dafa0d5352ada03f9a6db6ba8d3eec8f7884642 (patch) | |
| tree | 65e44148f35e678ce0703643784171206322de1a | |
| parent | b19dd9d1bbf0afce896a367a817e0e22c381308b (diff) | |
| download | emacs-6dafa0d5352ada03f9a6db6ba8d3eec8f7884642.tar.gz emacs-6dafa0d5352ada03f9a6db6ba8d3eec8f7884642.zip | |
* lisp/dired-aux.el (dired-do-async-shell-command): Doc fix.
(dired-do-async-shell-command): Don't add `*' at the end of the
command (Bug#11815).
(dired-do-shell-command): Doc fix.
(dired-shell-stuff-it): Strip the trailing "&" and ";" if any.
Join the individual commands using either "&" or ";" as the
separator depending on the values of these trailing characters.
At the end re-add the trailing "&". (Bug#10598)
* lisp/simple.el (async-shell-command): Sync the interactive spec with
`shell-command'. Doc fix.
(shell-command): Doc fix.
| -rw-r--r-- | etc/NEWS | 12 | ||||
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/dired-aux.el | 81 | ||||
| -rw-r--r-- | lisp/simple.el | 19 |
4 files changed, 89 insertions, 38 deletions
| @@ -274,13 +274,13 @@ The variable `diff-use-changed-face' defines whether to use | |||
| 274 | the face `diff-changed', or `diff-removed' and `diff-added' | 274 | the face `diff-changed', or `diff-removed' and `diff-added' |
| 275 | to highlight changes in context diffs. | 275 | to highlight changes in context diffs. |
| 276 | 276 | ||
| 277 | ** Ediff now uses the same color scheme as Diff mode | ||
| 278 | on high color displays. | ||
| 279 | |||
| 277 | ** Flymake uses fringe bitmaps to indicate errors and warnings. | 280 | ** Flymake uses fringe bitmaps to indicate errors and warnings. |
| 278 | See flymake-fringe-indicator-position, flymake-error-bitmap and | 281 | See flymake-fringe-indicator-position, flymake-error-bitmap and |
| 279 | flymake-warning-bitmap. | 282 | flymake-warning-bitmap. |
| 280 | 283 | ||
| 281 | ** Ediff now uses the same color scheme as Diff mode | ||
| 282 | on high color displays. | ||
| 283 | |||
| 284 | ** `sh-script' | 284 | ** `sh-script' |
| 285 | *** Pairing of parens/quotes uses electric-pair-mode instead of skeleton-pair. | 285 | *** Pairing of parens/quotes uses electric-pair-mode instead of skeleton-pair. |
| 286 | *** `sh-electric-here-document-mode' now controls auto-insertion of here-docs. | 286 | *** `sh-electric-here-document-mode' now controls auto-insertion of here-docs. |
| @@ -348,6 +348,12 @@ these commands now). | |||
| 348 | ** erc will look up server/channel names via auth-source and use the | 348 | ** erc will look up server/channel names via auth-source and use the |
| 349 | channel keys found, if any. | 349 | channel keys found, if any. |
| 350 | 350 | ||
| 351 | ** Dired | ||
| 352 | |||
| 353 | *** `dired-do-async-shell-command' executes each file sequentially | ||
| 354 | if the command ends in `;' (when operating on multiple files). | ||
| 355 | Othwerwise, it executes the command on each file in parallel. | ||
| 356 | |||
| 351 | ** FFAP | 357 | ** FFAP |
| 352 | 358 | ||
| 353 | *** The option `ffap-url-unwrap-remote' can now be a list of strings, | 359 | *** The option `ffap-url-unwrap-remote' can now be a list of strings, |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2320a16a26e..cbc233079a7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,20 @@ | |||
| 1 | 2012-07-17 Juri Linkov <juri@jurta.org> | 1 | 2012-07-17 Juri Linkov <juri@jurta.org> |
| 2 | 2 | ||
| 3 | * dired-aux.el (dired-do-async-shell-command): Doc fix. | ||
| 4 | (dired-do-async-shell-command): Don't add `*' at the end of the | ||
| 5 | command (Bug#11815). | ||
| 6 | (dired-do-shell-command): Doc fix. | ||
| 7 | (dired-shell-stuff-it): Strip the trailing "&" and ";" if any. | ||
| 8 | Join the individual commands using either "&" or ";" as the | ||
| 9 | separator depending on the values of these trailing characters. | ||
| 10 | At the end re-add the trailing "&". (Bug#10598) | ||
| 11 | |||
| 12 | * simple.el (async-shell-command): Sync the interactive spec with | ||
| 13 | `shell-command'. Doc fix. | ||
| 14 | (shell-command): Doc fix. | ||
| 15 | |||
| 16 | 2012-07-17 Juri Linkov <juri@jurta.org> | ||
| 17 | |||
| 3 | * descr-text.el (describe-char): Fix format args. (Bug#10129) | 18 | * descr-text.el (describe-char): Fix format args. (Bug#10129) |
| 4 | 19 | ||
| 5 | 2012-07-17 Fabián Ezequiel Gallina <fgallina@cuca> | 20 | 2012-07-17 Fabián Ezequiel Gallina <fgallina@cuca> |
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index ffd93a85ee8..6186f762e0a 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -545,8 +545,17 @@ offer a smarter default choice of shell command." | |||
| 545 | (defun dired-do-async-shell-command (command &optional arg file-list) | 545 | (defun dired-do-async-shell-command (command &optional arg file-list) |
| 546 | "Run a shell command COMMAND on the marked files asynchronously. | 546 | "Run a shell command COMMAND on the marked files asynchronously. |
| 547 | 547 | ||
| 548 | Like `dired-do-shell-command' but if COMMAND doesn't end in ampersand, | 548 | Like `dired-do-shell-command', but adds `&' at the end of COMMAND |
| 549 | adds `* &' surrounded by whitespace and executes the command asynchronously. | 549 | to execute it asynchronously. |
| 550 | |||
| 551 | When operating on multiple files, asynchronous commands | ||
| 552 | are executed in the background on each file in parallel. | ||
| 553 | In shell syntax this means separating the individual commands | ||
| 554 | with `&'. However, when COMMAND ends in `;' or `;&' then commands | ||
| 555 | are executed in the background on each file sequentially waiting | ||
| 556 | for each command to terminate before running the next command. | ||
| 557 | In shell syntax this means separating the individual commands with `;'. | ||
| 558 | |||
| 550 | The output appears in the buffer `*Async Shell Command*'." | 559 | The output appears in the buffer `*Async Shell Command*'." |
| 551 | (interactive | 560 | (interactive |
| 552 | (let ((files (dired-get-marked-files t current-prefix-arg))) | 561 | (let ((files (dired-get-marked-files t current-prefix-arg))) |
| @@ -555,18 +564,14 @@ The output appears in the buffer `*Async Shell Command*'." | |||
| 555 | (dired-read-shell-command "& on %s: " current-prefix-arg files) | 564 | (dired-read-shell-command "& on %s: " current-prefix-arg files) |
| 556 | current-prefix-arg | 565 | current-prefix-arg |
| 557 | files))) | 566 | files))) |
| 558 | (unless (string-match "[*?][ \t]*\\'" command) | ||
| 559 | (setq command (concat command " *"))) | ||
| 560 | (unless (string-match "&[ \t]*\\'" command) | 567 | (unless (string-match "&[ \t]*\\'" command) |
| 561 | (setq command (concat command " &"))) | 568 | (setq command (concat command " &"))) |
| 562 | (dired-do-shell-command command arg file-list)) | 569 | (dired-do-shell-command command arg file-list)) |
| 563 | 570 | ||
| 564 | ;; The in-background argument is only needed in Emacs 18 where | ||
| 565 | ;; shell-command doesn't understand an appended ampersand `&'. | ||
| 566 | ;;;###autoload | 571 | ;;;###autoload |
| 567 | (defun dired-do-shell-command (command &optional arg file-list) | 572 | (defun dired-do-shell-command (command &optional arg file-list) |
| 568 | "Run a shell command COMMAND on the marked files. | 573 | "Run a shell command COMMAND on the marked files. |
| 569 | If no files are marked or a specific numeric prefix arg is given, | 574 | If no files are marked or a numeric prefix arg is given, |
| 570 | the next ARG files are used. Just \\[universal-argument] means the current file. | 575 | the next ARG files are used. Just \\[universal-argument] means the current file. |
| 571 | The prompt mentions the file(s) or the marker, as appropriate. | 576 | The prompt mentions the file(s) or the marker, as appropriate. |
| 572 | 577 | ||
| @@ -588,7 +593,17 @@ If you want to use `*' as a shell wildcard with whitespace around | |||
| 588 | it, write `*\"\"' in place of just `*'. This is equivalent to just | 593 | it, write `*\"\"' in place of just `*'. This is equivalent to just |
| 589 | `*' in the shell, but avoids Dired's special handling. | 594 | `*' in the shell, but avoids Dired's special handling. |
| 590 | 595 | ||
| 591 | If COMMAND produces output, it goes to a separate buffer. | 596 | If COMMAND ends in `&', `;', or `;&', it is executed in the |
| 597 | background asynchronously, and the output appears in the buffer | ||
| 598 | `*Async Shell Command*'. When operating on multiple files and COMMAND | ||
| 599 | ends in `&', the shell command is executed on each file in parallel. | ||
| 600 | However, when COMMAND ends in `;' or `;&' then commands are executed | ||
| 601 | in the background on each file sequentially waiting for each command | ||
| 602 | to terminate before running the next command. You can also use | ||
| 603 | `dired-do-async-shell-command' that automatically adds `&'. | ||
| 604 | |||
| 605 | Otherwise, COMMAND is executed synchronously, and the output | ||
| 606 | appears in the buffer `*Shell Command Output*'. | ||
| 592 | 607 | ||
| 593 | This feature does not try to redisplay Dired buffers afterward, as | 608 | This feature does not try to redisplay Dired buffers afterward, as |
| 594 | there's no telling what files COMMAND may have changed. | 609 | there's no telling what files COMMAND may have changed. |
| @@ -607,10 +622,7 @@ can be produced by `dired-get-marked-files', for example." | |||
| 607 | (let ((files (dired-get-marked-files t current-prefix-arg))) | 622 | (let ((files (dired-get-marked-files t current-prefix-arg))) |
| 608 | (list | 623 | (list |
| 609 | ;; Want to give feedback whether this file or marked files are used: | 624 | ;; Want to give feedback whether this file or marked files are used: |
| 610 | (dired-read-shell-command (concat "! on " | 625 | (dired-read-shell-command "! on %s: " current-prefix-arg files) |
| 611 | "%s: ") | ||
| 612 | current-prefix-arg | ||
| 613 | files) | ||
| 614 | current-prefix-arg | 626 | current-prefix-arg |
| 615 | files))) | 627 | files))) |
| 616 | (let* ((on-each (not (string-match dired-star-subst-regexp command))) | 628 | (let* ((on-each (not (string-match dired-star-subst-regexp command))) |
| @@ -654,23 +666,34 @@ can be produced by `dired-get-marked-files', for example." | |||
| 654 | ;; Might be redefined for smarter things and could then use RAW-ARG | 666 | ;; Might be redefined for smarter things and could then use RAW-ARG |
| 655 | ;; (coming from interactive P and currently ignored) to decide what to do. | 667 | ;; (coming from interactive P and currently ignored) to decide what to do. |
| 656 | ;; Smart would be a way to access basename or extension of file names. | 668 | ;; Smart would be a way to access basename or extension of file names. |
| 657 | (let ((stuff-it | 669 | (let* ((in-background (string-match "[ \t]*&[ \t]*\\'" command)) |
| 658 | (if (or (string-match dired-star-subst-regexp command) | 670 | (command (if in-background |
| 659 | (string-match dired-quark-subst-regexp command)) | 671 | (substring command 0 (match-beginning 0)) |
| 660 | (lambda (x) | 672 | command)) |
| 661 | (let ((retval command)) | 673 | (sequentially (string-match "[ \t]*;[ \t]*\\'" command)) |
| 662 | (while (string-match | 674 | (command (if sequentially |
| 663 | "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval) | 675 | (substring command 0 (match-beginning 0)) |
| 664 | (setq retval (replace-match x t t retval 2))) | 676 | command)) |
| 665 | retval)) | 677 | (stuff-it |
| 666 | (lambda (x) (concat command dired-mark-separator x))))) | 678 | (if (or (string-match dired-star-subst-regexp command) |
| 667 | (if on-each | 679 | (string-match dired-quark-subst-regexp command)) |
| 668 | (mapconcat stuff-it (mapcar 'shell-quote-argument file-list) ";") | 680 | (lambda (x) |
| 669 | (let ((files (mapconcat 'shell-quote-argument | 681 | (let ((retval command)) |
| 670 | file-list dired-mark-separator))) | 682 | (while (string-match |
| 671 | (if (> (length file-list) 1) | 683 | "\\(^\\|[ \t]\\)\\([*?]\\)\\([ \t]\\|$\\)" retval) |
| 672 | (setq files (concat dired-mark-prefix files dired-mark-postfix))) | 684 | (setq retval (replace-match x t t retval 2))) |
| 673 | (funcall stuff-it files))))) | 685 | retval)) |
| 686 | (lambda (x) (concat command dired-mark-separator x))))) | ||
| 687 | (concat | ||
| 688 | (if on-each | ||
| 689 | (mapconcat stuff-it (mapcar 'shell-quote-argument file-list) | ||
| 690 | (if (and in-background (not sequentially)) "&" ";")) | ||
| 691 | (let ((files (mapconcat 'shell-quote-argument | ||
| 692 | file-list dired-mark-separator))) | ||
| 693 | (if (> (length file-list) 1) | ||
| 694 | (setq files (concat dired-mark-prefix files dired-mark-postfix))) | ||
| 695 | (funcall stuff-it files))) | ||
| 696 | (if in-background "&" "")))) | ||
| 674 | 697 | ||
| 675 | ;; This is an extra function so that it can be redefined by ange-ftp. | 698 | ;; This is an extra function so that it can be redefined by ange-ftp. |
| 676 | ;;;###autoload | 699 | ;;;###autoload |
diff --git a/lisp/simple.el b/lisp/simple.el index 37e0b48d31d..c958c460f98 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2247,9 +2247,11 @@ to `shell-command-history'." | |||
| 2247 | (defun async-shell-command (command &optional output-buffer error-buffer) | 2247 | (defun async-shell-command (command &optional output-buffer error-buffer) |
| 2248 | "Execute string COMMAND asynchronously in background. | 2248 | "Execute string COMMAND asynchronously in background. |
| 2249 | 2249 | ||
| 2250 | Like `shell-command' but if COMMAND doesn't end in ampersand, adds `&' | 2250 | Like `shell-command', but adds `&' at the end of COMMAND |
| 2251 | surrounded by whitespace and executes the command asynchronously. | 2251 | to execute it asynchronously. |
| 2252 | |||
| 2252 | The output appears in the buffer `*Async Shell Command*'. | 2253 | The output appears in the buffer `*Async Shell Command*'. |
| 2254 | That buffer is in shell mode. | ||
| 2253 | 2255 | ||
| 2254 | In Elisp, you will often be better served by calling `start-process' | 2256 | In Elisp, you will often be better served by calling `start-process' |
| 2255 | directly, since it offers more control and does not impose the use of a | 2257 | directly, since it offers more control and does not impose the use of a |
| @@ -2257,8 +2259,12 @@ shell (with its need to quote arguments)." | |||
| 2257 | (interactive | 2259 | (interactive |
| 2258 | (list | 2260 | (list |
| 2259 | (read-shell-command "Async shell command: " nil nil | 2261 | (read-shell-command "Async shell command: " nil nil |
| 2260 | (and buffer-file-name | 2262 | (let ((filename |
| 2261 | (file-relative-name buffer-file-name))) | 2263 | (cond |
| 2264 | (buffer-file-name) | ||
| 2265 | ((eq major-mode 'dired-mode) | ||
| 2266 | (dired-get-filename nil t))))) | ||
| 2267 | (and filename (file-relative-name filename)))) | ||
| 2262 | current-prefix-arg | 2268 | current-prefix-arg |
| 2263 | shell-command-default-error-buffer)) | 2269 | shell-command-default-error-buffer)) |
| 2264 | (unless (string-match "&[ \t]*\\'" command) | 2270 | (unless (string-match "&[ \t]*\\'" command) |
| @@ -2269,9 +2275,10 @@ shell (with its need to quote arguments)." | |||
| 2269 | "Execute string COMMAND in inferior shell; display output, if any. | 2275 | "Execute string COMMAND in inferior shell; display output, if any. |
| 2270 | With prefix argument, insert the COMMAND's output at point. | 2276 | With prefix argument, insert the COMMAND's output at point. |
| 2271 | 2277 | ||
| 2272 | If COMMAND ends in ampersand, execute it asynchronously. | 2278 | If COMMAND ends in `&', execute it asynchronously. |
| 2273 | The output appears in the buffer `*Async Shell Command*'. | 2279 | The output appears in the buffer `*Async Shell Command*'. |
| 2274 | That buffer is in shell mode. | 2280 | That buffer is in shell mode. You can also use |
| 2281 | `async-shell-command' that automatically adds `&'. | ||
| 2275 | 2282 | ||
| 2276 | Otherwise, COMMAND is executed synchronously. The output appears in | 2283 | Otherwise, COMMAND is executed synchronously. The output appears in |
| 2277 | the buffer `*Shell Command Output*'. If the output is short enough to | 2284 | the buffer `*Shell Command Output*'. If the output is short enough to |