diff options
| author | Tino Calancha | 2017-07-02 22:09:02 +0900 |
|---|---|---|
| committer | Tino Calancha | 2017-07-02 22:09:02 +0900 |
| commit | a8b71b3dc53883a2dcb3339bf4c7e1232c42d276 (patch) | |
| tree | fd9972fc07854be2f6e26f10e4d51b94ffc5381e /doc | |
| parent | 80e200c0a08805771d1c709546d79088be188021 (diff) | |
| download | emacs-a8b71b3dc53883a2dcb3339bf4c7e1232c42d276.tar.gz emacs-a8b71b3dc53883a2dcb3339bf4c7e1232c42d276.zip | |
Extend dired-do-shell-command substitutions
Substitute "`?`" inside command with the current file name.
See details in:
https://lists.gnu.org/archive/html/emacs-devel/2017-06/msg00618.html
* lisp/dired-aux.el (dired-quark-subst-regexp, dired-star-subst-regexp):
Mark as obsolete.
(dired-isolated-string-re): New defun.
(dired--star-or-qmark-p): New predicate.
(dired-do-shell-command): Use dired--star-or-qmark-p. Substitute "`?`"
with the current file name.
* doc/emacs/dired.texi (Shell Commands in Dired): Update manual.
; * etc/NEWS: Mention it.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/emacs/dired.texi | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 22b0fcd4676..28cb51d88bb 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi | |||
| @@ -875,27 +875,33 @@ treat it specially. | |||
| 875 | 875 | ||
| 876 | @item | 876 | @item |
| 877 | Otherwise, if the command string contains @samp{?} surrounded by | 877 | Otherwise, if the command string contains @samp{?} surrounded by |
| 878 | whitespace, Emacs runs the shell command once @emph{for each file}, | 878 | whitespace or @samp{`?`}, Emacs runs the shell command once |
| 879 | substituting the current file name for @samp{?} each time. You can | 879 | @emph{for each file}, substituting the current file name for @samp{?} |
| 880 | use @samp{?} more than once in the command; the same file name | 880 | and @samp{`?`} each time. You can use both @samp{?} or @samp{`?`} more |
| 881 | replaces each occurrence. | 881 | than once in the command; the same file name replaces each occurrence. |
| 882 | If you mix them with @samp{*} the command signals an error. | ||
| 882 | 883 | ||
| 883 | @item | 884 | @item |
| 884 | If the command string contains neither @samp{*} nor @samp{?}, Emacs | 885 | If the command string contains neither @samp{*} nor @samp{?} nor @samp{`?`}, |
| 885 | runs the shell command once for each file, adding the file name at the | 886 | Emacs runs the shell command once for each file, adding the file name at the |
| 886 | end. For example, @kbd{! uudecode @key{RET}} runs @code{uudecode} on | 887 | end. For example, @kbd{! uudecode @key{RET}} runs @code{uudecode} on |
| 887 | each file. | 888 | each file. |
| 888 | @end itemize | 889 | @end itemize |
| 889 | 890 | ||
| 890 | To iterate over the file names in a more complicated fashion, use an | 891 | To iterate over the file names in a more complicated fashion, you might |
| 891 | explicit shell loop. For example, here is how to uuencode each file, | 892 | prefer to use an explicit shell loop. For example, here is how to uuencode |
| 892 | making the output file name by appending @samp{.uu} to the input file | 893 | each file, making the output file name by appending @samp{.uu} to the input |
| 893 | name: | 894 | file name: |
| 894 | 895 | ||
| 895 | @example | 896 | @example |
| 896 | for file in * ; do uuencode "$file" "$file" >"$file".uu; done | 897 | for file in * ; do uuencode "$file" "$file" >"$file".uu; done |
| 897 | @end example | 898 | @end example |
| 898 | 899 | ||
| 900 | The same example with @samp{`?`} notation: | ||
| 901 | @example | ||
| 902 | uuencode ? ? > `?`.uu | ||
| 903 | @end example | ||
| 904 | |||
| 899 | The @kbd{!} and @kbd{&} commands do not attempt to update the Dired | 905 | The @kbd{!} and @kbd{&} commands do not attempt to update the Dired |
| 900 | buffer to show new or modified files, because they don't know what | 906 | buffer to show new or modified files, because they don't know what |
| 901 | files will be changed. Use the @kbd{g} command to update the Dired | 907 | files will be changed. Use the @kbd{g} command to update the Dired |