Commit | Line | Data |
---|---|---|
8cf51b2c | 1 | @c This is part of the Emacs manual. |
acaf905b | 2 | @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2012 |
4ebe9902 | 3 | @c Free Software Foundation, Inc. |
8cf51b2c | 4 | @c See file emacs.texi for copying conditions. |
e0b1591b | 5 | @node Dired |
8cf51b2c | 6 | @chapter Dired, the Directory Editor |
59eda47f RS |
7 | @c This node is referenced in the tutorial. When renaming or deleting |
8 | @c it, the tutorial needs to be adjusted. | |
8cf51b2c GM |
9 | @cindex Dired |
10 | @cindex file management | |
11 | ||
12 | Dired makes an Emacs buffer containing a listing of a directory, and | |
13 | optionally some of its subdirectories as well. You can use the normal | |
fac6225b CY |
14 | Emacs commands to move around in this buffer, and special Dired |
15 | commands to operate on the listed files. | |
8cf51b2c | 16 | |
16152b76 | 17 | The Dired buffer is ``read-only'', and inserting text in it is not |
fac6225b CY |
18 | allowed. Ordinary printing characters such as @kbd{d} and @kbd{x} are |
19 | redefined for special Dired commands. Some Dired commands @dfn{mark} | |
20 | or @dfn{flag} the @dfn{current file} (that is, the file on the current | |
21 | line); other commands operate on the marked files or on the flagged | |
22 | files. You first mark certain files in order to operate on all of | |
23 | them with one command. | |
8cf51b2c GM |
24 | |
25 | The Dired-X package provides various extra features for Dired mode. | |
8c62c205 | 26 | @xref{Top, Dired-X,,dired-x, Dired Extra User's Manual}. |
8cf51b2c | 27 | |
fac6225b CY |
28 | You can also view a list of files in a directory with @kbd{C-x C-d} |
29 | (@code{list-directory}). Unlike Dired, this command does not allow | |
30 | you to operate on the listed files. @xref{Directories}. | |
31 | ||
8cf51b2c GM |
32 | @menu |
33 | * Enter: Dired Enter. How to invoke Dired. | |
34 | * Navigation: Dired Navigation. Special motion commands in the Dired buffer. | |
35 | * Deletion: Dired Deletion. Deleting files with Dired. | |
36 | * Flagging Many Files:: Flagging files based on their names. | |
37 | * Visit: Dired Visiting. Other file operations through Dired. | |
8838673e GM |
38 | * Marks vs Flags:: Flagging for deletion vs marking. |
39 | * Operating on Files:: How to copy, rename, print, compress, etc. | |
40 | either one file or several files. | |
8cf51b2c GM |
41 | * Shell Commands in Dired:: Running a shell command on the marked files. |
42 | * Transforming File Names:: Using patterns to rename multiple files. | |
53eced6d | 43 | * Comparison in Dired:: Running @code{diff} by way of Dired. |
8cf51b2c GM |
44 | * Subdirectories in Dired:: Adding subdirectories to the Dired buffer. |
45 | @ifnottex | |
46 | * Subdir Switches:: Subdirectory switches in Dired. | |
47 | @end ifnottex | |
8838673e | 48 | * Subdirectory Motion:: Moving across subdirectories, and up and down. |
8cf51b2c GM |
49 | * Hiding Subdirectories:: Making subdirectories visible or invisible. |
50 | * Updating: Dired Updating. Discarding lines for files of no interest. | |
53eced6d | 51 | * Find: Dired and Find. Using @code{find} to choose the files for Dired. |
8cf51b2c | 52 | * Wdired:: Operating on files by editing the Dired buffer. |
c5ae942b | 53 | * Image-Dired:: Viewing image thumbnails in Dired. |
8cf51b2c GM |
54 | * Misc: Misc Dired Features. Various other features. |
55 | @end menu | |
56 | ||
57 | @node Dired Enter | |
58 | @section Entering Dired | |
59 | ||
60 | @findex dired | |
61 | @kindex C-x d | |
62 | @vindex dired-listing-switches | |
fac6225b CY |
63 | To invoke Dired, type @kbd{C-x d} (@code{dired}). This reads a |
64 | directory name using the minibuffer, and opens a @dfn{Dired buffer} | |
65 | listing the files in that directory. You can also supply a wildcard | |
66 | file name pattern as the minibuffer argument, in which case the Dired | |
67 | buffer lists all files matching that pattern. The usual history and | |
68 | completion commands can be used in the minibuffer; in particular, | |
69 | @kbd{M-n} puts the name of the visited file (if any) in the minibuffer | |
70 | (@pxref{Minibuffer History}). | |
71 | ||
72 | You can also invoke Dired by giving @kbd{C-x C-f} (@code{find-file}) | |
73 | a directory name. | |
8cf51b2c GM |
74 | |
75 | The variable @code{dired-listing-switches} specifies the options to | |
c40a7de7 CY |
76 | give to @command{ls} for listing the directory; this string |
77 | @emph{must} contain @samp{-l}. If you use a prefix argument with the | |
78 | @code{dired} command, you can specify the @command{ls} switches with the | |
79 | minibuffer before you enter the directory specification. No matter | |
80 | how they are specified, the @command{ls} switches can include short | |
81 | options (that is, single characters) requiring no arguments, and long | |
82 | options (starting with @samp{--}) whose arguments are specified with | |
83 | @samp{=}. | |
8cf51b2c | 84 | |
90a6258b | 85 | @vindex dired-use-ls-dired |
c40a7de7 CY |
86 | If your @command{ls} program supports the @samp{--dired} option, |
87 | Dired automatically passes it that option; this causes @command{ls} to | |
88 | emit special escape sequences for certain unusual file names, without | |
89 | which Dired will not be able to parse those names. The first time you | |
90 | run Dired in an Emacs session, it checks whether @command{ls} supports | |
91 | the @samp{--dired} option by calling it once with that option. If the | |
92 | exit code is 0, Dired will subsequently use the @samp{--dired} option; | |
93 | otherwise it will not. You can inhibit this check by customizing the | |
94 | variable @code{dired-use-ls-dired}. The value @code{unspecified} (the | |
95 | default) means to perform the check; any other non-@code{nil} value | |
96 | means to use the @samp{--dired} option; and @code{nil} means not to | |
97 | use the @samp{--dired} option. | |
98 | ||
99 | On MS-Windows and MS-DOS systems, Emacs emulates @command{ls}. | |
100 | @xref{ls in Lisp}, for options and peculiarities of this emulation. | |
8cf51b2c | 101 | |
8cf51b2c GM |
102 | @findex dired-other-window |
103 | @kindex C-x 4 d | |
104 | @findex dired-other-frame | |
105 | @kindex C-x 5 d | |
c40a7de7 CY |
106 | To display the Dired buffer in another window, use @kbd{C-x 4 d} |
107 | (@code{dired-other-window}) instead of @kbd{C-x d}. @kbd{C-x 5 d} | |
108 | (@code{dired-other-frame}) displays the Dired buffer in a separate | |
109 | frame. | |
110 | ||
111 | @kindex q @r{(Dired)} | |
112 | @findex quit-window | |
113 | Typing @kbd{q} (@code{quit-window}) buries the Dired buffer, and | |
114 | deletes its window if the window was created just for that buffer. | |
8cf51b2c GM |
115 | |
116 | @node Dired Navigation | |
117 | @section Navigation in the Dired Buffer | |
118 | ||
119 | @kindex C-n @r{(Dired)} | |
120 | @kindex C-p @r{(Dired)} | |
121 | All the usual Emacs cursor motion commands are available in Dired | |
122 | buffers. The keys @kbd{C-n} and @kbd{C-p} are redefined to put the | |
123 | cursor at the beginning of the file name on the line, rather than at | |
124 | the beginning of the line. | |
125 | ||
126 | @kindex SPC @r{(Dired)} | |
127 | For extra convenience, @key{SPC} and @kbd{n} in Dired are equivalent | |
fac6225b CY |
128 | to @kbd{C-n}. @kbd{p} is equivalent to @kbd{C-p}. (Moving by lines |
129 | is so common in Dired that it deserves to be easy to type.) @key{DEL} | |
130 | (move up and unflag) is also often useful simply for moving up | |
131 | (@pxref{Dired Deletion}). | |
8cf51b2c GM |
132 | |
133 | @findex dired-goto-file | |
134 | @kindex j @r{(Dired)} | |
fac6225b CY |
135 | @kbd{j} (@code{dired-goto-file}) prompts for a file name using the |
136 | minibuffer, and moves point to the line in the Dired buffer describing | |
137 | that file. | |
138 | ||
139 | @cindex searching Dired buffers | |
c40a7de7 | 140 | @findex dired-isearch-filenames |
fac6225b | 141 | @vindex dired-isearch-filenames |
c40a7de7 CY |
142 | @findex dired-isearch-filenames-regexp |
143 | @kindex M-s f C-s @r{(Dired)} | |
144 | @kindex M-s f M-C-s @r{(Dired)} | |
fac6225b CY |
145 | @kbd{M-s f C-s} (@code{dired-isearch-filenames}) performs a forward |
146 | incremental search in the Dired buffer, looking for matches only | |
147 | amongst the file names and ignoring the rest of the text in the | |
148 | buffer. @kbd{M-s f M-C-s} (@code{dired-isearch-filenames-regexp}) | |
149 | does the same, using a regular expression search. If you change the | |
13989ab1 | 150 | variable @code{dired-isearch-filenames} to @code{t}, then the |
fac6225b | 151 | usual search commands also limit themselves to the file names; for |
607f5f88 JL |
152 | instance, @kbd{C-s} behaves like @kbd{M-s f C-s}. If the value is |
153 | @code{dwim}, then search commands match the file names only when point | |
154 | was on a file name initially. @xref{Search}, for information about | |
155 | incremental search. | |
8cf51b2c GM |
156 | |
157 | Some additional navigation commands are available when the Dired | |
158 | buffer includes several directories. @xref{Subdirectory Motion}. | |
159 | ||
160 | @node Dired Deletion | |
161 | @section Deleting Files with Dired | |
162 | @cindex flagging files (in Dired) | |
163 | @cindex deleting files (in Dired) | |
164 | ||
165 | One of the most frequent uses of Dired is to first @dfn{flag} files for | |
166 | deletion, then delete the files that were flagged. | |
167 | ||
168 | @table @kbd | |
169 | @item d | |
170 | Flag this file for deletion. | |
171 | @item u | |
172 | Remove deletion flag on this line. | |
173 | @item @key{DEL} | |
174 | Move point to previous line and remove the deletion flag on that line. | |
175 | @item x | |
176 | Delete the files that are flagged for deletion. | |
177 | @end table | |
178 | ||
179 | @kindex d @r{(Dired)} | |
180 | @findex dired-flag-file-deletion | |
181 | You can flag a file for deletion by moving to the line describing | |
182 | the file and typing @kbd{d} (@code{dired-flag-file-deletion}). The | |
183 | deletion flag is visible as a @samp{D} at the beginning of the line. | |
184 | This command moves point to the next line, so that repeated @kbd{d} | |
185 | commands flag successive files. A numeric argument serves as a repeat | |
186 | count. | |
187 | ||
188 | @kindex u @r{(Dired deletion)} | |
189 | @kindex DEL @r{(Dired)} | |
190 | The reason for flagging files for deletion, rather than deleting | |
191 | files immediately, is to reduce the danger of deleting a file | |
192 | accidentally. Until you direct Dired to delete the flagged files, you | |
193 | can remove deletion flags using the commands @kbd{u} and @key{DEL}. | |
194 | @kbd{u} (@code{dired-unmark}) works just like @kbd{d}, but removes | |
195 | flags rather than making flags. @key{DEL} | |
196 | (@code{dired-unmark-backward}) moves upward, removing flags; it is | |
197 | like @kbd{u} with argument @minus{}1. | |
198 | ||
199 | @kindex x @r{(Dired)} | |
200 | @findex dired-do-flagged-delete | |
8cf51b2c | 201 | To delete the flagged files, type @kbd{x} |
fac6225b CY |
202 | (@code{dired-do-flagged-delete}). This command first displays a list |
203 | of all the file names flagged for deletion, and requests confirmation | |
204 | with @kbd{yes}. If you confirm, Dired deletes the flagged files, then | |
205 | deletes their lines from the text of the Dired buffer. The Dired | |
206 | buffer, with somewhat fewer lines, remains selected. | |
8cf51b2c GM |
207 | |
208 | If you answer @kbd{no} or quit with @kbd{C-g} when asked to confirm, you | |
209 | return immediately to Dired, with the deletion flags still present in | |
210 | the buffer, and no files actually deleted. | |
211 | ||
212 | @cindex recursive deletion | |
213 | @vindex dired-recursive-deletes | |
214 | You can delete empty directories just like other files, but normally | |
215 | Dired cannot delete directories that are nonempty. If the variable | |
216 | @code{dired-recursive-deletes} is non-@code{nil}, then Dired can | |
217 | delete nonempty directories including all their contents. That can | |
218 | be somewhat risky. | |
219 | ||
f2d7be88 | 220 | @vindex delete-by-moving-to-trash |
04e2ce72 CY |
221 | If you change the variable @code{delete-by-moving-to-trash} to |
222 | @code{t}, the above deletion commands will move the affected files or | |
223 | directories into the operating system's Trash, instead of deleting | |
224 | them outright. @xref{Misc File Ops}. | |
f2d7be88 | 225 | |
8cf51b2c GM |
226 | @node Flagging Many Files |
227 | @section Flagging Many Files at Once | |
228 | @cindex flagging many files for deletion (in Dired) | |
229 | ||
fac6225b CY |
230 | The @kbd{#}, @kbd{~}, @kbd{.}, @kbd{% &}, and @kbd{% d} commands |
231 | flag many files for deletion, based on their file names: | |
232 | ||
8cf51b2c GM |
233 | @table @kbd |
234 | @item # | |
235 | Flag all auto-save files (files whose names start and end with @samp{#}) | |
236 | for deletion (@pxref{Auto Save}). | |
237 | ||
238 | @item ~ | |
239 | Flag all backup files (files whose names end with @samp{~}) for deletion | |
240 | (@pxref{Backup}). | |
241 | ||
8cf51b2c GM |
242 | @item .@: @r{(Period)} |
243 | Flag excess numeric backup files for deletion. The oldest and newest | |
244 | few backup files of any one file are exempt; the middle ones are | |
245 | flagged. | |
246 | ||
fac6225b CY |
247 | @item % & |
248 | Flag for deletion all files with certain kinds of names which suggest | |
249 | you could easily create those files again. | |
250 | ||
8cf51b2c GM |
251 | @item % d @var{regexp} @key{RET} |
252 | Flag for deletion all files whose names match the regular expression | |
253 | @var{regexp}. | |
254 | @end table | |
255 | ||
8cf51b2c GM |
256 | @kindex # @r{(Dired)} |
257 | @findex dired-flag-auto-save-files | |
258 | @cindex deleting auto-save files | |
fac6225b CY |
259 | @kbd{#} (@code{dired-flag-auto-save-files}) flags all files whose |
260 | names look like auto-save files---that is, files whose names begin and | |
261 | end with @samp{#}. @xref{Auto Save}. | |
8cf51b2c GM |
262 | |
263 | @kindex ~ @r{(Dired)} | |
264 | @findex dired-flag-backup-files | |
fac6225b CY |
265 | @kbd{~} (@code{dired-flag-backup-files}) flags all files whose names |
266 | say they are backup files---that is, files whose names end in | |
267 | @samp{~}. @xref{Backup}. | |
8cf51b2c GM |
268 | |
269 | @kindex . @r{(Dired)} | |
270 | @vindex dired-kept-versions | |
271 | @findex dired-clean-directory | |
fac6225b CY |
272 | @kbd{.} (period, @code{dired-clean-directory}) flags just some of |
273 | the backup files for deletion: all but the oldest few and newest few | |
274 | backups of any one file. Normally, the number of newest versions kept | |
275 | for each file is given by the variable @code{dired-kept-versions} | |
276 | (@strong{not} @code{kept-new-versions}; that applies only when | |
277 | saving). The number of oldest versions to keep is given by the | |
278 | variable @code{kept-old-versions}. | |
8cf51b2c GM |
279 | |
280 | Period with a positive numeric argument, as in @kbd{C-u 3 .}, | |
281 | specifies the number of newest versions to keep, overriding | |
282 | @code{dired-kept-versions}. A negative numeric argument overrides | |
283 | @code{kept-old-versions}, using minus the value of the argument to | |
284 | specify the number of oldest versions of each file to keep. | |
285 | ||
fac6225b CY |
286 | @kindex % & @r{(Dired)} |
287 | @findex dired-flag-garbage-files | |
288 | @vindex dired-garbage-files-regexp | |
289 | @cindex deleting some backup files | |
290 | @kbd{% &} (@code{dired-flag-garbage-files}) flags files whose names | |
291 | match the regular expression specified by the variable | |
292 | @code{dired-garbage-files-regexp}. By default, this matches certain | |
293 | files produced by @TeX{}, @samp{.bak} files, and the @samp{.orig} and | |
294 | @samp{.rej} files produced by @code{patch}. | |
295 | ||
8cf51b2c GM |
296 | @findex dired-flag-files-regexp |
297 | @kindex % d @r{(Dired)} | |
fac6225b CY |
298 | @kbd{% d} flags all files whose names match a specified regular |
299 | expression (@code{dired-flag-files-regexp}). Only the non-directory | |
300 | part of the file name is used in matching. You can use @samp{^} and | |
301 | @samp{$} to anchor matches. You can exclude certain subdirectories | |
302 | from marking by hiding them while you use @kbd{% d}. @xref{Hiding | |
303 | Subdirectories}. | |
8cf51b2c GM |
304 | |
305 | @node Dired Visiting | |
306 | @section Visiting Files in Dired | |
307 | ||
308 | There are several Dired commands for visiting or examining the files | |
309 | listed in the Dired buffer. All of them apply to the current line's | |
310 | file; if that file is really a directory, these commands invoke Dired on | |
311 | that subdirectory (making a separate Dired buffer). | |
312 | ||
313 | @table @kbd | |
314 | @item f | |
315 | @kindex f @r{(Dired)} | |
316 | @findex dired-find-file | |
317 | Visit the file described on the current line, like typing @kbd{C-x C-f} | |
318 | and supplying that file name (@code{dired-find-file}). @xref{Visiting}. | |
319 | ||
320 | @item @key{RET} | |
321 | @itemx e | |
322 | @kindex RET @r{(Dired)} | |
323 | @kindex e @r{(Dired)} | |
324 | Equivalent to @kbd{f}. | |
325 | ||
326 | @ignore @c This command seems too risky to document at all. | |
327 | @item a | |
328 | @kindex a @r{(Dired)} | |
329 | @findex dired-find-alternate-file | |
330 | Like @kbd{f}, but replaces the contents of the Dired buffer with | |
331 | that of an alternate file or directory (@code{dired-find-alternate-file}). | |
332 | @end ignore | |
333 | ||
334 | @item o | |
335 | @kindex o @r{(Dired)} | |
336 | @findex dired-find-file-other-window | |
337 | Like @kbd{f}, but uses another window to display the file's buffer | |
338 | (@code{dired-find-file-other-window}). The Dired buffer remains visible | |
339 | in the first window. This is like using @kbd{C-x 4 C-f} to visit the | |
340 | file. @xref{Windows}. | |
341 | ||
342 | @item C-o | |
343 | @kindex C-o @r{(Dired)} | |
344 | @findex dired-display-file | |
345 | Visit the file described on the current line, and display the buffer in | |
346 | another window, but do not select that window (@code{dired-display-file}). | |
347 | ||
348 | @item Mouse-1 | |
349 | @itemx Mouse-2 | |
350 | @findex dired-mouse-find-file-other-window | |
c40a7de7 | 351 | Visit the file whose name you clicked on |
8cf51b2c GM |
352 | (@code{dired-mouse-find-file-other-window}). This uses another window |
353 | to display the file, like the @kbd{o} command. | |
354 | ||
355 | @item v | |
356 | @kindex v @r{(Dired)} | |
357 | @findex dired-view-file | |
c40a7de7 CY |
358 | View the file described on the current line, with View mode |
359 | (@code{dired-view-file}). View mode provides convenient commands to | |
360 | navigate the buffer but forbids changing it; @xref{View Mode}. | |
8cf51b2c GM |
361 | |
362 | @item ^ | |
363 | @kindex ^ @r{(Dired)} | |
364 | @findex dired-up-directory | |
365 | Visit the parent directory of the current directory | |
366 | (@code{dired-up-directory}). This is equivalent to moving to the line | |
367 | for @file{..} and typing @kbd{f} there. | |
368 | @end table | |
369 | ||
370 | @node Marks vs Flags | |
371 | @section Dired Marks vs. Flags | |
372 | ||
373 | @cindex marking many files (in Dired) | |
374 | Instead of flagging a file with @samp{D}, you can @dfn{mark} the | |
375 | file with some other character (usually @samp{*}). Most Dired | |
376 | commands to operate on files use the files marked with @samp{*}. The | |
fac6225b | 377 | only command that operates on flagged files is @kbd{x}, which deletes |
8cf51b2c GM |
378 | them. |
379 | ||
380 | Here are some commands for marking with @samp{*}, for unmarking, and | |
381 | for operating on marks. (@xref{Dired Deletion}, for commands to flag | |
382 | and unflag files.) | |
383 | ||
384 | @table @kbd | |
385 | @item m | |
386 | @itemx * m | |
387 | @kindex m @r{(Dired)} | |
388 | @kindex * m @r{(Dired)} | |
389 | @findex dired-mark | |
390 | Mark the current file with @samp{*} (@code{dired-mark}). With a numeric | |
391 | argument @var{n}, mark the next @var{n} files starting with the current | |
392 | file. (If @var{n} is negative, mark the previous @minus{}@var{n} | |
393 | files.) | |
394 | ||
395 | @item * * | |
396 | @kindex * * @r{(Dired)} | |
397 | @findex dired-mark-executables | |
398 | @cindex marking executable files (in Dired) | |
399 | Mark all executable files with @samp{*} | |
400 | (@code{dired-mark-executables}). With a numeric argument, unmark all | |
401 | those files. | |
402 | ||
403 | @item * @@ | |
404 | @kindex * @@ @r{(Dired)} | |
405 | @findex dired-mark-symlinks | |
406 | @cindex marking symbolic links (in Dired) | |
407 | Mark all symbolic links with @samp{*} (@code{dired-mark-symlinks}). | |
408 | With a numeric argument, unmark all those files. | |
409 | ||
410 | @item * / | |
411 | @kindex * / @r{(Dired)} | |
412 | @findex dired-mark-directories | |
413 | @cindex marking subdirectories (in Dired) | |
414 | Mark with @samp{*} all files which are directories, except for | |
415 | @file{.} and @file{..} (@code{dired-mark-directories}). With a numeric | |
416 | argument, unmark all those files. | |
417 | ||
418 | @item * s | |
419 | @kindex * s @r{(Dired)} | |
420 | @findex dired-mark-subdir-files | |
421 | Mark all the files in the current subdirectory, aside from @file{.} | |
422 | and @file{..} (@code{dired-mark-subdir-files}). | |
423 | ||
424 | @item u | |
425 | @itemx * u | |
426 | @kindex u @r{(Dired)} | |
427 | @kindex * u @r{(Dired)} | |
428 | @findex dired-unmark | |
429 | Remove any mark on this line (@code{dired-unmark}). | |
430 | ||
431 | @item @key{DEL} | |
432 | @itemx * @key{DEL} | |
433 | @kindex * DEL @r{(Dired)} | |
434 | @findex dired-unmark-backward | |
435 | @cindex unmarking files (in Dired) | |
436 | Move point to previous line and remove any mark on that line | |
437 | (@code{dired-unmark-backward}). | |
438 | ||
439 | @item * ! | |
440 | @itemx U | |
441 | @kindex * ! @r{(Dired)} | |
442 | @kindex U @r{(Dired)} | |
443 | @findex dired-unmark-all-marks | |
444 | Remove all marks from all the files in this Dired buffer | |
445 | (@code{dired-unmark-all-marks}). | |
446 | ||
447 | @item * ? @var{markchar} | |
448 | @itemx M-@key{DEL} | |
449 | @kindex * ? @r{(Dired)} | |
450 | @kindex M-DEL @r{(Dired)} | |
451 | @findex dired-unmark-all-files | |
452 | Remove all marks that use the character @var{markchar} | |
453 | (@code{dired-unmark-all-files}). The argument is a single | |
454 | character---do not use @key{RET} to terminate it. See the description | |
455 | of the @kbd{* c} command below, which lets you replace one mark | |
456 | character with another. | |
457 | ||
458 | With a numeric argument, this command queries about each marked file, | |
459 | asking whether to remove its mark. You can answer @kbd{y} meaning yes, | |
460 | @kbd{n} meaning no, or @kbd{!} to remove the marks from the remaining | |
461 | files without asking about them. | |
462 | ||
463 | @item * C-n | |
464 | @itemx M-@} | |
465 | @findex dired-next-marked-file | |
466 | @kindex * C-n @r{(Dired)} | |
467 | @kindex M-@} @r{(Dired)} | |
468 | Move down to the next marked file (@code{dired-next-marked-file}) | |
469 | A file is ``marked'' if it has any kind of mark. | |
470 | ||
471 | @item * C-p | |
472 | @itemx M-@{ | |
473 | @findex dired-prev-marked-file | |
474 | @kindex * C-p @r{(Dired)} | |
475 | @kindex M-@{ @r{(Dired)} | |
476 | Move up to the previous marked file (@code{dired-prev-marked-file}) | |
477 | ||
478 | @item t | |
479 | @itemx * t | |
480 | @kindex t @r{(Dired)} | |
481 | @kindex * t @r{(Dired)} | |
482 | @findex dired-toggle-marks | |
483 | @cindex toggling marks (in Dired) | |
484 | Toggle all marks (@code{dired-toggle-marks}): files marked with @samp{*} | |
485 | become unmarked, and unmarked files are marked with @samp{*}. Files | |
486 | marked in any other way are not affected. | |
487 | ||
488 | @item * c @var{old-markchar} @var{new-markchar} | |
489 | @kindex * c @r{(Dired)} | |
490 | @findex dired-change-marks | |
491 | Replace all marks that use the character @var{old-markchar} with marks | |
492 | that use the character @var{new-markchar} (@code{dired-change-marks}). | |
493 | This command is the primary way to create or use marks other than | |
494 | @samp{*} or @samp{D}. The arguments are single characters---do not use | |
495 | @key{RET} to terminate them. | |
496 | ||
497 | You can use almost any character as a mark character by means of this | |
498 | command, to distinguish various classes of files. If @var{old-markchar} | |
499 | is a space (@samp{ }), then the command operates on all unmarked files; | |
500 | if @var{new-markchar} is a space, then the command unmarks the files it | |
501 | acts on. | |
502 | ||
503 | To illustrate the power of this command, here is how to put @samp{D} | |
504 | flags on all the files that have no marks, while unflagging all those | |
505 | that already have @samp{D} flags: | |
506 | ||
507 | @example | |
508 | * c D t * c SPC D * c t SPC | |
509 | @end example | |
510 | ||
511 | This assumes that no files were already marked with @samp{t}. | |
512 | ||
513 | @item % m @var{regexp} @key{RET} | |
514 | @itemx * % @var{regexp} @key{RET} | |
515 | @findex dired-mark-files-regexp | |
516 | @kindex % m @r{(Dired)} | |
517 | @kindex * % @r{(Dired)} | |
518 | Mark (with @samp{*}) all files whose names match the regular expression | |
519 | @var{regexp} (@code{dired-mark-files-regexp}). This command is like | |
520 | @kbd{% d}, except that it marks files with @samp{*} instead of flagging | |
521 | with @samp{D}. | |
522 | ||
523 | Only the non-directory part of the file name is used in matching. Use | |
524 | @samp{^} and @samp{$} to anchor matches. You can exclude | |
525 | subdirectories by temporarily hiding them (@pxref{Hiding | |
526 | Subdirectories}). | |
527 | ||
528 | @item % g @var{regexp} @key{RET} | |
529 | @findex dired-mark-files-containing-regexp | |
530 | @kindex % g @r{(Dired)} | |
531 | @cindex finding files containing regexp matches (in Dired) | |
532 | Mark (with @samp{*}) all files whose @emph{contents} contain a match for | |
533 | the regular expression @var{regexp} | |
534 | (@code{dired-mark-files-containing-regexp}). This command is like | |
535 | @kbd{% m}, except that it searches the file contents instead of the file | |
536 | name. | |
537 | ||
c40a7de7 CY |
538 | @item C-/ |
539 | @itemx C-x u | |
8cf51b2c | 540 | @itemx C-_ |
8cf51b2c GM |
541 | @kindex C-_ @r{(Dired)} |
542 | @findex dired-undo | |
543 | Undo changes in the Dired buffer, such as adding or removing | |
544 | marks (@code{dired-undo}). @emph{This command does not revert the | |
545 | actual file operations, nor recover lost files!} It just undoes | |
546 | changes in the buffer itself. | |
547 | ||
548 | In some cases, using this after commands that operate on files can | |
549 | cause trouble. For example, after renaming one or more files, | |
550 | @code{dired-undo} restores the original names in the Dired buffer, | |
551 | which gets the Dired buffer out of sync with the actual contents of | |
552 | the directory. | |
553 | @end table | |
554 | ||
555 | @node Operating on Files | |
556 | @section Operating on Files | |
557 | @cindex operating on files in Dired | |
558 | ||
559 | This section describes the basic Dired commands to operate on one file | |
560 | or several files. All of these commands are capital letters; all of | |
561 | them use the minibuffer, either to read an argument or to ask for | |
562 | confirmation, before they act. All of them let you specify the | |
563 | files to manipulate in these ways: | |
564 | ||
565 | @itemize @bullet | |
566 | @item | |
567 | If you give the command a numeric prefix argument @var{n}, it operates | |
568 | on the next @var{n} files, starting with the current file. (If @var{n} | |
569 | is negative, the command operates on the @minus{}@var{n} files preceding | |
570 | the current line.) | |
571 | ||
572 | @item | |
573 | Otherwise, if some files are marked with @samp{*}, the command operates | |
574 | on all those files. | |
575 | ||
576 | @item | |
577 | Otherwise, the command operates on the current file only. | |
578 | @end itemize | |
579 | ||
580 | @noindent | |
581 | Certain other Dired commands, such as @kbd{!} and the @samp{%} | |
582 | commands, use the same conventions to decide which files to work on. | |
583 | ||
584 | @vindex dired-dwim-target | |
585 | @cindex two directories (in Dired) | |
586 | Commands which ask for a destination directory, such as those which | |
587 | copy and rename files or create links for them, try to guess the default | |
588 | target directory for the operation. Normally, they suggest the Dired | |
589 | buffer's default directory, but if the variable @code{dired-dwim-target} | |
590 | is non-@code{nil}, and if there is another Dired buffer displayed in the | |
591 | next window, that other buffer's directory is suggested instead. | |
592 | ||
593 | Here are the file-manipulating Dired commands that operate on files. | |
594 | ||
595 | @table @kbd | |
596 | @findex dired-do-copy | |
597 | @kindex C @r{(Dired)} | |
598 | @cindex copying files (in Dired) | |
599 | @item C @var{new} @key{RET} | |
600 | Copy the specified files (@code{dired-do-copy}). The argument @var{new} | |
601 | is the directory to copy into, or (if copying a single file) the new | |
602 | name. This is like the shell command @code{cp}. | |
603 | ||
604 | @vindex dired-copy-preserve-time | |
605 | If @code{dired-copy-preserve-time} is non-@code{nil}, then copying | |
606 | with this command preserves the modification time of the old file in | |
607 | the copy, like @samp{cp -p}. | |
608 | ||
609 | @vindex dired-recursive-copies | |
610 | @cindex recursive copying | |
611 | The variable @code{dired-recursive-copies} controls whether to copy | |
612 | directories recursively (like @samp{cp -r}). The default is | |
2bfab837 | 613 | @code{top}, which means to ask before recursively copying a directory. |
8cf51b2c GM |
614 | |
615 | @item D | |
616 | @findex dired-do-delete | |
617 | @kindex D @r{(Dired)} | |
618 | Delete the specified files (@code{dired-do-delete}). This is like the | |
619 | shell command @code{rm}. | |
620 | ||
621 | Like the other commands in this section, this command operates on the | |
622 | @emph{marked} files, or the next @var{n} files. By contrast, @kbd{x} | |
623 | (@code{dired-do-flagged-delete}) deletes all @dfn{flagged} files. | |
624 | ||
625 | @findex dired-do-rename | |
626 | @kindex R @r{(Dired)} | |
627 | @cindex renaming files (in Dired) | |
628 | @cindex moving files (in Dired) | |
629 | @item R @var{new} @key{RET} | |
630 | Rename the specified files (@code{dired-do-rename}). If you rename a | |
631 | single file, the argument @var{new} is the new name of the file. If | |
632 | you rename several files, the argument @var{new} is the directory into | |
c40a7de7 | 633 | which to move the files (this is like the shell command @command{mv}). |
8cf51b2c GM |
634 | |
635 | Dired automatically changes the visited file name of buffers associated | |
636 | with renamed files so that they refer to the new names. | |
637 | ||
638 | @findex dired-do-hardlink | |
639 | @kindex H @r{(Dired)} | |
640 | @cindex hard links (in Dired) | |
641 | @item H @var{new} @key{RET} | |
642 | Make hard links to the specified files (@code{dired-do-hardlink}). | |
c40a7de7 | 643 | This is like the shell command @command{ln}. The argument @var{new} is |
8cf51b2c GM |
644 | the directory to make the links in, or (if making just one link) the |
645 | name to give the link. | |
646 | ||
647 | @findex dired-do-symlink | |
648 | @kindex S @r{(Dired)} | |
649 | @cindex symbolic links (creation in Dired) | |
650 | @item S @var{new} @key{RET} | |
651 | Make symbolic links to the specified files (@code{dired-do-symlink}). | |
652 | This is like @samp{ln -s}. The argument @var{new} is the directory to | |
653 | make the links in, or (if making just one link) the name to give the | |
654 | link. | |
655 | ||
656 | @findex dired-do-chmod | |
657 | @kindex M @r{(Dired)} | |
658 | @cindex changing file permissions (in Dired) | |
659 | @item M @var{modespec} @key{RET} | |
c40a7de7 CY |
660 | Change the mode (also called @dfn{permission bits}) of the specified |
661 | files (@code{dired-do-chmod}). @var{modespec} can be in octal or | |
662 | symbolic notation, like arguments handled by the @command{chmod} | |
663 | program. | |
8cf51b2c GM |
664 | |
665 | @findex dired-do-chgrp | |
666 | @kindex G @r{(Dired)} | |
667 | @cindex changing file group (in Dired) | |
668 | @item G @var{newgroup} @key{RET} | |
669 | Change the group of the specified files to @var{newgroup} | |
670 | (@code{dired-do-chgrp}). | |
671 | ||
672 | @findex dired-do-chown | |
673 | @kindex O @r{(Dired)} | |
674 | @cindex changing file owner (in Dired) | |
675 | @item O @var{newowner} @key{RET} | |
676 | Change the owner of the specified files to @var{newowner} | |
677 | (@code{dired-do-chown}). (On most systems, only the superuser can do | |
678 | this.) | |
679 | ||
680 | @vindex dired-chown-program | |
681 | The variable @code{dired-chown-program} specifies the name of the | |
c40a7de7 CY |
682 | program to use to do the work (different systems put @command{chown} |
683 | in different places). | |
8cf51b2c GM |
684 | |
685 | @findex dired-do-touch | |
686 | @kindex T @r{(Dired)} | |
687 | @cindex changing file time (in Dired) | |
688 | @item T @var{timestamp} @key{RET} | |
689 | Touch the specified files (@code{dired-do-touch}). This means | |
690 | updating their modification times to the present time. This is like | |
691 | the shell command @code{touch}. | |
692 | ||
693 | @findex dired-do-print | |
694 | @kindex P @r{(Dired)} | |
695 | @cindex printing files (in Dired) | |
696 | @item P @var{command} @key{RET} | |
697 | Print the specified files (@code{dired-do-print}). You must specify the | |
698 | command to print them with, but the minibuffer starts out with a | |
699 | suitable guess made using the variables @code{lpr-command} and | |
700 | @code{lpr-switches} (the same variables that @code{lpr-buffer} uses; | |
701 | @pxref{Printing}). | |
702 | ||
703 | @findex dired-do-compress | |
704 | @kindex Z @r{(Dired)} | |
705 | @cindex compressing files (in Dired) | |
706 | @item Z | |
707 | Compress the specified files (@code{dired-do-compress}). If the file | |
708 | appears to be a compressed file already, uncompress it instead. | |
709 | ||
86d7a550 DU |
710 | @findex epa-dired-do-decrypt |
711 | @kindex :d @r{(Dired)} | |
712 | @cindex decrypting files (in Dired) | |
713 | @item :d | |
714 | Decrypt the specified files (@code{epa-dired-do-decrypt}). | |
715 | @xref{Dired integration,,, epa, EasyPG Assistant User's Manual}. | |
716 | ||
717 | @findex epa-dired-do-verify | |
718 | @kindex :v @r{(Dired)} | |
719 | @cindex verifying digital signatures on files (in Dired) | |
720 | @item :v | |
721 | Verify digital signatures on the specified files (@code{epa-dired-do-verify}). | |
722 | @xref{Dired integration,,, epa, EasyPG Assistant User's Manual}. | |
723 | ||
724 | @findex epa-dired-do-sign | |
725 | @kindex :s @r{(Dired)} | |
726 | @cindex signing files (in Dired) | |
727 | @item :s | |
728 | Digitally sign the specified files (@code{epa-dired-do-sign}). | |
729 | @xref{Dired integration,,, epa, EasyPG Assistant User's Manual}. | |
730 | ||
731 | @findex epa-dired-do-encrypt | |
732 | @kindex :e @r{(Dired)} | |
733 | @cindex encrypting files (in Dired) | |
734 | @item :e | |
735 | Encrypt the specified files (@code{epa-dired-do-encrypt}). | |
736 | @xref{Dired integration,,, epa, EasyPG Assistant User's Manual}. | |
737 | ||
8cf51b2c GM |
738 | @findex dired-do-load |
739 | @kindex L @r{(Dired)} | |
740 | @cindex loading several files (in Dired) | |
741 | @item L | |
742 | Load the specified Emacs Lisp files (@code{dired-do-load}). | |
743 | @xref{Lisp Libraries}. | |
744 | ||
745 | @findex dired-do-byte-compile | |
746 | @kindex B @r{(Dired)} | |
747 | @cindex byte-compiling several files (in Dired) | |
748 | @item B | |
749 | Byte compile the specified Emacs Lisp files | |
750 | (@code{dired-do-byte-compile}). @xref{Byte Compilation,, Byte | |
751 | Compilation, elisp, The Emacs Lisp Reference Manual}. | |
752 | ||
753 | @kindex A @r{(Dired)} | |
754 | @findex dired-do-search | |
755 | @cindex search multiple files (in Dired) | |
756 | @item A @var{regexp} @key{RET} | |
757 | Search all the specified files for the regular expression @var{regexp} | |
758 | (@code{dired-do-search}). | |
759 | ||
760 | This command is a variant of @code{tags-search}. The search stops at | |
761 | the first match it finds; use @kbd{M-,} to resume the search and find | |
762 | the next match. @xref{Tags Search}. | |
763 | ||
764 | @kindex Q @r{(Dired)} | |
765 | @findex dired-do-query-replace-regexp | |
766 | @cindex search and replace in multiple files (in Dired) | |
767 | @item Q @var{regexp} @key{RET} @var{to} @key{RET} | |
768 | Perform @code{query-replace-regexp} on each of the specified files, | |
769 | replacing matches for @var{regexp} with the string | |
770 | @var{to} (@code{dired-do-query-replace-regexp}). | |
771 | ||
772 | This command is a variant of @code{tags-query-replace}. If you exit the | |
773 | query replace loop, you can use @kbd{M-,} to resume the scan and replace | |
774 | more matches. @xref{Tags Search}. | |
775 | @end table | |
776 | ||
777 | @node Shell Commands in Dired | |
778 | @section Shell Commands in Dired | |
779 | @cindex shell commands, Dired | |
780 | ||
781 | @findex dired-do-shell-command | |
782 | @kindex ! @r{(Dired)} | |
783 | @kindex X @r{(Dired)} | |
784 | The Dired command @kbd{!} (@code{dired-do-shell-command}) reads a | |
785 | shell command string in the minibuffer and runs that shell command on | |
fac6225b CY |
786 | one or more files. The files that the shell command operates on are |
787 | determined in the usual way for Dired commands (@pxref{Operating on | |
788 | Files}). The command @kbd{X} is a synonym for @kbd{!}. | |
8cf51b2c | 789 | |
fac6225b CY |
790 | The command @kbd{&} (@code{dired-do-async-shell-command}) does the |
791 | same, except that it runs the shell command asynchronously. You can | |
792 | also do this with @kbd{!}, by appending a @samp{&} character to the | |
793 | end of the shell command. | |
8cf51b2c | 794 | |
fac6225b CY |
795 | For both @kbd{!} and @kbd{&}, the working directory for the shell |
796 | command is the top-level directory of the Dired buffer. | |
797 | ||
798 | If you tell @kbd{!} or @kbd{&} to operate on more than one file, the | |
799 | shell command string determines how those files are passed to the | |
800 | shell command: | |
8cf51b2c GM |
801 | |
802 | @itemize @bullet | |
803 | @item | |
fac6225b | 804 | If you use @samp{*} surrounded by whitespace in the command string, |
8cf51b2c GM |
805 | then the command runs just once, with the list of file names |
806 | substituted for the @samp{*}. The order of file names is the order of | |
807 | appearance in the Dired buffer. | |
808 | ||
809 | Thus, @kbd{! tar cf foo.tar * @key{RET}} runs @code{tar} on the entire | |
810 | list of file names, putting them into one tar file @file{foo.tar}. | |
811 | ||
812 | If you want to use @samp{*} as a shell wildcard with whitespace around | |
813 | it, write @samp{*""}. In the shell, this is equivalent to @samp{*}; | |
fac6225b CY |
814 | but since the @samp{*} is not surrounded by whitespace, Dired does not |
815 | treat it specially. | |
8cf51b2c GM |
816 | |
817 | @item | |
fac6225b CY |
818 | Otherwise, if the command string contains @samp{?} surrounded by |
819 | whitespace, Emacs runs the shell command once @emph{for each file}, | |
820 | substituting the current file name for @samp{?} each time. You can | |
821 | use @samp{?} more than once in the command; the same file name | |
822 | replaces each occurrence. | |
8cf51b2c GM |
823 | |
824 | @item | |
fac6225b | 825 | If the command string contains neither @samp{*} nor @samp{?}, Emacs |
9805f81d DM |
826 | runs the shell command once for each file, adding the file name at the |
827 | end. For example, @kbd{! uudecode @key{RET}} runs @code{uudecode} on | |
828 | each file. | |
8cf51b2c GM |
829 | @end itemize |
830 | ||
831 | To iterate over the file names in a more complicated fashion, use an | |
832 | explicit shell loop. For example, here is how to uuencode each file, | |
833 | making the output file name by appending @samp{.uu} to the input file | |
834 | name: | |
835 | ||
836 | @example | |
837 | for file in * ; do uuencode "$file" "$file" >"$file".uu; done | |
838 | @end example | |
839 | ||
fac6225b CY |
840 | The @kbd{!} and @kbd{&} commands do not attempt to update the Dired |
841 | buffer to show new or modified files, because they don't know what | |
842 | files will be changed. Use the @kbd{g} command to update the Dired | |
843 | buffer (@pxref{Dired Updating}). | |
844 | ||
845 | @xref{Single Shell}, for information about running shell commands | |
846 | outside Dired. | |
8cf51b2c GM |
847 | |
848 | @node Transforming File Names | |
849 | @section Transforming File Names in Dired | |
850 | ||
851 | This section describes Dired commands which alter file names in a | |
852 | systematic way. Each command operates on some or all of the marked | |
853 | files, using a new name made by transforming the existing name. | |
854 | ||
855 | Like the basic Dired file-manipulation commands (@pxref{Operating on | |
856 | Files}), the commands described here operate either on the next | |
857 | @var{n} files, or on all files marked with @samp{*}, or on the current | |
858 | file. (To mark files, use the commands described in @ref{Marks vs | |
859 | Flags}.) | |
860 | ||
861 | All of the commands described in this section work | |
862 | @emph{interactively}: they ask you to confirm the operation for each | |
863 | candidate file. Thus, you can select more files than you actually | |
864 | need to operate on (e.g., with a regexp that matches many files), and | |
865 | then filter the selected names by typing @kbd{y} or @kbd{n} when the | |
866 | command prompts for confirmation. | |
867 | ||
868 | @table @kbd | |
869 | @findex dired-upcase | |
870 | @kindex % u @r{(Dired)} | |
871 | @cindex upcase file names | |
872 | @item % u | |
873 | Rename each of the selected files to an upper-case name | |
874 | (@code{dired-upcase}). If the old file names are @file{Foo} | |
875 | and @file{bar}, the new names are @file{FOO} and @file{BAR}. | |
876 | ||
877 | @item % l | |
878 | @findex dired-downcase | |
879 | @kindex % l @r{(Dired)} | |
880 | @cindex downcase file names | |
881 | Rename each of the selected files to a lower-case name | |
882 | (@code{dired-downcase}). If the old file names are @file{Foo} and | |
883 | @file{bar}, the new names are @file{foo} and @file{bar}. | |
884 | ||
885 | @item % R @var{from} @key{RET} @var{to} @key{RET} | |
886 | @kindex % R @r{(Dired)} | |
887 | @findex dired-do-rename-regexp | |
888 | @itemx % C @var{from} @key{RET} @var{to} @key{RET} | |
889 | @kindex % C @r{(Dired)} | |
890 | @findex dired-do-copy-regexp | |
891 | @itemx % H @var{from} @key{RET} @var{to} @key{RET} | |
892 | @kindex % H @r{(Dired)} | |
893 | @findex dired-do-hardlink-regexp | |
894 | @itemx % S @var{from} @key{RET} @var{to} @key{RET} | |
895 | @kindex % S @r{(Dired)} | |
896 | @findex dired-do-symlink-regexp | |
897 | These four commands rename, copy, make hard links and make soft links, | |
898 | in each case computing the new name by regular-expression substitution | |
899 | from the name of the old file. | |
900 | @end table | |
901 | ||
902 | The four regular-expression substitution commands effectively | |
903 | perform a search-and-replace on the selected file names. They read | |
904 | two arguments: a regular expression @var{from}, and a substitution | |
905 | pattern @var{to}; they match each ``old'' file name against | |
906 | @var{from}, and then replace the matching part with @var{to}. You can | |
907 | use @samp{\&} and @samp{\@var{digit}} in @var{to} to refer to all or | |
908 | part of what the pattern matched in the old file name, as in | |
909 | @code{replace-regexp} (@pxref{Regexp Replace}). If the regular | |
910 | expression matches more than once in a file name, only the first match | |
911 | is replaced. | |
912 | ||
913 | For example, @kbd{% R ^.*$ @key{RET} x-\& @key{RET}} renames each | |
914 | selected file by prepending @samp{x-} to its name. The inverse of this, | |
915 | removing @samp{x-} from the front of each file name, is also possible: | |
916 | one method is @kbd{% R ^x-\(.*\)$ @key{RET} \1 @key{RET}}; another is | |
917 | @kbd{% R ^x- @key{RET} @key{RET}}. (Use @samp{^} and @samp{$} to anchor | |
918 | matches that should span the whole file name.) | |
919 | ||
920 | Normally, the replacement process does not consider the files' | |
921 | directory names; it operates on the file name within the directory. If | |
922 | you specify a numeric argument of zero, then replacement affects the | |
923 | entire absolute file name including directory name. (A non-zero | |
924 | argument specifies the number of files to operate on.) | |
925 | ||
926 | You may want to select the set of files to operate on using the same | |
927 | regexp @var{from} that you will use to operate on them. To do this, | |
928 | mark those files with @kbd{% m @var{from} @key{RET}}, then use the | |
929 | same regular expression in the command to operate on the files. To | |
930 | make this more convenient, the @kbd{%} commands to operate on files | |
931 | use the last regular expression specified in any @kbd{%} command as a | |
932 | default. | |
933 | ||
934 | @node Comparison in Dired | |
935 | @section File Comparison with Dired | |
936 | @cindex file comparison (in Dired) | |
937 | @cindex compare files (in Dired) | |
938 | ||
939 | Here are two Dired commands that compare specified files using | |
940 | @code{diff}. They show the output in a buffer using Diff mode | |
941 | (@pxref{Comparing Files}). | |
942 | ||
943 | @table @kbd | |
944 | @item = | |
945 | @findex dired-diff | |
946 | @kindex = @r{(Dired)} | |
947 | Compare the current file (the file at point) with another file (the | |
948 | file at the mark) using the @code{diff} program (@code{dired-diff}). | |
949 | The file at the mark is the first argument of @code{diff}, and the | |
950 | file at point is the second argument. This refers to the ordinary | |
951 | Emacs mark, not Dired marks; use @kbd{C-@key{SPC}} | |
952 | (@code{set-mark-command}) to set the mark at the first file's line | |
953 | (@pxref{Setting Mark}). | |
954 | ||
955 | @findex dired-backup-diff | |
956 | @kindex M-= @r{(Dired)} | |
957 | @item M-= | |
958 | Compare the current file with its latest backup file | |
959 | (@code{dired-backup-diff}). If the current file is itself a backup, | |
960 | compare it with the file it is a backup of; this way, you can compare | |
961 | a file with any one of its backups. | |
962 | ||
963 | The backup file is the first file given to @code{diff}. | |
964 | @end table | |
965 | ||
966 | @node Subdirectories in Dired | |
967 | @section Subdirectories in Dired | |
968 | @cindex subdirectories in Dired | |
969 | @cindex expanding subdirectories in Dired | |
970 | ||
c40a7de7 CY |
971 | A Dired buffer usually displays just one directory, but you can |
972 | optionally include its subdirectories as well. | |
8cf51b2c GM |
973 | |
974 | The simplest way to include multiple directories in one Dired buffer is | |
c40a7de7 | 975 | to specify the options @samp{-lR} for running @command{ls}. (If you give a |
8cf51b2c GM |
976 | numeric argument when you run Dired, then you can specify these options |
977 | in the minibuffer.) That produces a recursive directory listing showing | |
978 | all subdirectories at all levels. | |
979 | ||
980 | More often, you will want to show only specific subdirectories. You | |
c40a7de7 | 981 | can do this with @kbd{i} (@code{dired-maybe-insert-subdir}): |
8cf51b2c GM |
982 | |
983 | @table @kbd | |
984 | @findex dired-maybe-insert-subdir | |
985 | @kindex i @r{(Dired)} | |
986 | @item i | |
987 | @cindex inserted subdirectory (Dired) | |
988 | @cindex in-situ subdirectory (Dired) | |
989 | Insert the contents of a subdirectory later in the buffer. | |
990 | @end table | |
991 | ||
c40a7de7 CY |
992 | @noindent |
993 | If you use this command on a line that describes a file which is a | |
994 | directory, it inserts the contents of that directory into the same | |
995 | Dired buffer, and moves there. Inserted subdirectory contents follow | |
996 | the top-level directory of the Dired buffer, just as they do in | |
997 | @samp{ls -lR} output. | |
998 | ||
999 | If the subdirectory's contents are already present in the buffer, | |
1000 | the @kbd{i} command just moves to it. | |
1001 | ||
1002 | In either case, @kbd{i} sets the Emacs mark before moving, so | |
1003 | @kbd{C-u C-@key{SPC}} returns to your previous position in the Dired | |
1004 | buffer (@pxref{Setting Mark}). You can also use @samp{^} to return to | |
1005 | the parent directory in the same Dired buffer (@pxref{Dired | |
1006 | Visiting}). | |
1007 | ||
1008 | Use the @kbd{l} command (@code{dired-do-redisplay}) to update the | |
1009 | subdirectory's contents, and use @kbd{C-u k} on the subdirectory | |
1010 | header line to remove the subdirectory listing (@pxref{Dired | |
1011 | Updating}). You can also hide and show inserted subdirectories | |
1012 | (@pxref{Hiding Subdirectories}). | |
8cf51b2c | 1013 | |
8cf51b2c GM |
1014 | @ifnottex |
1015 | @include dired-xtra.texi | |
1016 | @end ifnottex | |
1017 | ||
1018 | @node Subdirectory Motion | |
1019 | @section Moving Over Subdirectories | |
1020 | ||
1021 | When a Dired buffer lists subdirectories, you can use the page motion | |
1022 | commands @kbd{C-x [} and @kbd{C-x ]} to move by entire directories | |
1023 | (@pxref{Pages}). | |
1024 | ||
1025 | @cindex header line (Dired) | |
1026 | @cindex directory header lines | |
1027 | The following commands move across, up and down in the tree of | |
1028 | directories within one Dired buffer. They move to @dfn{directory header | |
1029 | lines}, which are the lines that give a directory's name, at the | |
1030 | beginning of the directory's contents. | |
1031 | ||
1032 | @table @kbd | |
1033 | @findex dired-next-subdir | |
1034 | @kindex C-M-n @r{(Dired)} | |
1035 | @item C-M-n | |
1036 | Go to next subdirectory header line, regardless of level | |
1037 | (@code{dired-next-subdir}). | |
1038 | ||
1039 | @findex dired-prev-subdir | |
1040 | @kindex C-M-p @r{(Dired)} | |
1041 | @item C-M-p | |
1042 | Go to previous subdirectory header line, regardless of level | |
1043 | (@code{dired-prev-subdir}). | |
1044 | ||
1045 | @findex dired-tree-up | |
1046 | @kindex C-M-u @r{(Dired)} | |
1047 | @item C-M-u | |
1048 | Go up to the parent directory's header line (@code{dired-tree-up}). | |
1049 | ||
1050 | @findex dired-tree-down | |
1051 | @kindex C-M-d @r{(Dired)} | |
1052 | @item C-M-d | |
1053 | Go down in the directory tree, to the first subdirectory's header line | |
1054 | (@code{dired-tree-down}). | |
1055 | ||
1056 | @findex dired-prev-dirline | |
1057 | @kindex < @r{(Dired)} | |
1058 | @item < | |
1059 | Move up to the previous directory-file line (@code{dired-prev-dirline}). | |
1060 | These lines are the ones that describe a directory as a file in its | |
1061 | parent directory. | |
1062 | ||
1063 | @findex dired-next-dirline | |
1064 | @kindex > @r{(Dired)} | |
1065 | @item > | |
1066 | Move down to the next directory-file line (@code{dired-prev-dirline}). | |
1067 | @end table | |
1068 | ||
1069 | @node Hiding Subdirectories | |
1070 | @section Hiding Subdirectories | |
8b74f389 BG |
1071 | @cindex hiding subdirectories (Dired) |
1072 | @cindex showing hidden subdirectories (Dired) | |
8cf51b2c | 1073 | |
8cf51b2c GM |
1074 | @dfn{Hiding} a subdirectory means to make it invisible, except for its |
1075 | header line. | |
1076 | ||
1077 | @table @kbd | |
1078 | @item $ | |
1079 | @findex dired-hide-subdir | |
1080 | @kindex $ @r{(Dired)} | |
8b74f389 BG |
1081 | Hide or show the subdirectory that point is in, and move point to the |
1082 | next subdirectory (@code{dired-hide-subdir}). This is a toggle. A | |
1083 | numeric argument serves as a repeat count. | |
8cf51b2c GM |
1084 | |
1085 | @item M-$ | |
1086 | @findex dired-hide-all | |
1087 | @kindex M-$ @r{(Dired)} | |
1088 | Hide all subdirectories in this Dired buffer, leaving only their header | |
1089 | lines (@code{dired-hide-all}). Or, if any subdirectory is currently | |
1090 | hidden, make all subdirectories visible again. You can use this command | |
1091 | to get an overview in very deep directory trees or to move quickly to | |
1092 | subdirectories far away. | |
1093 | @end table | |
1094 | ||
1095 | Ordinary Dired commands never consider files inside a hidden | |
1096 | subdirectory. For example, the commands to operate on marked files | |
1097 | ignore files in hidden directories even if they are marked. Thus you | |
1098 | can use hiding to temporarily exclude subdirectories from operations | |
1099 | without having to remove the Dired marks on files in those | |
1100 | subdirectories. | |
1101 | ||
e3e0fb39 | 1102 | @xref{Dired Updating}, for how to insert or delete a subdirectory listing. |
8b74f389 | 1103 | |
8cf51b2c GM |
1104 | @node Dired Updating |
1105 | @section Updating the Dired Buffer | |
1106 | @cindex updating Dired buffer | |
1107 | @cindex refreshing displayed files | |
1108 | ||
1109 | This section describes commands to update the Dired buffer to reflect | |
1110 | outside (non-Dired) changes in the directories and files, and to delete | |
1111 | part of the Dired buffer. | |
1112 | ||
1113 | @table @kbd | |
1114 | @item g | |
1115 | Update the entire contents of the Dired buffer (@code{revert-buffer}). | |
1116 | ||
1117 | @item l | |
1118 | Update the specified files (@code{dired-do-redisplay}). You specify the | |
1119 | files for @kbd{l} in the same way as for file operations. | |
1120 | ||
1121 | @item k | |
1122 | Delete the specified @emph{file lines}---not the files, just the lines | |
1123 | (@code{dired-do-kill-lines}). | |
1124 | ||
1125 | @item s | |
1126 | Toggle between alphabetical order and date/time order | |
1127 | (@code{dired-sort-toggle-or-edit}). | |
1128 | ||
1129 | @item C-u s @var{switches} @key{RET} | |
1130 | Refresh the Dired buffer using @var{switches} as | |
1131 | @code{dired-listing-switches}. | |
1132 | @end table | |
1133 | ||
1134 | @kindex g @r{(Dired)} | |
1135 | @findex revert-buffer @r{(Dired)} | |
1136 | Type @kbd{g} (@code{revert-buffer}) to update the contents of the | |
1137 | Dired buffer, based on changes in the files and directories listed. | |
1138 | This preserves all marks except for those on files that have vanished. | |
1139 | Hidden subdirectories are updated but remain hidden. | |
1140 | ||
1141 | @kindex l @r{(Dired)} | |
1142 | @findex dired-do-redisplay | |
1143 | To update only some of the files, type @kbd{l} | |
1144 | (@code{dired-do-redisplay}). Like the Dired file-operating commands, | |
1145 | this command operates on the next @var{n} files (or previous | |
1146 | @minus{}@var{n} files), or on the marked files if any, or on the | |
1147 | current file. Updating the files means reading their current status, | |
1148 | then updating their lines in the buffer to indicate that status. | |
1149 | ||
1150 | If you use @kbd{l} on a subdirectory header line, it updates the | |
1151 | contents of the corresponding subdirectory. | |
1152 | ||
4102856c CY |
1153 | @vindex dired-auto-revert-buffer |
1154 | If you use @kbd{C-x d} or some other Dired command to visit a | |
1155 | directory that is already being shown in a Dired buffer, Dired | |
1156 | switches to that buffer but does not update it. If the buffer is not | |
1157 | up-to-date, Dired displays a warning telling you to type @key{g} to | |
1158 | update it. You can also tell Emacs to revert each Dired buffer | |
1159 | automatically when you revisit it, by setting the variable | |
1160 | @code{dired-auto-revert-buffer} to a non-@code{nil} value. | |
1161 | ||
8cf51b2c GM |
1162 | @kindex k @r{(Dired)} |
1163 | @findex dired-do-kill-lines | |
1164 | To delete the specified @emph{file lines} from the buffer---not | |
1165 | delete the files---type @kbd{k} (@code{dired-do-kill-lines}). Like | |
1166 | the file-operating commands, this command operates on the next @var{n} | |
1167 | files, or on the marked files if any; but it does not operate on the | |
1168 | current file as a last resort. | |
1169 | ||
1170 | If you use @kbd{k} with a numeric prefix argument to kill the line | |
1171 | for a file that is a directory, which you have inserted in the Dired | |
ff9ad330 LMI |
1172 | buffer as a subdirectory, it removed that subdirectory line from the |
1173 | buffer as well. Typing @kbd{C-u k} on the header line for a | |
1174 | subdirectory also removes the subdirectory line from the Dired buffer. | |
8cf51b2c GM |
1175 | |
1176 | The @kbd{g} command brings back any individual lines that you have | |
1177 | killed in this way, but not subdirectories---you must use @kbd{i} to | |
1178 | reinsert a subdirectory. | |
1179 | ||
1180 | @cindex Dired sorting | |
1181 | @cindex sorting Dired buffer | |
1182 | @kindex s @r{(Dired)} | |
1183 | @findex dired-sort-toggle-or-edit | |
1184 | The files in a Dired buffers are normally listed in alphabetical order | |
1185 | by file names. Alternatively Dired can sort them by date/time. The | |
1186 | Dired command @kbd{s} (@code{dired-sort-toggle-or-edit}) switches | |
1187 | between these two sorting modes. The mode line in a Dired buffer | |
1188 | indicates which way it is currently sorted---by name, or by date. | |
1189 | ||
1190 | @kbd{C-u s @var{switches} @key{RET}} lets you specify a new value for | |
1191 | @code{dired-listing-switches}. | |
1192 | ||
1193 | @node Dired and Find | |
1194 | @section Dired and @code{find} | |
1195 | @cindex @code{find} and Dired | |
1196 | ||
1197 | You can select a set of files for display in a Dired buffer more | |
fac6225b | 1198 | flexibly by using the @command{find} utility to choose the files. |
8cf51b2c GM |
1199 | |
1200 | @findex find-name-dired | |
1201 | To search for files with names matching a wildcard pattern use | |
1202 | @kbd{M-x find-name-dired}. It reads arguments @var{directory} and | |
1203 | @var{pattern}, and chooses all the files in @var{directory} or its | |
1204 | subdirectories whose individual names match @var{pattern}. | |
1205 | ||
1206 | The files thus chosen are displayed in a Dired buffer, in which the | |
1207 | ordinary Dired commands are available. | |
1208 | ||
1209 | @findex find-grep-dired | |
1210 | If you want to test the contents of files, rather than their names, | |
1211 | use @kbd{M-x find-grep-dired}. This command reads two minibuffer | |
fac6225b CY |
1212 | arguments, @var{directory} and @var{regexp}; it chooses all the files |
1213 | in @var{directory} or its subdirectories that contain a match for | |
1214 | @var{regexp}. It works by running the programs @command{find} and | |
1215 | @command{grep}. See also @kbd{M-x grep-find}, in @ref{Grep | |
1216 | Searching}. Remember to write the regular expression for | |
1217 | @command{grep}, not for Emacs. (An alternative method of showing | |
1218 | files whose contents match a given regexp is the @kbd{% g | |
1219 | @var{regexp}} command, see @ref{Marks vs Flags}.) | |
8cf51b2c GM |
1220 | |
1221 | @findex find-dired | |
fac6225b CY |
1222 | The most general command in this series is @kbd{M-x find-dired}, |
1223 | which lets you specify any condition that @command{find} can test. It | |
1224 | takes two minibuffer arguments, @var{directory} and @var{find-args}; | |
1225 | it runs @command{find} in @var{directory}, passing @var{find-args} to | |
1226 | tell @command{find} what condition to test. To use this command, you | |
1227 | need to know how to use @command{find}. | |
8cf51b2c GM |
1228 | |
1229 | @vindex find-ls-option | |
c40a7de7 | 1230 | The format of listing produced by these commands is controlled by |
e517eda4 GM |
1231 | the variable @code{find-ls-option}. This is a pair of options; the |
1232 | first specifying how to call @command{find} to produce the file listing, | |
1233 | and the second telling Dired to parse the output. | |
8cf51b2c GM |
1234 | |
1235 | @findex locate | |
1236 | @findex locate-with-filter | |
1237 | @cindex file database (locate) | |
1238 | @vindex locate-command | |
1239 | The command @kbd{M-x locate} provides a similar interface to the | |
fac6225b | 1240 | @command{locate} program. @kbd{M-x locate-with-filter} is similar, but |
8cf51b2c GM |
1241 | keeps only files whose names match a given regular expression. |
1242 | ||
1243 | These buffers don't work entirely like ordinary Dired buffers: file | |
1244 | operations work, but do not always automatically update the buffer. | |
1245 | Reverting the buffer with @kbd{g} deletes all inserted subdirectories, | |
1246 | and erases all flags and marks. | |
1247 | ||
1248 | @node Wdired | |
1249 | @section Editing the Dired Buffer | |
1250 | ||
1251 | @cindex wdired mode | |
1252 | @findex wdired-change-to-wdired-mode | |
1253 | Wdired is a special mode that allows you to perform file operations | |
1254 | by editing the Dired buffer directly (the ``W'' in ``Wdired'' stands | |
16152b76 | 1255 | for ``writable''.) To enter Wdired mode, type @kbd{C-x C-q} |
fac6225b CY |
1256 | (@code{dired-toggle-read-only}) while in a Dired buffer. |
1257 | Alternatively, use the @samp{Immediate / Edit File Names} menu item. | |
8cf51b2c GM |
1258 | |
1259 | @findex wdired-finish-edit | |
1260 | While in Wdired mode, you can rename files by editing the file names | |
1261 | displayed in the Dired buffer. All the ordinary Emacs editing | |
1262 | commands, including rectangle operations and @code{query-replace}, are | |
1263 | available for this. Once you are done editing, type @kbd{C-c C-c} | |
1264 | (@code{wdired-finish-edit}). This applies your changes and switches | |
1265 | back to ordinary Dired mode. | |
1266 | ||
1267 | Apart from simply renaming files, you can move a file to another | |
1268 | directory by typing in the new file name (either absolute or | |
1269 | relative). To mark a file for deletion, delete the entire file name. | |
1270 | To change the target of a symbolic link, edit the link target name | |
1271 | which appears next to the link name. | |
1272 | ||
1273 | The rest of the text in the buffer, such as the file sizes and | |
1274 | modification dates, is marked read-only, so you can't edit it. | |
1275 | However, if you set @code{wdired-allow-to-change-permissions} to | |
1276 | @code{t}, you can edit the file permissions. For example, you can | |
1277 | change @samp{-rw-r--r--} to @samp{-rw-rw-rw-} to make a file | |
1278 | world-writable. These changes also take effect when you type @kbd{C-c | |
1279 | C-c}. | |
1280 | ||
1281 | @node Image-Dired | |
1282 | @section Viewing Image Thumbnails in Dired | |
1283 | @cindex image-dired mode | |
1284 | @cindex image-dired | |
1285 | ||
1286 | Image-Dired is a facility for browsing image files. It provides viewing | |
1287 | the images either as thumbnails or in full size, either inside Emacs | |
1288 | or through an external viewer. | |
1289 | ||
1290 | @kindex C-t d @r{(Image-Dired)} | |
1291 | @findex image-dired-display-thumbs | |
1292 | To enter Image-Dired, mark the image files you want to look at in | |
1293 | the Dired buffer, using @kbd{m} as usual. Then type @kbd{C-t d} | |
1294 | (@code{image-dired-display-thumbs}). This creates and switches to a | |
1295 | buffer containing image-dired, corresponding to the marked files. | |
1296 | ||
1297 | You can also enter Image-Dired directly by typing @kbd{M-x | |
1298 | image-dired}. This prompts for a directory; specify one that has | |
1299 | image files. This creates thumbnails for all the images in that | |
16152b76 | 1300 | directory, and displays them all in the ``thumbnail buffer''. This |
8cf51b2c GM |
1301 | takes a long time if the directory contains many image files, and it |
1302 | asks for confirmation if the number of image files exceeds | |
1303 | @code{image-dired-show-all-from-dir-max-files}. | |
1304 | ||
1305 | With point in the thumbnail buffer, you can type @kbd{RET} | |
1306 | (@code{image-dired-display-thumbnail-original-image}) to display a | |
1307 | sized version of it in another window. This sizes the image to fit | |
1308 | the window. Use the arrow keys to move around in the buffer. For | |
1309 | easy browsing, use @kbd{SPC} | |
1310 | (@code{image-dired-display-next-thumbnail-original}) to advance and | |
1311 | display the next image. Typing @kbd{DEL} | |
1312 | (@code{image-dired-display-previous-thumbnail-original}) backs up to | |
1313 | the previous thumbnail and displays that instead. | |
1314 | ||
1315 | @vindex image-dired-external-viewer | |
1316 | To view and the image in its original size, either provide a prefix | |
1317 | argument (@kbd{C-u}) before pressing @kbd{RET}, or type | |
1318 | @kbd{C-@key{RET}} (@code{image-dired-thumbnail-display-external}) to | |
1319 | display the image in an external viewer. You must first configure | |
1320 | @code{image-dired-external-viewer}. | |
1321 | ||
1322 | You can delete images through Image-Dired also. Type @kbd{d} | |
1323 | (@code{image-dired-flag-thumb-original-file}) to flag the image file | |
1324 | for deletion in the Dired buffer. You can also delete the thumbnail | |
1325 | image from the thumbnail buffer with @kbd{C-d} | |
1326 | (@code{image-dired-delete-char}). | |
1327 | ||
1328 | More advanced features include @dfn{image tags}, which are metadata | |
1329 | used to categorize image files. The tags are stored in a plain text | |
1330 | file configured by @code{image-dired-db-file}. | |
1331 | ||
1332 | To tag image files, mark them in the dired buffer (you can also mark | |
1333 | files in Dired from the thumbnail buffer by typing @kbd{m}) and type | |
39e26906 RS |
1334 | @kbd{C-t t} (@code{image-dired-tag-files}). This reads the tag name |
1335 | in the minibuffer. To mark files having a certain tag, type @kbd{C-t f} | |
8cf51b2c GM |
1336 | (@code{image-dired-mark-tagged-files}). After marking image files |
1337 | with a certain tag, you can use @kbd{C-t d} to view them. | |
1338 | ||
1339 | You can also tag a file directly from the thumbnail buffer by typing | |
1340 | @kbd{t t} and you can remove a tag by typing @kbd{t r}. There is also | |
1341 | a special ``tag'' called ``comment'' for each file (it is not a tag in | |
1342 | the exact same sense as the other tags, it is handled slightly | |
1343 | different). That is used to enter a comment or description about the | |
1344 | image. You comment a file from the thumbnail buffer by typing | |
1345 | @kbd{c}. You will be prompted for a comment. Type @kbd{C-t c} to add | |
1346 | a comment from Dired (@code{image-dired-dired-comment-files}). | |
1347 | ||
1348 | Image-Dired also provides simple image manipulation. In the | |
1349 | thumbnail buffer, type @kbd{L} to rotate the original image 90 degrees | |
1350 | anti clockwise, and @kbd{R} to rotate it 90 degrees clockwise. This | |
1351 | rotation is lossless, and uses an external utility called JpegTRAN. | |
1352 | ||
1353 | @node Misc Dired Features | |
1354 | @section Other Dired Features | |
1355 | ||
1356 | @kindex + @r{(Dired)} | |
1357 | @findex dired-create-directory | |
fac6225b | 1358 | The command @kbd{+} (@code{dired-create-directory}) reads a |
c40a7de7 CY |
1359 | directory name, and creates that directory. It signals an error if |
1360 | the directory already exists. | |
fac6225b CY |
1361 | |
1362 | @cindex searching multiple files via Dired | |
c40a7de7 CY |
1363 | @kindex M-s a C-s @r{(Dired)} |
1364 | @kindex M-s a M-C-s @r{(Dired)} | |
1365 | @findex dired-do-isearch | |
1366 | @findex dired-do-isearch-regexp | |
fac6225b CY |
1367 | The command @kbd{M-s a C-s} (@code{dired-do-isearch}) begins a |
1368 | ``multi-file'' incremental search on the marked files. If a search | |
1369 | fails at the end of a file, typing @kbd{C-s} advances to the next | |
1370 | marked file and repeats the search; at the end of the last marked | |
1371 | file, the search wraps around to the first marked file. The command | |
1372 | @kbd{M-s a M-C-s} (@code{dired-do-isearch-regexp}) does the same with | |
1373 | a regular expression search. @xref{Repeat Isearch}, for information | |
1374 | about search repetition. | |
8cf51b2c GM |
1375 | |
1376 | @cindex Adding to the kill ring in Dired. | |
1377 | @kindex w @r{(Dired)} | |
1378 | @findex dired-copy-filename-as-kill | |
fac6225b | 1379 | The command @kbd{w} (@code{dired-copy-filename-as-kill}) puts the |
8cf51b2c | 1380 | names of the marked (or next @var{n}) files into the kill ring, as if |
fac6225b CY |
1381 | you had killed them with @kbd{C-w}. The names are separated by a |
1382 | space. | |
8cf51b2c GM |
1383 | |
1384 | With a zero prefix argument, this uses the absolute file name of | |
1385 | each marked file. With just @kbd{C-u} as the prefix argument, it uses | |
1386 | file names relative to the Dired buffer's default directory. (This | |
1387 | can still contain slashes if in a subdirectory.) As a special case, | |
1388 | if point is on a directory headerline, @kbd{w} gives you the absolute | |
1389 | name of that directory. Any prefix argument or marked files are | |
1390 | ignored in this case. | |
1391 | ||
1392 | The main purpose of this command is so that you can yank the file | |
1393 | names into arguments for other Emacs commands. It also displays what | |
1394 | it added to the kill ring, so you can use it to display the list of | |
1395 | currently marked files in the echo area. | |
1396 | ||
4ebe9902 GM |
1397 | @cindex Dired and version control |
1398 | If the directory you are visiting is under version control | |
1399 | (@pxref{Version Control}), then the normal VC diff and log commands | |
1400 | will operate on the selected files. | |
1401 | ||
8cf51b2c GM |
1402 | @findex dired-compare-directories |
1403 | The command @kbd{M-x dired-compare-directories} is used to compare | |
1404 | the current Dired buffer with another directory. It marks all the files | |
1405 | that are ``different'' between the two directories. It puts these marks | |
1406 | in all Dired buffers where these files are listed, which of course includes | |
1407 | the current buffer. | |
1408 | ||
1409 | The default comparison method (used if you type @key{RET} at the | |
1410 | prompt) is to compare just the file names---each file name that does | |
16152b76 | 1411 | not appear in the other directory is ``different''. You can specify |
8cf51b2c GM |
1412 | more stringent comparisons by entering a Lisp expression, which can |
1413 | refer to the variables @code{size1} and @code{size2}, the respective | |
1414 | file sizes; @code{mtime1} and @code{mtime2}, the last modification | |
1415 | times in seconds, as floating point numbers; and @code{fa1} and | |
1416 | @code{fa2}, the respective file attribute lists (as returned by the | |
1417 | function @code{file-attributes}). This expression is evaluated for | |
1418 | each pair of like-named files, and if the expression's value is | |
16152b76 | 1419 | non-@code{nil}, those files are considered ``different''. |
8cf51b2c GM |
1420 | |
1421 | For instance, the sequence @code{M-x dired-compare-directories | |
1422 | @key{RET} (> mtime1 mtime2) @key{RET}} marks files newer in this | |
1423 | directory than in the other, and marks files older in the other | |
1424 | directory than in this one. It also marks files with no counterpart, | |
1425 | in both directories, as always. | |
1426 | ||
1427 | @cindex drag and drop, Dired | |
50b063c3 | 1428 | On the X Window System, Emacs supports the ``drag and drop'' |
8cf51b2c GM |
1429 | protocol. You can drag a file object from another program, and drop |
1430 | it onto a Dired buffer; this either moves, copies, or creates a link | |
1431 | to the file in that directory. Precisely which action is taken is | |
1432 | determined by the originating program. Dragging files out of a Dired | |
1433 | buffer is currently not supported. |