0
|
1 \input texinfo @c -*-texinfo-*-
|
|
2
|
|
3 @comment !Date: 1993/12/21 22:31:56 ! !Revision: 1.1 !
|
|
4
|
|
5 @comment %**start of header (This is for running Texinfo on a region.)
|
|
6 @setfilename ../info/dired.info
|
|
7 @settitle Tree Dired Version 6
|
|
8 @c @setchapternewpage odd
|
|
9 @comment %**end of header (This is for running Texinfo on a region.)
|
|
10
|
|
11 @iftex
|
|
12 @finalout
|
|
13 @end iftex
|
|
14
|
|
15 @ifinfo
|
|
16 This file documents Tree Dired, the GNU Emacs Directory Browser, and
|
|
17 most of the extra features available as an option.
|
|
18
|
|
19 Copyright (C) 1991, 1992 Free Software Foundation
|
|
20
|
|
21 Permission is granted to make and distribute verbatim copies of this
|
|
22 manual provided the copyright notice and this permission notice are
|
|
23 preserved on all copies.
|
|
24
|
|
25 @ignore
|
|
26 Permission is granted to process this file through TeX and print the
|
|
27 results, provided the printed document carries copying permission notice
|
|
28 identical to this one except for the removal of this paragraph (this
|
|
29 paragraph not being relevant to the printed manual).
|
|
30
|
|
31 @end ignore
|
|
32 Permission is granted to copy and distribute modified versions of this
|
|
33 manual under the conditions for verbatim copying, provided also that the
|
|
34 section entitled ``GNU General Public License'' is included exactly as
|
|
35 in the original, and provided that the entire resulting derived work is
|
|
36 distributed under the terms of a permission notice identical to this one.
|
|
37
|
|
38 Permission is granted to copy and distribute translations of this manual
|
|
39 into another language, under the above conditions for modified versions,
|
|
40 except that the section entitled ``GNU General Public License'' may be
|
|
41 included in a translation approved by the author instead of in the
|
|
42 original English.
|
|
43 @end ifinfo
|
|
44
|
|
45 @titlepage
|
|
46 @sp 6
|
|
47 @center @titlefont{Tree Dired}
|
|
48 @sp 2
|
|
49 @center @titlefont{The GNU Emacs}
|
|
50 @sp 1
|
|
51 @center @titlefont{Directory Editor}
|
|
52 @sp 4
|
|
53 @c @@center !Date: 1993/12/21 22:31:56 !
|
|
54 @sp 1
|
|
55 @c @@center !Revision: 1.1 !
|
|
56 @sp 5
|
|
57 @center Sebastian Kremer
|
|
58 @center sk@@thp.uni-koeln.de
|
|
59
|
|
60 @page
|
|
61
|
|
62 @noindent
|
|
63 !Date: 1993/12/21 22:31:56 !
|
|
64
|
|
65 @noindent
|
|
66 !Revision: 1.1 !
|
|
67
|
|
68 @vskip 0pt plus 1filll
|
|
69 Copyright @copyright{} 1991, 1992 Free Software Foundation
|
|
70
|
|
71 Permission is granted to make and distribute verbatim copies of
|
|
72 this manual provided the copyright notice and this permission notice
|
|
73 are preserved on all copies.
|
|
74
|
|
75 @ignore
|
|
76 Permission is granted to process this file through TeX and print the
|
|
77 results, provided the printed document carries copying permission notice
|
|
78 identical to this one except for the removal of this paragraph (this
|
|
79 paragraph not being relevant to the printed manual).
|
|
80
|
|
81 @end ignore
|
|
82 Permission is granted to copy and distribute modified versions of this
|
|
83 manual under the conditions for verbatim copying, provided also that the
|
|
84 section entitled ``GNU General Public License'' is included exactly as
|
|
85 in the original, and provided that the entire resulting derived work is
|
|
86 distributed under the terms of a permission notice identical to this one.
|
|
87
|
|
88 Permission is granted to copy and distribute translations of this manual
|
|
89 into another language, under the above conditions for modified versions,
|
|
90 except that the section entitled ``GNU General Public License'' may be
|
|
91 included in a translation approved by the author instead of in the
|
|
92 original English.
|
|
93 @end titlepage
|
|
94
|
|
95 @ifinfo
|
|
96
|
|
97 @node Top, Dired, (dir), (dir)
|
|
98
|
|
99 This file documents Tree Dired (version 6), the GNU Emacs Directory
|
|
100 Editor, including the optional ``Dired Extra'' features.
|
|
101
|
|
102 Tree Dired is an enhanced version of the Classic (18.xx Emacs) Dired and
|
|
103 will be the Dired of Emacs 19. It is known to work with Emacs 18.55 and
|
|
104 18.57 (and probably most earlier versions).
|
|
105 @c and also with prerelease versions of Emacs 19, but I don't write that
|
|
106 @c since I don't want to be bombarded with questions like `when it will
|
|
107 @c be ready'...
|
|
108
|
|
109 @noindent
|
|
110 Revision of this manual:
|
|
111
|
|
112 @noindent
|
|
113 !Id: dired.texinfo,v 1.1 1993/12/21 22:31:56 jwz Exp !
|
|
114
|
|
115 @noindent
|
|
116 Report bugs to:
|
|
117 @example
|
|
118 Sebastian Kremer <sk@@thp.uni-koeln.de>
|
|
119 @end example
|
|
120
|
|
121 @menu
|
|
122 * Dired:: Dired, the Directory Editor
|
|
123 * Tree Dired Extra:: Tree Dired Extra features
|
|
124 * Dired Internals:: Dired Internals
|
|
125 * Dired Known Problems:: Known Problems with Dired
|
|
126
|
|
127 --- Indices ---
|
|
128
|
|
129 * Dired Variable Index::
|
|
130 * Dired Function Index::
|
|
131 * Dired Key Index::
|
|
132 * Dired Concept Index::
|
|
133
|
|
134 --- The Detailed Node Listing ---
|
|
135
|
|
136 Dired, the Directory Editor
|
|
137
|
|
138 * Entering Dired::
|
|
139 * Editing in Dired::
|
|
140 * Listing Files in Dired::
|
|
141 * Marking Files in Dired::
|
|
142 * Mark-using Commands::
|
|
143 * Commands That Do Not Use Marks::
|
|
144 * Subdirectories in Dired::
|
|
145 * Hiding Directories in Dired::
|
|
146 * Acknowledgement::
|
|
147 * Dired Customization::
|
|
148
|
|
149 Mark-using Commands
|
|
150
|
|
151 * Copy and Move Into a Directory::
|
|
152 * Renaming and More With Regexps::
|
|
153 * Other File Creating Commands::
|
|
154 * Deleting Files With Dired::
|
|
155 * Dired Shell Commands::
|
|
156 * Compressing and Uncompressing::
|
|
157 * Changing File Attributes::
|
|
158 * Loading and Byte-compiling Emacs Lisp Files::
|
|
159 * Printing the Marked Files::
|
|
160
|
|
161 Dired Customization
|
|
162
|
|
163 * Dired User Options::
|
|
164 * Dired Configuration::
|
|
165 * Dired Hooks::
|
|
166
|
|
167 Tree Dired Extra features
|
|
168
|
|
169 * Tree Dired Extra Features::
|
|
170 * Dired Minibuffer History::
|
|
171 * Inserting All Marked Subdirectories::
|
|
172 * Dynamic Dired Markers::
|
|
173 * Omitting Files in Dired::
|
|
174 * Advanced Dired Mark Commands::
|
|
175 * Virtual Dired::
|
|
176 * Multiple Dired Directories::
|
|
177 * Dired Local Variables::
|
|
178 * Making Relative Symbolic Links in Dired::
|
|
179 * Letting Dired Guess What Shell Command to Apply::
|
|
180 * dired-trns.el:: Filename Transformers for Dired Shell Commands
|
|
181 * dired-cd.el:: Changing the Working Directory for Dired Shell Commands
|
|
182 * dired-nstd.el:: Nested Dired format
|
|
183 * find-dired.el:: Feeding Find Output to Dired
|
|
184
|
|
185 Dired Internals
|
|
186
|
|
187 * Tree Dired Internals::
|
|
188 * Dired Mark Internals::
|
|
189 @end menu
|
|
190
|
|
191 @end ifinfo
|
|
192
|
|
193 @node Dired, Tree Dired Extra, Top, Top
|
|
194 @chapter Dired, the Directory Editor
|
|
195 @cindex Dired
|
|
196 @cindex Deletion (of files)
|
|
197
|
|
198 Dired makes it easy to delete or visit many of the files in a single
|
|
199 directory (and possibly its subdirectories) at once. It makes an Emacs
|
|
200 buffer containing a listing of the directories, in the format of
|
|
201 @code{ls -lR}. You can use the normal Emacs commands to move around in
|
|
202 this buffer, and special Dired commands to operate on the files. You
|
|
203 can run shell commands on files, visit, compress, load or byte-compile
|
|
204 them, change their file attributes and insert subdirectories into the
|
|
205 same buffer. You can ``mark'' files for later commands or ``flag'' them
|
|
206 for deletion, either file by file or all files matching certain
|
|
207 criteria.
|
|
208
|
|
209 @menu
|
|
210 * Entering Dired::
|
|
211 * Editing in Dired::
|
|
212 * Listing Files in Dired::
|
|
213 * Marking Files in Dired::
|
|
214 * Mark-using Commands::
|
|
215 * Commands That Do Not Use Marks::
|
|
216 * Subdirectories in Dired::
|
|
217 * Hiding Directories in Dired::
|
|
218 * Acknowledgement::
|
|
219 * Dired Customization::
|
|
220 @end menu
|
|
221
|
|
222 @node Entering Dired, Editing in Dired, Dired, Dired
|
|
223 @section Entering Dired
|
|
224
|
|
225 @findex Dired
|
|
226 @kindex C-x d
|
|
227 @vindex dired-listing-switches
|
|
228 @noindent
|
|
229 To invoke Dired, do @kbd{C-x d} or @kbd{M-x dired}. The command reads a
|
|
230 directory name or wildcard file name pattern as a minibuffer argument
|
|
231 just like the @code{list-directory} command, @kbd{C-x C-d}. Invoking
|
|
232 Dired with a prefix argument lets you enter the listing switches for the
|
|
233 directory.
|
|
234
|
|
235 Dired assumes you meant to use a wildcard if the last component of the
|
|
236 name is not an existing file. Note that only the last pathname
|
|
237 component may contain wildcards. With wildcards it uses the shell to do
|
|
238 the filename globbing, whereas usually it calls @samp{ls} directly.
|
|
239 Because of this, you might have to quote characters that are special to
|
|
240 the shell. For example, to dired all auto-save files in your
|
|
241 @file{~/mail/} directory, use @samp{~/mail/\#*} as argument to Dired.
|
|
242 Note the backslash needed to quote @samp{#} (at the beginning of a word)
|
|
243 to the shell.
|
|
244
|
|
245 Where @code{dired} differs from @code{list-directory} is in naming the
|
|
246 buffer after the directory name or the wildcard pattern used for the
|
|
247 listing, and putting the buffer into Dired mode so that the special
|
|
248 commands of Dired are available in it. The variable
|
|
249 @code{dired-listing-switches} is a string used as an argument to
|
|
250 @code{ls} in making the directory; this string @i{must} contain
|
|
251 @samp{-l}. Most other switches are also allowed, especially @samp{-F},
|
|
252 @samp{-i} and @samp{-s}. For the @samp{-F} switch to work you may have
|
|
253 to set the variable @code{dired-ls-F-marks-symlinks}, depending on what
|
|
254 kind of @samp{ls} program you are using.
|
|
255 @xref{Dired Configuration}.
|
|
256 @refill
|
|
257
|
|
258 When a Dired buffer for the given directory already exists, it is simply
|
|
259 selected without refreshing it. You can type @kbd{g} if you suspect it
|
|
260 is out of date.
|
|
261
|
|
262 @findex dired-other-window
|
|
263 @kindex C-x 4 d
|
|
264 To display the Dired buffer in another window rather than in the
|
|
265 selected window, use @kbd{C-x 4 d} (@code{dired-other-window)} instead
|
|
266 of @kbd{C-x d}.@refill
|
|
267
|
|
268 @node Editing in Dired, Listing Files in Dired, Entering Dired, Dired
|
|
269 @section Editing in Dired
|
|
270
|
|
271 @noindent
|
|
272 Once the Dired buffer exists, you can switch freely between it and other
|
|
273 Emacs buffers. Whenever the Dired buffer is selected, certain special
|
|
274 commands are provided that operate on files that are listed. The Dired
|
|
275 buffer is ``read-only'', and inserting text in it is not useful, so
|
|
276 ordinary printing characters such as @kbd{d} and @kbd{x} are used for Dired
|
|
277 commands, and digits are prefix arguments.@refill
|
|
278
|
|
279 @cindex Current file (in Dired)
|
|
280 The file described by the line that point is on is called the
|
|
281 @dfn{current file}. The directory this file is in is the @dfn{current
|
|
282 Dired directory}. Note that there may be several directories in one
|
|
283 Dired buffer as long as they belong to the same tree. The top level
|
|
284 directory, the @dfn{root} of the tree, is used as the working directory
|
|
285 of the buffer.@refill
|
|
286
|
|
287 Some or all directories can be @dfn{hidden}, leaving only their
|
|
288 headerlines visible, and exlcuding their files from Dired operations.
|
|
289
|
|
290 @cindex Marking files (in Dired)
|
|
291 Files can be @dfn{marked} for later commands. Marking means putting a
|
|
292 special character, usually @samp{*}, in the first column of the file
|
|
293 line. To @dfn{flag} a file means to mark it for later deletion. This
|
|
294 special case of ``marking'' is distinguished so that you do not delete
|
|
295 files accidentally. Internally, the only difference between marking and
|
|
296 flagging is the character used to mark the file: @samp{*} (an asterisk)
|
|
297 for a marked file, and @samp{D} for files flagged for deletion.
|
|
298
|
|
299 @cindex Mark-using commands
|
|
300 Most Dired commands operate on the ``marked'' files and default to the
|
|
301 current file. They are the @dfn{mark-using} commands. Deleting is the
|
|
302 only mark-using command that does not default to the current file.
|
|
303
|
|
304 Dired buffers ``know'' about each other. For example, copying from
|
|
305 @var{dir1} into @var{dir2} will update @var{dir2}'s Dired buffer(s).
|
|
306 When you move files or directories, file and dired buffers are kept up
|
|
307 to date and refer to the new location. But Dired only knows about files
|
|
308 changed by itself, not by other parts of Emacs or programs outside
|
|
309 Emacs.
|
|
310
|
|
311 All the usual Emacs cursor motion commands are available in Dired
|
|
312 buffers. Some special purpose commands are also provided. The keys
|
|
313 @kbd{C-n} and @kbd{C-p} are redefined so that they try to position the
|
|
314 cursor at the beginning of the filename on the line, rather than at the
|
|
315 beginning of the line.
|
|
316
|
|
317 For extra convenience, @key{SPC} and @kbd{n} in Dired are equivalent to
|
|
318 @kbd{C-n}. @kbd{p} is equivalent to @kbd{C-p}. Moving by lines is also
|
|
319 done so often in Dired that it deserves to be easy to type. @key{DEL}
|
|
320 (move up and unflag) is often useful simply for moving up.@refill
|
|
321
|
|
322 @node Listing Files in Dired, Marking Files in Dired, Editing in Dired, Dired
|
|
323 @section Listing Files in Dired
|
|
324
|
|
325 @cindex Headerline
|
|
326 @cindex Non-file line
|
|
327 @cindex File line
|
|
328 @noindent
|
|
329 Initially the Dired buffer shows the directory you selected. The first
|
|
330 line shows the full directory name. It is an example of a
|
|
331 @dfn{headerline} of a directory. Note that it is terminated by a colon
|
|
332 (@samp{:}) that is not part of the directory name. The second line
|
|
333 usually displays the total size of all files in the directory or
|
|
334 the wildcard used. Both are examples of @dfn{non-file lines}.
|
|
335 Applying a command to a non-file line signals an error. The other lines
|
|
336 of the directory, called the @dfn{file lines}, show information about
|
|
337 each file such as permission bits, size and date of last modification,
|
|
338 and the name of the file.@refill
|
|
339
|
|
340 For example, the listing
|
|
341
|
|
342 @example
|
|
343 /home/sk/lib/emacs/lisp:
|
|
344 total 4973
|
|
345 -rw-r--r-- 1 sk users 231608 Feb 6 16:58 ChangeLog
|
|
346 drwxr-sr-x 2 sk users 2048 Feb 6 11:07 RCS
|
|
347 -r--r--r-- 1 sk users 141389 Feb 6 10:45 dired.el
|
|
348 -r--r--r-- 1 sk users 113033 Feb 5 16:21 dired.texi
|
|
349 @dots{}
|
|
350
|
|
351 /home/sk/lib/emacs/lisp/RCS:
|
|
352 total 4798
|
|
353 -r--r--r-- 1 sk users 231748 Feb 6 16:59 dired.texi,v
|
|
354 -r--r--r-- 1 sk users 763898 Feb 6 10:45 dired.el,v
|
|
355 @dots{}
|
|
356 @end example
|
|
357
|
|
358 has a headerline for the @file{lisp} directory, a total line saying
|
|
359 there are 4973 K in all the files of that directory (your @samp{ls}
|
|
360 program may use units of blocks instead), and several file lines. After
|
|
361 that, a headerline for the @file{RCS} subdirectory with its total line
|
|
362 and its files follows.
|
|
363
|
|
364 Here is an example of a wildcard listing:
|
|
365
|
|
366 @example
|
|
367 /home/sk/lib/emacs/lisp:
|
|
368 wildcard dired*
|
|
369 -rw-r--r-- 1 sk users 113036 Feb 6 16:59 dired.texi
|
|
370 -r--r--r-- 1 sk users 81267 Feb 6 16:29 dired.elc
|
|
371 -r--r--r-- 1 sk users 38436 Feb 6 16:28 dired-x.elc
|
|
372 -r--r--r-- 1 sk users 60258 Feb 6 16:27 dired-x.el
|
|
373 -r--r--r-- 1 sk users 141389 Feb 6 10:45 dired.el
|
|
374 @dots{}
|
|
375 @end example
|
|
376
|
|
377 Since @samp{ls} does not provide a total count when called with a wildcard
|
|
378 argument, the second line now gives instead the wildcard used, here
|
|
379 @samp{dired*}. If there would have been a directory matching the
|
|
380 wildcard, e.g. a @samp{dired/} subdirectory, its file line would be
|
|
381 shown, but it would not have been expanded automatically.
|
|
382
|
|
383 Filenames may have embedded and trailing (but not leading) spaces.
|
|
384 Leading spaces are not recognized because different @samp{ls} programs
|
|
385 differ in the amount of whitespace the insert before the filename.
|
|
386 Filenames may @emph{not} contain newlines or @samp{^M}'s. You can get
|
|
387 away with @samp{^M}'s in filenames if you do
|
|
388
|
|
389 @example
|
|
390 (setq selective-display nil)
|
|
391 @end example
|
|
392
|
|
393 @noindent
|
|
394 in the Dired buffer (inside @code{dired-mode-hook}, @xref{Dired
|
|
395 Hooks}.). But this also disables the @kbd{=} and @kbd{$} hiding
|
|
396 commands, @xref{Hiding Directories in Dired}.@refill
|
|
397
|
|
398 Other unprintable characters than @samp{^M} or newline (@samp{^J}) in
|
|
399 filenames are no problem for Dired. But your @samp{ls} program may not
|
|
400 output them correctly (e.g., replacing all unprintable characters with a
|
|
401 question mark @samp{?}). Dired can do nothing if @samp{ls} suppresses
|
|
402 information about the filenames. But some (System V derived) @samp{ls}
|
|
403 programs have a @samp{-b} switch to quote control characters, e.g.
|
|
404 @samp{\n} for a newline character, or @samp{\007} for a ASCII bell
|
|
405 character (@kbd{C-g}), so you might want to add @samp{b} to your
|
|
406 switches (see below). Dired translates the quoted control character
|
|
407 escapes when a @samp{-b} switch was used. The @samp{-b} switch is the
|
|
408 recommended method to cope with funny filenames containing newlines or
|
|
409 leading spaces. But check if your @samp{ls} understands @samp{-b} and really
|
|
410 quotes newlines and spaces. Dired is known to work with GNU @samp{ls
|
|
411 -b}, but other @samp{ls -b} don't quote spaces, so leading spaces still
|
|
412 don't work with these @samp{ls} programs.
|
|
413 @refill
|
|
414
|
|
415 The appearance of the listing is determined by the listing switches
|
|
416 used, for example whether you display or suppress @samp{.} files with
|
|
417 the @samp{-a} and @samp{-A} switches, use the @samp{-F} switch to tag
|
|
418 filenames etc. It may additionally be restricted to certain files if you
|
|
419 used wildcards to display only those files matching a shell file
|
|
420 wildcard.@refill
|
|
421
|
|
422 @cindex Dired listing switches
|
|
423 Dired has commands that change the listing switches for this buffer.
|
|
424 They are mainly used to set the sort mode, but can also be used to
|
|
425 change other formatting options. The buffer is automatically refreshed
|
|
426 after the switches are changed to let the new format take effect.
|
|
427
|
|
428 The default value for the switches comes from the variable
|
|
429 @code{dired-listing-switches}; a prefix argument to @code{dired} can be
|
|
430 use to determine the switches used for a specific buffer.
|
|
431 @xref{Entering Dired}. Each Dired buffer has its own value for the
|
|
432 switches, stored in the variable @code{dired-actual-switches}.@refill
|
|
433 @vindex dired-actual-switches
|
|
434
|
|
435 @vindex dired-sort-by-name-regexp
|
|
436 @vindex dired-sort-by-date-regexp
|
|
437 The Dired modeline displays @samp{by name} or @samp{by date} to indicate
|
|
438 the sort mode. It uses the regexps in the variables
|
|
439 @code{dired-sort-by-date-regexp} and @code{dired-sort-by-name-regexp} to
|
|
440 decide what should be displayed. If neither of the regexps matches, the
|
|
441 listing switches are displayed literally. You can use this to always
|
|
442 display the literal switches instead of @samp{by name} or @samp{by
|
|
443 date}: set them to a regexp that never matches any listing switches, for
|
|
444 example @samp{^$}.@refill
|
|
445
|
|
446 @vindex dired-ls-sorting-switches
|
|
447 Most @samp{ls} programs can only sort by name (without @samp{-t}) or by
|
|
448 date (with @samp{-t}), nothing else. GNU @samp{ls} additionally sorts
|
|
449 on size with @samp{-S}, on extension with @samp{-X}, and unsorted (in
|
|
450 directory order) with @samp{-U}. So anything that does not contain
|
|
451 these is sort "by name". However, this is configurable in the variable
|
|
452 @code{dired-ls-sorting-switches}, which defaults to @code{"SXU"}. It
|
|
453 contains a string of @samp{ls} switches (single letters) except @samp{t} that
|
|
454 influence sorting. It is consulted at load time, so if you redefine it,
|
|
455 you must do it before Dired is loaded.@refill
|
|
456
|
|
457 @table @kbd
|
|
458
|
|
459 @item s
|
|
460 @kindex s
|
|
461 @findex dired-sort-toggle-or-edit
|
|
462 (@code{dired-sort-toggle-or-edit}) Toggle between sort by name/date and
|
|
463 refresh the dired buffer. With a prefix argument you can edit the
|
|
464 current listing switches instead.
|
|
465
|
|
466 @end table
|
|
467
|
|
468 @cindex Refreshing a Dired listing
|
|
469 After some time the listing may become out of date because of actions by
|
|
470 other programs than Dired. You can refresh the complete Dired buffer
|
|
471 from disk or only refresh the lines of certain files or a single file.
|
|
472
|
|
473 @table @kbd
|
|
474
|
|
475 @item l
|
|
476 @kindex l
|
|
477 @findex dired-do-redisplay
|
|
478 (@code{dired-do-redisplay}) Redisplay all marked (or, with a prefix
|
|
479 argument, the next @var{N}) files. As always, if no files are marked,
|
|
480 the current file is used.
|
|
481
|
|
482 If on a headerline, redisplay that subdirectory. In that case,
|
|
483 a prefix arg lets you edit the @samp{ls} switches used for the new listing.
|
|
484
|
|
485
|
|
486 @kindex g
|
|
487 @findex revert-buffer
|
|
488 @item g
|
|
489 (@code{revert-buffer}) The @kbd{g} command in Dired ultimately runs
|
|
490 @code{dired-revert} to reinitialize the buffer from the actual disk
|
|
491 directory (or directories). All marks and flags in the Dired buffer are
|
|
492 restored, except of course for files that have vanished. Hidden
|
|
493 subdirectories are hidden again. @xref{Hiding Directories in Dired}.
|
|
494 @refill
|
|
495
|
|
496 @item k
|
|
497 @kindex k
|
|
498 @findex dired-kill-line-or-subdir
|
|
499 (@code{dired-kill-line-or-subdir}) Kill this line (but not this file).
|
|
500 Optional prefix argument is a repeat factor.
|
|
501 If file is displayed as expanded subdirectory, kill that as well.
|
|
502
|
|
503 If on a subdirectory line, kill that subdirectory. Reinsert it with
|
|
504 @kbd{i} (@code{dired-maybe-insert-subdir}), @xref{Subdirectories in
|
|
505 Dired}.
|
|
506
|
|
507 Killing a file line means that the line is removed from the Dired
|
|
508 buffer. The file is not touched, and the line will reappear when the
|
|
509 buffer is refreshed (using @kbd{g}, @code{revert-buffer}). A killed
|
|
510 subdirectory will not reappear after reverting the buffer, since @kbd{g}
|
|
511 only list those subdirectories that were listed before.
|
|
512
|
|
513 @item M-k
|
|
514 @kindex M-k
|
|
515 @findex dired-do-kill
|
|
516 (@code{dired-do-kill}) Kill all marked lines (not files). With a prefix
|
|
517 argument, kill all lines not marked or flagged.
|
|
518
|
|
519 (For file marking, @xref{Marking Files in Dired}.)
|
|
520
|
|
521 @item C-x u
|
|
522 @kindex C-x u
|
|
523 @item C-_
|
|
524 @kindex C-_
|
|
525 @findex dired-undo
|
|
526 (@code{dired-undo}) Undo in a Dired buffer. This doesn't recover lost
|
|
527 files, it is just normal undo with a temporarily writable buffer. You
|
|
528 can use it to recover marks, killed lines or subdirs. In the latter
|
|
529 case, you have to do @kbd{M-x dired-build-subdir-alist} to parse the
|
|
530 buffer again for the new subdirectory list.@refill
|
|
531
|
|
532 @end table
|
|
533
|
|
534
|
|
535 @node Marking Files in Dired, Mark-using Commands, Listing Files in Dired, Dired
|
|
536 @section Marking Files in Dired
|
|
537
|
|
538 @noindent
|
|
539 This section describes commands to mark and unmark single files, and
|
|
540 commands to mark several files at once if they match certain criteria.
|
|
541 There also is a command to move to the next marked file.
|
|
542
|
|
543 As always, hidden subdirs are not affected. @xref{Hiding Directories in
|
|
544 Dired}.
|
|
545
|
|
546 @table @kbd
|
|
547
|
|
548 @item m
|
|
549 @kindex m
|
|
550 @findex dired-mark-subdir-or-file
|
|
551 (@code{dired-mark-subdir-or-file}) If on a file line, mark the current
|
|
552 file. A numeric argument tells how many next or previous files to mark.
|
|
553 If on a subdirectory header line, mark all its files except `.' and `..'.
|
|
554
|
|
555 @item u
|
|
556 @kindex u
|
|
557 @findex dired-unmark-subdir-or-file
|
|
558 (@code{dired-unmark-subdir-or-file}) Like @kbd{m}, only unmarking
|
|
559 instead of marking.
|
|
560
|
|
561 @item DEL
|
|
562 @kindex DEL
|
|
563 @findex dired-backup-unflag
|
|
564 (@code{dired-backup-unflag}) Move up lines and remove flags there.
|
|
565 Optional prefix argument says how many lines to unflag; default is one
|
|
566 line.
|
|
567
|
|
568 @item M-DEL
|
|
569 @kindex M-DEL
|
|
570 @findex dired-unflag-all-files
|
|
571 (@code{dired-unflag-all-files}) Remove a specific or all flags from
|
|
572 every file. With an argument, queries for each marked file. Type your
|
|
573 help character, usually
|
|
574 @kbd{C-h}, at that time for help.
|
|
575
|
|
576 @item *
|
|
577 @kindex *
|
|
578 @findex dired-mark-executables
|
|
579 (@code{dired-mark-executables}) Mark all executable files. With prefix
|
|
580 argument, unflag all those files.
|
|
581
|
|
582 @item @@
|
|
583 @kindex @@
|
|
584 @findex dired-mark-symlinks
|
|
585 (@code{dired-mark-symlinks}) Mark all symbolic links. With prefix
|
|
586 argument, unflag all those files.
|
|
587
|
|
588 @item /
|
|
589 @kindex /
|
|
590 @findex dired-mark-directories
|
|
591 (@code{dired-mark-directories}) Mark all directory files except `.' and
|
|
592 `..'. With prefix argument, unflag all those files.
|
|
593
|
|
594 @item %m
|
|
595 @kindex %m
|
|
596 @findex dired-mark-files-regexp
|
|
597 (@code{dired-mark-files-regexp}) Mark all files matching @var{regexp}
|
|
598 for use in later commands. A prefix argument means to unmark them
|
|
599 instead. @file{.} and @file{..} are never marked.
|
|
600
|
|
601 The match is against the non-directory part of the filename. Use
|
|
602 @samp{^} and @samp{$} to anchor matches. Exclude subdirs by hiding
|
|
603 them.
|
|
604
|
|
605 This is an Emacs regexp, not a shell wildcard. E.g., use @samp{\.o$}
|
|
606 for object files - just @samp{.o} will mark more than you might think.
|
|
607 By default, the match is case sensitive (just like filenames), since
|
|
608 @code{case-fold-search} is set to @code{nil} in Dired buffers.
|
|
609
|
|
610 @item M-@}
|
|
611 @kindex M-@}
|
|
612 @findex dired-next-marked-file
|
|
613 (@code{dired-next-marked-file}) Move to the next marked file, wrapping
|
|
614 around the end of the buffer.
|
|
615
|
|
616 @item M-@{
|
|
617 @kindex M-@{
|
|
618 @findex dired-prev-marked-file
|
|
619 (@code{dired-prev-marked-file}) Move to the previous marked file,
|
|
620 wrapping around the beginning of the buffer.
|
|
621
|
|
622 @end table
|
|
623
|
|
624 @node Mark-using Commands, Commands That Do Not Use Marks, Marking Files in Dired, Dired
|
|
625 @section Mark-using Commands
|
|
626
|
|
627 @cindex Mark-using commands
|
|
628 Most Dired commands operate on the ``marked'' files and default to the
|
|
629 current file. They are the ``mark-using'' commands. Deleting is the
|
|
630 only mark-using command that does not default to the current file.
|
|
631
|
|
632 @cindex Numeric argument to Dired's mark-using commands
|
|
633 @cindex Prefix argument to Dired's mark-using commands
|
|
634 @cindex Repeat count for Dired's mark-using commands
|
|
635 @cindex Mark-using commands, use of prefix argument as repeat count
|
|
636 Mark-using Dired commands treat a numeric argument as a repeat count,
|
|
637 meaning to act on the files of the next few lines instead of on the
|
|
638 marked files. That is, when you give a prefix argument the marks are
|
|
639 not consulted at all. A negative argument means to operate on the files
|
|
640 of the preceding lines. Either set of files is called @dfn{marked
|
|
641 files} below, whether they really come from marks or from a prefix
|
|
642 argument. The prompt of a mark-using command always makes clear which
|
|
643 set of files is operated upon: it mentions either the marker character
|
|
644 @samp{*} or the @samp{next @var{N}} files, where a negative @var{N}
|
|
645 really means the previous @var{-N} files.@refill
|
|
646
|
|
647 @cindex Prefix argument via digit keys
|
|
648 Thus you can use a prefix argument of @code{1} to apply a command to just the
|
|
649 current file, e.g, if you don't want to disturb the other files you
|
|
650 marked. As digits are prefix arguments in Dired, simply type @kbd{1}
|
|
651 followed by the command.
|
|
652
|
|
653 Many mark-using commands treat a prefix of @var{N=0} specially, since it
|
|
654 would otherwise be a no-op.
|
|
655
|
|
656 @cindex Why something went wrong in Dired
|
|
657 @cindex Error logging in Dired
|
|
658 @kindex W
|
|
659 All mark-using commands display a list of files for which they failed.
|
|
660 Type @kbd{W} to see why a (mark-using or other) command failed. Error
|
|
661 messages from shell commands (@samp{stderr}) cannot be redirected
|
|
662 separately and goes together with the usual output (@samp{stdout}).
|
|
663
|
|
664 @menu
|
|
665 * Copy and Move Into a Directory::
|
|
666 * Renaming and More With Regexps::
|
|
667 * Other File Creating Commands::
|
|
668 * Deleting Files With Dired::
|
|
669 * Dired Shell Commands::
|
|
670 * Compressing and Uncompressing::
|
|
671 * Changing File Attributes::
|
|
672 * Loading and Byte-compiling Emacs Lisp Files::
|
|
673 * Printing the Marked Files::
|
|
674 @end menu
|
|
675
|
|
676 @node Copy and Move Into a Directory, Renaming and More With Regexps, Mark-using Commands, Mark-using Commands
|
|
677 @subsection Copy, Move etc. Into a Directory
|
|
678
|
|
679 @cindex Target commands in Dired
|
|
680 @cindex Dired target commands
|
|
681 @noindent
|
|
682 This section explains commands that create a new file for each marked
|
|
683 file, for example by copying (@kbd{c}) or moving (@kbd{r}) files. They
|
|
684 prompt in the minibuffer for a @var{target} argument, usually the target
|
|
685 directory in which the new files are created. But if there is but one
|
|
686 marked file, the target may also be a plain file. (Otherwise you could
|
|
687 not simply rename or copy a single file within the same directory.)
|
|
688 Even with one marked file the target may still be an (existing)
|
|
689 directory.
|
|
690
|
|
691 @cindex Target default in Dired
|
|
692 @cindex Default target in Dired
|
|
693 @vindex dired-dwim-target
|
|
694 The target prompt displays a @dfn{default target} that will be used if
|
|
695 you just type @kbd{RET}. Normally the default target is the current
|
|
696 Dired directory, so if you want to copy into some specific subdirectory,
|
|
697 move point into that subdirectory before typing @kbd{c}. But if there
|
|
698 is a Dired buffer in the next window, and @code{dired-dwim-target} is
|
|
699 true, its current Dired directory is used. This makes it easy to copy
|
|
700 from one Dired buffer into another if both are displayed. On the other
|
|
701 hand you have to use @kbd{C-x 1} to make other Dired buffers vanish if
|
|
702 you do not want to have them as default targets. To make Dired never
|
|
703 look at the next window, set the variable @code{dired-dwim-target} to
|
|
704 nil (@samp{dwim} means Do What I Mean). @xref{Dired User Options}, on
|
|
705 how to set cutomization variables.
|
|
706
|
|
707 @cindex Overwriting of files in Dired
|
|
708 As a general rule, Dired will not let you remove or overwrite a file
|
|
709 without explicit confirmation. Dired asks you for each existing target
|
|
710 file whether or not to overwrite just this file (answer @kbd{y} or
|
|
711 @kbd{n}) or all remaining files (answer @kbd{!}). You can also type
|
|
712 your help character, usually @kbd{C-h}, at that time for help.
|
|
713
|
|
714 @table @kbd
|
|
715 @findex dired-do-copy
|
|
716 @kindex c
|
|
717 @vindex dired-copy-preserve-time
|
|
718 @item c
|
|
719 (@code{dired-do-copy}) Copy the marked (or next @var{N}) files into a
|
|
720 directory, or copy a single file.
|
|
721
|
|
722 Thus, a zero prefix argument (@var{N-0}) copies nothing. But it toggles
|
|
723 the variable @code{dired-copy-preserve-time}.@*
|
|
724 @xref{Dired User Options}, on how to set customization variables.
|
|
725
|
|
726 @findex dired-do-move
|
|
727 @kindex r
|
|
728 @item r
|
|
729 (@code{dired-do-move}) Move the marked files into a directory. If
|
|
730 there is just one marked file, rename that file. As the marked files
|
|
731 default to the current file, this can also be used to simply rename the
|
|
732 current file.
|
|
733
|
|
734 Dired silently changes the visited file name of buffers associated with
|
|
735 moved files so that they refer to the new location of the file.
|
|
736
|
|
737 When a directory is renamed, its headerlines in Dired buffers are
|
|
738 updated, and any buffers visiting affected files have their visited file
|
|
739 name changed to refer to the new location. Their buffer name is changed
|
|
740 if no buffer with such a name already exists. Affected files are all
|
|
741 those which contain the directory somewhere in their absolute path name.
|
|
742
|
|
743 A zero prefix arguments does not move any files, but toggles the
|
|
744 variable @code{dired-dwim-target}.
|
|
745
|
|
746 @findex dired-do-hardlink
|
|
747 @kindex H
|
|
748 @item H
|
|
749 (@code{dired-do-hardlink}) Make hard links from the target directory
|
|
750 to each marked file.
|
|
751 @findex dired-do-symlink
|
|
752 @kindex Y
|
|
753 @item Y
|
|
754 (@code{dired-do-symlink}) Make symbolic links from the target
|
|
755 directory to each marked file.
|
|
756 @end table
|
|
757
|
|
758 @vindex dired-keep-marker-copy
|
|
759 @vindex dired-keep-marker-hardlink
|
|
760 @vindex dired-keep-marker-symlink
|
|
761 Linking is very similar to copying in that new files are created while
|
|
762 the old files stay. If you want each newly copied or linked file to be
|
|
763 marked with the same marker that its original has, set the variables
|
|
764 @code{dired-keep-marker-copy}, @code{dired-keep-marker-hardlink} or
|
|
765 @code{dired-keep-marker-symlink} to @code{t}. Set them to @code{nil} to
|
|
766 not give these newly created files marks. The default is to mark them
|
|
767 with @samp{C}, @samp{H} and @samp{Y}, respectively.
|
|
768
|
|
769 @vindex dired-keep-marker-move
|
|
770 Moving differs from copying and linking in that the old file is removed
|
|
771 as part of the creation of the new file. Thus it makes sense to set the
|
|
772 variable @code{dired-keep-marker-move} to @code{t} (the default) so that
|
|
773 moved files ``take their markers with them''.
|
|
774
|
|
775 @node Renaming and More With Regexps, Other File Creating Commands, Copy and Move Into a Directory, Mark-using Commands
|
|
776 @subsection Renaming (and More) With Regexps
|
|
777
|
|
778 @cindex Regexp commands in Dired
|
|
779 @cindex Dired regexp commands
|
|
780 A second class of Commands uses regular expressions to construct a new
|
|
781 filename from each marked file. @xref{Regexps,Syntax of Regular
|
|
782 Expressions,Regular Expressions,emacs,The GNU Emacs Manual}. The commands
|
|
783 to make new names by regexp conversion are the same as those to make
|
|
784 them in another directory, except that they share a prefix char, @kbd{%}.
|
|
785
|
|
786 @table @kbd
|
|
787
|
|
788 @item %r
|
|
789 @kindex %r
|
|
790 @findex dired-rename-regexp
|
|
791 (@code{dired-rename-regexp}) Rename files with regexps
|
|
792
|
|
793 @item %c
|
|
794 @kindex %c
|
|
795 @findex dired-do-copy-regexp
|
|
796 (@code{dired-do-copy-regexp})
|
|
797 Copy files with regexps.
|
|
798
|
|
799 @item %H
|
|
800 @kindex %H
|
|
801 @findex dired-do-hardlink-regexp
|
|
802 (@code{dired-do-hardlink-regexp})
|
|
803 Make hard links with regexps.
|
|
804
|
|
805 @item %Y
|
|
806 @kindex %Y
|
|
807 @findex dired-do-symlink-regexp
|
|
808 (@code{dired-do-symlink-regexp})
|
|
809 Make symbolic links with regexps.
|
|
810
|
|
811 @end table
|
|
812
|
|
813 These commands prompt in the minibuffer for a @var{regexp} and a
|
|
814 @var{newname}. For each marked file matching @var{regexp}, a new
|
|
815 filename is constructed from @var{newname}. The match can be anywhere
|
|
816 in the file name, it need not span the whole filename. Use @samp{^} and
|
|
817 @samp{$} to anchor matches that should span the whole filename. Only
|
|
818 the first match in the filename is replaced with @var{newtext}. (It
|
|
819 would be easy to change this to replace all matches, but probably harder
|
|
820 to use.)
|
|
821
|
|
822 @samp{\&} in @var{newname} stands for the entire text being replaced.
|
|
823 @samp{\@var{d}} in @var{newname}, where @var{d} is a digit, stands for
|
|
824 whatever matched the @var{d}'th parenthesized grouping in @var{regexp}.
|
|
825 As each match is found, the user must type a character saying whether or
|
|
826 not to apply the command to just this file (@kbd{y} or @kbd{n}) or to
|
|
827 all remaining files(@kbd{!}). For help type your help character,
|
|
828 usually @kbd{C-h}, at that time.@refill
|
|
829
|
|
830 For example, if you want to rename all @file{.lsp} files to @file{.el}
|
|
831 files, type first @kbd{%m} with @samp{\.lsp$} as regexp to mark all
|
|
832 @file{.lsp} files. Then type @kbd{%r} with @samp{\.lsp$} and @samp{.el}
|
|
833 as @var{regexp} and @var{newtext} arguments. Dired will prompt you for
|
|
834 each file to be renamed.
|
|
835
|
|
836 Or to append @file{.old} to all marked files, use @kbd{%r} @samp{$}
|
|
837 @kbd{RET} @samp{.old} @kbd{RET}, replacing the empty string at the end
|
|
838 of each file name with @samp{.old}.
|
|
839
|
|
840 You can use the regexp @samp{\(.+\)\.\(.+\)$} to make the
|
|
841 basename as @samp{\1} and the extension as @samp{\2} available in
|
|
842 @var{newtext}.
|
|
843
|
|
844 With a zero prefix arg, renaming by regexp affects the complete
|
|
845 pathname. Usually only the non-directory part of file names is used and
|
|
846 changed, and renaming only takes place within the current directory.
|
|
847 The zero prefix argument can be used to change the directory part as
|
|
848 well.
|
|
849
|
|
850 Often you will want to apply the command to all files matching the same
|
|
851 @var{regexp} that you use in the command. Simply use the @kbd{%m}
|
|
852 command with @var{regexp} as argument, which will then also be the
|
|
853 default for the next regexp using command.@refill For example, to remove
|
|
854 a @file{V17I12-} prefix from several filenames, use @kbd{%m}
|
|
855 @samp{^V17I12-} @kbd{RET} @kbd{%r} @kbd{RET} @kbd{RET}, in effect
|
|
856 replacing the prefix with the empy string.
|
|
857
|
|
858 @node Other File Creating Commands, Deleting Files With Dired, Renaming and More With Regexps, Mark-using Commands
|
|
859 @subsection Other File Creating Commands
|
|
860
|
|
861 @cindex Case-changing Dired commands
|
|
862 @cindex Dired case-changing commands
|
|
863 Commands to change the case of file names:
|
|
864
|
|
865 @table @kbd
|
|
866 @findex dired-upcase
|
|
867 @kindex %u
|
|
868 @item %u
|
|
869 (@code{dired-upcase}) Rename each marked file to upper case.
|
|
870 @findex dired-downcase
|
|
871 @kindex %l
|
|
872 @item %l
|
|
873 (@code{dired-downcase}) Rename each marked file to lower case.
|
|
874 @end table
|
|
875
|
|
876 @node Deleting Files With Dired, Dired Shell Commands, Other File Creating Commands, Mark-using Commands
|
|
877 @subsection Deleting Files With Dired
|
|
878
|
|
879 @noindent
|
|
880 Deleting is a special mark-using command. It uses a special marker,
|
|
881 @samp{D}, and does not default to the current file if no files are
|
|
882 marked to prevent accidental deletions.@refill
|
|
883
|
|
884 @xref{Dired Customization}, variable @code{dired-del-marker} to make
|
|
885 deleting behave exactly like any mark-using command.@refill
|
|
886
|
|
887 @table @kbd
|
|
888
|
|
889 @findex dired-flag-file-deleted
|
|
890 @kindex d
|
|
891 @item d
|
|
892 (@code{dired-flag-file-deleted}) Flag this file for deletion. If on a
|
|
893 subdirectory headerline, mark all its files except @file{.} and @file{..}.
|
|
894
|
|
895 @findex dired-unmark-subdir-or-file
|
|
896 @kindex u
|
|
897 @item u
|
|
898 (@code{dired-unmark-subdir-or-file}) Remove deletion-flag on this line.
|
|
899
|
|
900 @findex dired-backup-unflag
|
|
901 @kindex @key{DEL}
|
|
902 @item @key{DEL}
|
|
903 (@code{dired-backup-unflag}) Remove deletion-flag on previous line,
|
|
904 moving point to that line.
|
|
905
|
|
906 @findex dired-flag-regexp-files
|
|
907 @kindex %d
|
|
908 @item %d
|
|
909 (@code{dired-flag-regexp-files}) Flag all files containing the specified
|
|
910 @var{regexp} for deletion.
|
|
911
|
|
912 The match is against the non-directory part of the filename. Use
|
|
913 @samp{^} and @samp{$} to anchor matches. Exclude subdirs by hiding
|
|
914 them.
|
|
915
|
|
916 The special directories @file{.} and @file{..} are never flagged.
|
|
917
|
|
918 @findex dired-do-deletions
|
|
919 @kindex x
|
|
920 @item x
|
|
921 (@code{dired-do-deletions}) Delete the files that are flagged for
|
|
922 deletion (with @samp{D}).
|
|
923
|
|
924 @findex dired-do-delete
|
|
925 @kindex X
|
|
926 @item X
|
|
927 (@code{dired-do-delete}) Delete the @samp{*}-marked (as opposed to the
|
|
928 @samp{D}-flagged) files.
|
|
929
|
|
930 @findex dired-flag-auto-save-files
|
|
931 @kindex #
|
|
932 @item #
|
|
933 (@code{dired-flag-auto-save-files}) Flag all auto-save files (files
|
|
934 whose names start and end with @samp{#}) for deletion (@pxref{Auto
|
|
935 Save,Auto-Saving: Protection Against Disasters,Auto Save,emacs,The GNU Emacs
|
|
936 Manual}).
|
|
937
|
|
938 @findex dired-flag-backup-files
|
|
939 @kindex ~
|
|
940 @item ~
|
|
941 (@code{dired-flag-backup-files}) Flag all backup files (files whose
|
|
942 names end with @samp{~}) for deletion (@pxref{Backup,Backup
|
|
943 Files,Backup,emacs,The GNU Emacs Manual}).
|
|
944
|
|
945 @findex dired-clean-directory
|
|
946 @kindex .
|
|
947 @item .@: @r{(Period)}
|
|
948 (@code{dired-clean-directory}) Flag excess numeric backup files for
|
|
949 deletion. The oldest and newest few backup files of any one file are
|
|
950 exempt; the middle ones are flagged.
|
|
951 @end table
|
|
952
|
|
953 You can flag a file for deletion by moving to the line describing the
|
|
954 file and typing @kbd{d} or @kbd{C-d}. The deletion flag is visible as a
|
|
955 @samp{D} at the beginning of the line. Point is moved to the beginning
|
|
956 of the next line, so that repeated @kbd{d} commands flag successive
|
|
957 files.
|
|
958
|
|
959 The files are flagged for deletion rather than deleted immediately to
|
|
960 avoid the danger of deleting a file accidentally. Until you direct
|
|
961 Dired to delete the flagged files, you can remove deletion flags using
|
|
962 the commands @kbd{u} and @key{DEL}. @kbd{u} works just like @kbd{d},
|
|
963 but removes flags rather than making flags. @key{DEL} moves upward,
|
|
964 removing flags; it is like @kbd{u} with numeric argument automatically
|
|
965 negated.
|
|
966
|
|
967 To delete the flagged files, type @kbd{x}. This command first displays
|
|
968 a list of all the file names flagged for deletion, and requests
|
|
969 confirmation with @kbd{yes}. Once you confirm, all the flagged files
|
|
970 are deleted, and their lines are deleted from the text of the Dired
|
|
971 buffer. The shortened Dired buffer remains selected. If you answer
|
|
972 @kbd{no} or quit with @kbd{C-g}, you return immediately to Dired, with
|
|
973 the deletion flags still present and no files actually deleted.
|
|
974
|
|
975 Deletions proceed from the end of the buffer, so if subdirs are in a
|
|
976 natural order in the buffer, it usually works to flag @samp{dir1},
|
|
977 @samp{dir1/dir2} and @samp{dir1/dir2/*} (by typing @kbd{d} on the
|
|
978 directory headerlines) and delete everything, including @samp{dir1/dir2}
|
|
979 and @samp{dir1}. Using shell commands (e.g. @samp{rm -rf}) to remove
|
|
980 complete directories may be quicker than having Dired remove each file
|
|
981 separately. (@xref{Dired Shell Commands}.) However, like all actions
|
|
982 external to Dired, this does not update the display.@refill
|
|
983 @c and does not offer to kill buffers of deleted files.
|
|
984
|
|
985 The @kbd{#}, @kbd{~} and @kbd{.} commands flag many files for deletion,
|
|
986 based on their names. These commands are useful precisely because they
|
|
987 do not actually delete any files; you can remove the deletion flags from
|
|
988 any flagged files that you really wish to keep.@refill
|
|
989
|
|
990 @kbd{#} flags for deletion all files that appear to have been made by
|
|
991 auto-saving (that is, files whose names begin and end with @samp{#}).
|
|
992 @kbd{~} flags for deletion all files that appear to have been made as
|
|
993 backups for files that were edited (that is, files whose names end with
|
|
994 @samp{~}).
|
|
995
|
|
996 @vindex dired-kept-versions
|
|
997 @kbd{.} (Period) flags just some of the backup files for deletion: only
|
|
998 numeric backups that are not among the oldest few nor the newest few
|
|
999 backups of any one file. Normally @code{dired-kept-versions} (not
|
|
1000 @code{kept-new-versions}; that applies only when saving) specifies the
|
|
1001 number of newest versions of each file to keep, and
|
|
1002 @code{kept-old-versions} specifies the number of oldest versions to
|
|
1003 keep. Period with a positive numeric argument, as in @kbd{C-u 3 .},
|
|
1004 specifies the number of newest versions to keep, overriding
|
|
1005 @code{dired-kept-versions}. A negative numeric argument overrides
|
|
1006 @code{kept-old-versions}, using minus the value of the argument to
|
|
1007 specify the number of oldest versions of each file to keep.@refill
|
|
1008
|
|
1009 @node Dired Shell Commands, Compressing and Uncompressing, Deleting Files With Dired, Mark-using Commands
|
|
1010 @subsection Shell Commands on Marked files
|
|
1011
|
|
1012 @cindex Shell commands (in Dired)
|
|
1013 @noindent
|
|
1014 You can run arbitrary shell commands on the marked files. If there is
|
|
1015 output, it goes to a separate buffer.
|
|
1016
|
|
1017 @table @kbd
|
|
1018
|
|
1019 @findex dired-do-shell-command
|
|
1020 @kindex !
|
|
1021 @item !
|
|
1022 (@code{dired-do-shell-command}) Run a shell command on the marked
|
|
1023 files.
|
|
1024
|
|
1025 @end table
|
|
1026
|
|
1027 A command string is prompted for in the minibuffer. The list of marked
|
|
1028 files is appended to the command string unless asterisks @samp{*}
|
|
1029 indicate the place(s) where the list should go. Thus,@refill
|
|
1030
|
|
1031 @example
|
|
1032 command -flags
|
|
1033 @end example
|
|
1034
|
|
1035 is equivalent to
|
|
1036
|
|
1037 @example
|
|
1038 command -flags *
|
|
1039 @end example
|
|
1040
|
|
1041 The filenames are inserted in the order they appear in the buffer. The
|
|
1042 file listed topmost in the buffer will be the leftmost in the list.
|
|
1043
|
|
1044 Currently, there is no way to insert a real @samp{*} into the command.
|
|
1045
|
|
1046 As with all mark-using commands, if no files are marked or a specific
|
|
1047 numeric prefix arg is given, the current or the next @var{N} files are
|
|
1048 used. The prompt mentions the file(s) or the marker, as appropriate.
|
|
1049
|
|
1050 However, for shell commands, a zero argument is special. It means to run
|
|
1051 command on each marked file separately:
|
|
1052
|
|
1053 @example
|
|
1054 cmd * |foo
|
|
1055 @end example
|
|
1056
|
|
1057 results in
|
|
1058
|
|
1059 @example
|
|
1060 cmd F1 |foo; @dots{}; cmd F@var{n} |foo
|
|
1061 @end example
|
|
1062
|
|
1063 Usually
|
|
1064
|
|
1065 @example
|
|
1066 cmd F1 @dots{} F@var{n} |foo
|
|
1067 @end example
|
|
1068
|
|
1069 would be executed.@refill
|
|
1070
|
|
1071 No automatic redisplay is attempted because Dired cannot know what files
|
|
1072 should be redisplayed for a general shell command. For example, a
|
|
1073 @samp{tar cvf} will not change the marked files at all, but rather
|
|
1074 create a new file, while a @samp{ci -u -m'@dots{}' *} will probably change
|
|
1075 the permission bits of all marked files.
|
|
1076
|
|
1077 Type @kbd{l} to redisplay just the marked files, or @kbd{l} on a
|
|
1078 directory headerline to redisplay just that directory, or @kbd{g} to
|
|
1079 redisplay all directories.@refill
|
|
1080
|
|
1081 The shell command has the top level directory as working directory, so
|
|
1082 output files usually are created there instead of in a subdirectory,
|
|
1083 which may sometimes be surprising if all files come from the same
|
|
1084 subdirectory. Just remember that an Emacs buffer can have but one
|
|
1085 working directory, and this is the top level directory in Dired
|
|
1086 buffers.
|
|
1087
|
|
1088 Examples for shell commands:
|
|
1089
|
|
1090 @itemize @bullet
|
|
1091
|
|
1092 @item
|
|
1093 Type @kbd{!} and
|
|
1094
|
|
1095 @example
|
|
1096 tar cvf foo.tar
|
|
1097 @end example
|
|
1098
|
|
1099 @noindent
|
|
1100 to tar all marked files into a @file{foo.tar} file. Dired does not know
|
|
1101 that a new file has been created and you have to type @kbd{g} to refresh
|
|
1102 the listing. If you have several subdirectories in your Dired buffer,
|
|
1103 the names given to @samp{tar} will be relative to the top level
|
|
1104 directory, and the output file @file{foo.tar} will also be created
|
|
1105 there.@refill
|
|
1106
|
|
1107 You can use
|
|
1108
|
|
1109 @example
|
|
1110 tar cvf - * | compress -c > foo.tar.Z
|
|
1111 @end example
|
|
1112
|
|
1113 @noindent
|
|
1114 as an alternative to immediately compress the tar file.
|
|
1115
|
|
1116 @item
|
|
1117 Type @kbd{0 !} and
|
|
1118
|
|
1119 @example
|
|
1120 uudecode
|
|
1121 @end example
|
|
1122
|
|
1123 @noindent
|
|
1124 to uudecode each of the marked files. Note the use of the zero prefix
|
|
1125 argument to apply the shell command to each file separately (uudecode
|
|
1126 doesn't accept a list of input files). Type @kbd{g} afterwards to see
|
|
1127 the created files.
|
|
1128
|
|
1129 @item
|
|
1130 Type @kbd{0 !} and
|
|
1131
|
|
1132 @example
|
|
1133 uuencode * * >*.uu
|
|
1134 @end example
|
|
1135
|
|
1136 @noindent
|
|
1137 to uuencode each of the marked files, writing into a corresponding
|
|
1138 @file{.uu} file. Note the use of the zero prefix argument to apply the
|
|
1139 shell command to each file separately. Type @kbd{g} afterwards to see
|
|
1140 the created @file{.uu} files.
|
|
1141
|
|
1142 @item
|
|
1143 Type @kbd{1 !} and
|
|
1144
|
|
1145 @example
|
|
1146 mail joe@@somewhere <*
|
|
1147 @end example
|
|
1148
|
|
1149 @noindent
|
|
1150 to mail the current file (note the prefix argument @samp{1}) to user
|
|
1151 @samp{joe@@somewhere}.@refill
|
|
1152
|
|
1153 @item
|
|
1154 @cindex running the current file
|
|
1155 @cindex executing the current file
|
|
1156 @cindex current file, how to run it
|
|
1157 Here is a Dired shell command to execute the current file, assuming no
|
|
1158 other files are marked (else just give the prefix @kbd{1} to @kbd{!}):
|
|
1159 @example
|
|
1160 ./*
|
|
1161 @end example
|
|
1162 which will be expanded to @samp{./@var{cmd}}, thus @var{cmd} will be
|
|
1163 executed.. (Just @samp{./} would be expanded to @samp{./ @var{cmd}},
|
|
1164 with an intervening @kbd{SPC}.) This will work even if you don't have
|
|
1165 @file{.} in your @code{$PATH}. If @file{.} is in your path (not a good
|
|
1166 idea, as you will find out if you dired a directory containing a file
|
|
1167 named @file{ls}), a single @kbd{SPC} as command would also work.
|
|
1168
|
|
1169 @c <<NEED MORE AND BETTER EXAMPLES HERE>>
|
|
1170 @end itemize
|
|
1171
|
|
1172 @node Compressing and Uncompressing, Changing File Attributes, Dired Shell Commands, Mark-using Commands
|
|
1173 @subsection Compressing and Uncompressing
|
|
1174
|
|
1175 @noindent
|
|
1176 You can compress or uncompress the marked files. Dired refuses to
|
|
1177 compress files ending in @file{.Z} (which are already compressed) or
|
|
1178 symbolic links (the link would be overwritten by a plain, compressed
|
|
1179 file) and to uncompress files not ending in @file{.Z}.
|
|
1180
|
|
1181 @table @kbd
|
|
1182
|
|
1183 @findex dired-do-compress
|
|
1184 @kindex C
|
|
1185 @item C
|
|
1186 (@code{dired-do-compress}) Compress the marked files.
|
|
1187
|
|
1188 @findex dired-do-uncompress
|
|
1189 @kindex U
|
|
1190 @item U
|
|
1191 (@code{dired-do-uncompress}) Uncompress the marked files.
|
|
1192 @end table
|
|
1193
|
|
1194 @node Changing File Attributes, Loading and Byte-compiling Emacs Lisp Files, Compressing and Uncompressing, Mark-using Commands
|
|
1195 @subsection Changing File Attributes
|
|
1196
|
|
1197 @noindent
|
|
1198 You can change the file attributes (mode, group, owner) of marked files.
|
|
1199
|
|
1200 @table @kbd
|
|
1201
|
|
1202 @findex dired-do-chmod
|
|
1203 @kindex M
|
|
1204 @item M
|
|
1205 (@code{dired-do-chmod}) Change the mode (also called ``permission
|
|
1206 bits'') of the marked files. This calls the @samp{chmod} program, thus
|
|
1207 symbolic modes like @samp{g+w} are allowed.
|
|
1208
|
|
1209 Multiple switches like @samp{-fR g+w} are not understood, though. Use
|
|
1210 @kbd{!} (@code{dired-do-shell-command}) for that.
|
|
1211
|
|
1212 @findex dired-do-chgrp
|
|
1213 @kindex G
|
|
1214 @item G
|
|
1215 (@code{dired-do-chgrp}) Change the group of the marked files.
|
|
1216
|
|
1217 @vindex dired-chown-program
|
|
1218 @findex dired-do-chown
|
|
1219 @kindex O
|
|
1220 @item O
|
|
1221 (@code{dired-do-chown}) Change the owner of the marked files. This
|
|
1222 usually works for the superuser only. It uses the program in the
|
|
1223 variable @code{dired-chown-program} to do the change.@refill
|
|
1224 @end table
|
|
1225
|
|
1226 @node Loading and Byte-compiling Emacs Lisp Files, Printing the Marked Files, Changing File Attributes, Mark-using Commands
|
|
1227 @subsection Loading and Byte-compiling Emacs Lisp Files
|
|
1228
|
|
1229 @noindent
|
|
1230 You can load and byte-compile GNU Emacs Lisp files. Errors are caught and
|
|
1231 reported after all files have been processed.
|
|
1232
|
|
1233 @table @kbd
|
|
1234
|
|
1235 @findex dired-do-load
|
|
1236 @kindex L
|
|
1237 @item L
|
|
1238 (@code{dired-do-load}) Load the marked elisp files.
|
|
1239
|
|
1240 @findex dired-do-byte-compile
|
|
1241 @kindex B
|
|
1242 @item B
|
|
1243 (@code{dired-do-byte-compile}) Byte compile the marked elisp files.
|
|
1244 @end table
|
|
1245
|
|
1246 @node Printing the Marked Files, , Loading and Byte-compiling Emacs Lisp Files, Mark-using Commands
|
|
1247 @subsection Printing the Marked Files
|
|
1248
|
|
1249 @table @kbd
|
|
1250 @findex dired-do-print
|
|
1251 @kindex P
|
|
1252 @vindex lpr-command
|
|
1253 @vindex lpr-switches
|
|
1254 @item P
|
|
1255 (@code{dired-do-print}) Print the marked (or next @var{N}) files.
|
|
1256 Uses the shell command coming from variables @code{lpr-command} and
|
|
1257 @code{lpr-switches} as default.
|
|
1258
|
|
1259 Since internally this is just a special case of
|
|
1260 @code{dired-do-shell-command}, you can use @samp{*} and pipes like for
|
|
1261 shell command, e.g.,
|
|
1262 @example
|
|
1263 (setq lpr-command: "lwf")
|
|
1264 (setq lpr-switches: '("-l -m * | lpr -Palw"))
|
|
1265 @end example
|
|
1266 to print with the shell command @samp{lwf -l -m * | lpr -Palw}, where
|
|
1267 @samp{*} will be substituted by the marked files. The @code{lpr-buffer}
|
|
1268 and @code{lpr-region} don't know about @samp{*} or @samp{|}, though, only
|
|
1269 Dired does.
|
|
1270 @end table
|
|
1271
|
|
1272 @node Commands That Do Not Use Marks, Subdirectories in Dired, Mark-using Commands, Dired
|
|
1273 @section Commands That Do Not Use Marks
|
|
1274
|
|
1275 @noindent
|
|
1276 These are commands that visit files.
|
|
1277 @xref{Visiting,Visiting Files,Visiting,emacs,The GNU Emacs Manual}.
|
|
1278
|
|
1279 @table @kbd
|
|
1280
|
|
1281 @findex dired-advertised-find-file
|
|
1282 @kindex f
|
|
1283 @item f
|
|
1284 (@code{dired-advertised-find-file}) Visits the file described on the
|
|
1285 current line. It is just like typing @kbd{C-x C-f} and supplying that
|
|
1286 file name. If the file on this line is a subdirectory, @kbd{f} actually
|
|
1287 causes Dired to be invoked on that subdirectory.
|
|
1288
|
|
1289 @findex dired-find-file-other-window
|
|
1290 @kindex o
|
|
1291 @item o
|
|
1292 (@code{dired-find-file-other-window}) Like @kbd{f}, but uses another
|
|
1293 window to display the file's buffer. The Dired buffer remains visible
|
|
1294 in the first window. This is like using @kbd{C-x 4 C-f} to visit the
|
|
1295 file. @xref{Windows,Multiple Windows,Windows,emacs,The GNU Emacs Manual}.
|
|
1296
|
|
1297 @findex dired-view-file
|
|
1298 @kindex v
|
|
1299 @item v
|
|
1300 (@code{dired-view-file}) Views the file described on this line using
|
|
1301 @kbd{M-x view-file}. Viewing a file is like visiting it, but is slanted
|
|
1302 toward moving around in the file conveniently and does not allow
|
|
1303 changing the file. @xref{Misc File Ops,View File,Miscellaneous File
|
|
1304 Operations,emacs,The GNU Emacs Manual}. @refill Viewing a file that is a
|
|
1305 directory goes to its headerline if it is in this buffer. Otherwise, it
|
|
1306 is displayed in another buffer.
|
|
1307
|
|
1308 @c Forgot that this only works for my version of C-x C-r...
|
|
1309 @c
|
|
1310 @c You might think that a @code{dired-view-file-other-window} command is
|
|
1311 @c missing, but it is easy to use @kbd{o} followed by @kbd{C-x C-r}
|
|
1312 @c @kbd{RET}, which will first visit the file in the other window, then
|
|
1313 @c @samp{find-file-read-only} it (@kbd{RET} defaulting to the current
|
|
1314 @c buffer's file).
|
|
1315
|
|
1316 @end table
|
|
1317
|
|
1318 @cindex Diffing files in Dired
|
|
1319 @noindent
|
|
1320 Commands to diff a file:
|
|
1321
|
|
1322 @table @kbd
|
|
1323
|
|
1324 @findex dired-diff
|
|
1325 @kindex D
|
|
1326 @item D
|
|
1327 (@code{dired-diff}) Compare file at point with another file (default:
|
|
1328 file at mark), by running the system command @samp{diff}. The other
|
|
1329 file is the first file given to @samp{diff}.
|
|
1330
|
|
1331 @findex dired-backup-diff
|
|
1332 @kindex M-~
|
|
1333 @item M-~
|
|
1334 (@code{dired-backup-diff}) Diff this file with its backup file. Uses
|
|
1335 the latest backup, if there are several numerical backups. If this file
|
|
1336 is a backup, diff it with its original. The backup file is the first
|
|
1337 file given to @samp{diff}.
|
|
1338 @end table
|
|
1339
|
|
1340 @noindent
|
|
1341 Other commands:
|
|
1342
|
|
1343 @table @kbd
|
|
1344 @findex dired-create-directory
|
|
1345 @kindex +
|
|
1346 @cindex Creating a directory in Dired
|
|
1347 @cindex Directory, how to create one in Dired
|
|
1348 @item +
|
|
1349 (@code{dired-create-directory}) Create a directory.
|
|
1350 @end table
|
|
1351
|
|
1352 @table @kbd
|
|
1353 @findex dired-why
|
|
1354 @kindex W
|
|
1355 @cindex Why something went wrong in Dired
|
|
1356 @cindex Error logging in Dired
|
|
1357 @item W
|
|
1358 (@code{dired-why}) Pop up a buffer with error log output from Dired.
|
|
1359 All mark-using commands log errors there. (Standard error from shell
|
|
1360 commands cannot be logged separately, it goes into the usual shell
|
|
1361 command output buffer.) A group of errors from a single command ends
|
|
1362 with a formfeed, so that you can use @kbd{C-x [} (@code{backward-page})
|
|
1363 to find the beginning of new error logs that are reported by a command.
|
|
1364
|
|
1365 @end table
|
|
1366
|
|
1367 @node Subdirectories in Dired, Hiding Directories in Dired, Commands That Do Not Use Marks, Dired
|
|
1368 @section Subdirectories in Dired
|
|
1369
|
|
1370 @noindent
|
|
1371 Thise section explains how to @dfn{insert} (or @dfn{expand})
|
|
1372 subdirectories in the same Dired buffer and move around in them.
|
|
1373 @cindex Inserting subdirectories in same Dired buffer
|
|
1374 @cindex Expanding subdirectories in Dired
|
|
1375
|
|
1376 You can display subdirectories in your Dired buffer by using @samp{-R}
|
|
1377 in your Dired listing switches. But you do not usually want to have a
|
|
1378 complete recursive listing in all your Dired buffers. So there is a
|
|
1379 command to insert a single directory:
|
|
1380
|
|
1381 @table @kbd
|
|
1382
|
|
1383 @findex dired-maybe-insert-subdir
|
|
1384 @kindex i
|
|
1385 @item i
|
|
1386 @cindex Inserted subdirectory
|
|
1387 @cindex Expanded subdirectory
|
|
1388 @cindex In-situ subdirectory
|
|
1389 @cindex Headerline
|
|
1390 (@code{dired-maybe-insert-subdir}) Insert this subdirectory into the
|
|
1391 same Dired buffer. If it is already present, just move to it (type
|
|
1392 @kbd{l}, @code{dired-do-redisplay} to refresh it). Else inserts it as
|
|
1393 @samp{ls -lR} would have done. With a prefix arg, you may edit the ls
|
|
1394 switches used for this listing. You can add @samp{R} to the switches to
|
|
1395 expand the whole tree starting at this subdirectory. This function
|
|
1396 takes some pains to conform to @samp{ls -lR} output. For example, it adds the
|
|
1397 headerline for the inserted subdirectory.@refill
|
|
1398
|
|
1399 The mark is dropped before moving, so @kbd{C-x C-x} takes you back to
|
|
1400 the old position in the buffer.
|
|
1401
|
|
1402 @end table
|
|
1403
|
|
1404 Dired changes the buffer-local value of the variable
|
|
1405 @code{page-delimiter} to @code{"\n\n"}, so that subdirectories become
|
|
1406 pages. Thus, the page moving commands @kbd{C-x [} and @kbd{C-x ]}
|
|
1407 (@code{backward-page} and @code{forward-page}) can be used to move to
|
|
1408 the beginning (i.e., the headerlines) of subdirectories.
|
|
1409
|
|
1410 In addition, the following commands move around directory-wise, usually
|
|
1411 putting you on a file line instead of on a headerline. For a mnemonic,
|
|
1412 note that they all look like rotated versions of each other, and that
|
|
1413 they move in the direction they point to.
|
|
1414
|
|
1415 @table @kbd
|
|
1416
|
|
1417 @findex dired-prev-dirline
|
|
1418 @kindex <
|
|
1419 @item <
|
|
1420 (@code{dired-prev-dirline}) Goto previous directory file line.
|
|
1421
|
|
1422 @findex dired-next-dirline
|
|
1423 @kindex >
|
|
1424 @item >
|
|
1425 (@code{dired-next-dirline}) Goto next directory file line.
|
|
1426
|
|
1427 @findex dired-up-directory
|
|
1428 @kindex ^
|
|
1429 @item ^
|
|
1430 (@code{dired-up-directory}) Dired parent directory. Tries first to find
|
|
1431 its file line, then its header line in this buffer, then its Dired
|
|
1432 buffer, finally creating a new Dired buffer if necessary.
|
|
1433
|
|
1434 @findex dired-view-file
|
|
1435 @kindex v
|
|
1436 @item v
|
|
1437 (@code{dired-view-file}) When the current file is not a directory, view
|
|
1438 it. When file is a directory, tries to go to its subdirectory.
|
|
1439
|
|
1440 @comment actually, it is not always inverse
|
|
1441 This command is inverse to the @kbd{^} command and it is very convenient
|
|
1442 to use these two commands together.
|
|
1443
|
|
1444 @end table
|
|
1445
|
|
1446 The following commands move up and down in the directory tree:
|
|
1447
|
|
1448 @table @kbd
|
|
1449
|
|
1450 @findex dired-tree-up
|
|
1451 @kindex M-C-u
|
|
1452 @item M-C-u
|
|
1453 (@code{dired-tree-up}) Go up to the parent directory's headerline.
|
|
1454
|
|
1455 @findex dired-tree-down
|
|
1456 @kindex M-C-d
|
|
1457 @item M-C-d
|
|
1458 (@code{dired-tree-down}) Go down in the tree, to the first
|
|
1459 subdirectory's headerline.
|
|
1460
|
|
1461 @end table
|
|
1462
|
|
1463 The following commands move forwards and backwards to subdirectory headerlines:
|
|
1464
|
|
1465 @table @kbd
|
|
1466
|
|
1467 @findex dired-next-subdir
|
|
1468 @kindex M-C-n
|
|
1469 @item M-C-n
|
|
1470 (@code{dired-next-subdir}) Go to next subdirectory headerline,
|
|
1471 regardless of level.
|
|
1472
|
|
1473 @findex dired-prev-subdir
|
|
1474 @kindex M-C-p
|
|
1475 @item M-C-p
|
|
1476 (@code{dired-prev-subdir}) Go to previous subdirectory headerline,
|
|
1477 regardless of level.
|
|
1478
|
|
1479 @end table
|
|
1480
|
|
1481 @node Hiding Directories in Dired, Acknowledgement, Subdirectories in Dired, Dired
|
|
1482 @section Hiding Directories in Dired
|
|
1483
|
|
1484 @cindex Hiding in Dired
|
|
1485 @noindent
|
|
1486 @dfn{Hiding} a subdirectory means to make it invisible, except for its
|
|
1487 headerline. Files inside a hidden subdirectory are never considered by
|
|
1488 Dired. For example, mark-using commands will not ``see'' files in a
|
|
1489 hidden directory. Thus you can use hiding to temporarily exclude
|
|
1490 subdirectories from operations without having to remove the markers.
|
|
1491
|
|
1492 The hiding commands toggle, that is they unhide what was hidden and vice
|
|
1493 versa.
|
|
1494
|
|
1495 @table @kbd
|
|
1496
|
|
1497 @findex dired-hide-subdir
|
|
1498 @kindex $
|
|
1499 @item $
|
|
1500 (@code{dired-hide-subdir}) Hide or unhide the current subdirectory and
|
|
1501 move to next directory. Optional prefix argument is a repeat factor.
|
|
1502
|
|
1503 @findex dired-hide-all
|
|
1504 @kindex =
|
|
1505 @item =
|
|
1506 (@code{dired-hide-all}) Hide all subdirectories, leaving only their
|
|
1507 header lines. If there is already something hidden, make everything
|
|
1508 visible again. Use this command to get an overview in very deep
|
|
1509 directory trees or to move quickly to subdirs far away.
|
|
1510 @end table
|
|
1511
|
|
1512 @node Acknowledgement, Dired Customization, Hiding Directories in Dired, Dired
|
|
1513 @section Acknowledgement
|
|
1514
|
|
1515 @noindent
|
|
1516 I would like to thank
|
|
1517
|
|
1518 @itemize @bullet
|
|
1519 @item
|
|
1520 Richard Stallman for providing a pre-release version of @file{dired.el}
|
|
1521 from Emacs 19, critical comments and many helpful suggestions
|
|
1522 @item
|
|
1523 Andy Norman for the collaboration that made Tree Dired and ange-ftp such
|
|
1524 a successful combination
|
|
1525 @item
|
|
1526 Jamie Zawinski for insisting on and writing nested Dired format, and for
|
|
1527 lots of other things
|
|
1528 @item
|
|
1529 Michael Ernst for the ``omitting'' code and helpful discussion about
|
|
1530 Dired design
|
|
1531 @item
|
|
1532 Hans Chalupsky for providing FTP service and writing
|
|
1533 @file{dired-trns.el}
|
|
1534 @item
|
|
1535 Roland McGrath for @file{find-dired.el} and bug fixes for the diffing
|
|
1536 commands
|
|
1537 @item
|
|
1538 Kevin Gallagher for sending me existing VMS Dired fixes
|
|
1539 @item
|
|
1540 Hal R. Brand for VMS support and porting his old dired fixes to Tree
|
|
1541 Dired
|
|
1542 @item
|
|
1543 Hugh Secker-Walker for writing @file{dired-cd.el}
|
|
1544 @item
|
|
1545 Tom Wurgler for ideas such as the @dfn{dired-jump-back} command
|
|
1546 @item
|
|
1547 Cengiz Alaettinoglu, who found more bugs in Tree Dired than anybody else
|
|
1548 (except me)
|
|
1549 @end itemize
|
|
1550 @noindent
|
|
1551 and all other beta testers and people who reported bugs or just said
|
|
1552 ``thanks''.
|
|
1553
|
|
1554 @node Dired Customization, , Acknowledgement, Dired
|
|
1555 @section Dired Customization
|
|
1556
|
|
1557 @noindent
|
|
1558 You can customize Dired by setting some variables in your @file{~/.emacs}
|
|
1559 file. Other variables are intended to be configured when Dired is
|
|
1560 installed. Finally, there are so-called `hook' variables.
|
|
1561
|
|
1562 @menu
|
|
1563 * Dired User Options::
|
|
1564 * Dired Configuration::
|
|
1565 * Dired Hooks::
|
|
1566 @end menu
|
|
1567
|
|
1568 @node Dired User Options, Dired Configuration, Dired Customization, Dired Customization
|
|
1569 @subsection Customization of Dired
|
|
1570
|
|
1571 @noindent
|
|
1572 The following variables are for personal customization in your
|
|
1573 @file{~/.emacs} file. For example, include a line similar to the
|
|
1574 following
|
|
1575
|
|
1576 @example
|
|
1577 (setq dired-listing-switches "-Alt") ; sort on time, ignore . and ..
|
|
1578 @end example
|
|
1579
|
|
1580 to set your favorite Dired listing switches.
|
|
1581
|
|
1582 @c Should actually use @defopt here, but this is in Texinfo2 only.
|
|
1583
|
|
1584 @table @code
|
|
1585
|
|
1586 @vindex dired-listing-switches
|
|
1587 @item dired-listing-switches
|
|
1588
|
|
1589 Default: @code{"-al"}
|
|
1590
|
|
1591 Switches passed to @samp{ls} for Dired. @i{Must} contain the @samp{l} option.
|
|
1592
|
|
1593 @vindex dired-trivial-filenames
|
|
1594 @item dired-trivial-filenames
|
|
1595
|
|
1596 Default: @code{"^\\.\\.?$\\|^#"}
|
|
1597
|
|
1598 Regexp of files to skip when moving point to the first file of a new
|
|
1599 directory listing. Nil means move to the subdirectory line, t means move to
|
|
1600 first file.
|
|
1601
|
|
1602 @vindex dired-marker-char
|
|
1603 @item dired-marker-char
|
|
1604
|
|
1605 Default: @code{?*} (@samp{?*} is the Lisp notation for the character
|
|
1606 @samp{*}.)
|
|
1607
|
|
1608 In Dired, character used to mark files for later commands.
|
|
1609
|
|
1610 This is a variable so that one can write things like
|
|
1611
|
|
1612 @example
|
|
1613 (let ((dired-marker-char ?X))
|
|
1614 ;; great code using X markers ...
|
|
1615 )
|
|
1616 @end example
|
|
1617
|
|
1618 @vindex dired-del-marker
|
|
1619 @item dired-del-marker
|
|
1620
|
|
1621 Default: @code{?D}
|
|
1622
|
|
1623 Character used to flag files for deletion.
|
|
1624
|
|
1625 Usually, marking for commands and flagging for deletion are separate
|
|
1626 features. (Internally they use the same marking mechanism.) You type
|
|
1627 @kbd{d} to flag with @samp{D} and @kbd{x} to delete the @samp{D}-flagged
|
|
1628 files.@refill
|
|
1629
|
|
1630 This explains how to make deletion behave just like a special case of
|
|
1631 the general file marking feature, so that you type @kbd{m} to mark with
|
|
1632 @samp{*} (as usual) and @kbd{d} to delete the @samp{*} (or next @var{N})
|
|
1633 files: In your @file{~/.emacs}, include
|
|
1634
|
|
1635 @example
|
|
1636 (setq dired-del-marker dired-marker-char) ; use * also for deletions
|
|
1637 (setq dired-load-hook
|
|
1638 (function
|
|
1639 (lambda ()
|
|
1640 ;; other customizations here
|
|
1641 ;; let "d" do the actual deletion:
|
|
1642 (define-key dired-mode-map "d" 'dired-do-delete))))
|
|
1643 @end example
|
|
1644
|
|
1645 If you do not like that @kbd{d} defaults to the current file if there
|
|
1646 are no marks, replace the @code{define-key} statement in
|
|
1647 @code{dired-load-hook} above with this one:
|
|
1648
|
|
1649 @example
|
|
1650 (define-key dired-mode-map "d" 'dired-do-deletions)
|
|
1651 @end example
|
|
1652
|
|
1653 @vindex dired-shrink-to-fit
|
|
1654 @item dired-shrink-to-fit
|
|
1655
|
|
1656 Default: @code{(if (fboundp 'baud-rate) (> (baud-rate) search-slow-speed) t)}
|
|
1657
|
|
1658 Whether Dired shrinks the display buffer to fit the marked files.
|
|
1659
|
|
1660 @vindex dired-no-confirm
|
|
1661 @item dired-no-confirm
|
|
1662
|
|
1663 Default: @code{nil}
|
|
1664
|
|
1665 If non-nil, list of commands Dired should not confirm. Confirmation for
|
|
1666 commands that require an argument to be entered (like the shell command
|
|
1667 for @kbd{!}) means a list of marked files is displayed in a pop-up
|
|
1668 buffer. Confirmation for commands that do not require an argument (like
|
|
1669 compressing with @kbd{C}) means you have to confirm by typing @kbd{y} or
|
|
1670 @kbd{SPC}.
|
|
1671
|
|
1672 Except @code{nil}, it can be a sublist of
|
|
1673
|
|
1674 @example
|
|
1675 '(byte-compile chgrp chmod chown compress copy delete hardlink load
|
|
1676 move print shell symlink uncompress)
|
|
1677 @end example
|
|
1678
|
|
1679 to suppress confirmation for just those commands.
|
|
1680
|
|
1681 @c @vindex dired-deletion-confirmer
|
|
1682 @c But you can
|
|
1683 @c set the variable @code{dired-deletion-confirmer} to another function
|
|
1684 @c than @code{yes-or-no-p}, its default value. Using @code{y-or-no-p} will
|
|
1685 @c confirm with only a single key stroke, @key{y} or @key{n}, and using
|
|
1686 @c @code{identity} will effectively switch off confirmation.
|
|
1687
|
|
1688 @vindex dired-keep-marker-move
|
|
1689 @item dired-keep-marker-move
|
|
1690
|
|
1691 Default: @code{t}
|
|
1692
|
|
1693 If nil, moved files are not marked.
|
|
1694
|
|
1695 If t, moved marked files are marked with the same marker they had before
|
|
1696 (maybe none if you used the prefix argument to specify the next @var{N}
|
|
1697 files).
|
|
1698
|
|
1699 If a character, moved files (marked or not) are marked with that
|
|
1700 character.
|
|
1701
|
|
1702 This also applies to the following, similar variables for copied, and
|
|
1703 hard or symbolically linked files:
|
|
1704
|
|
1705 @vindex dired-keep-marker-copy
|
|
1706 @item dired-keep-marker-copy
|
|
1707
|
|
1708 Default: @code{?C}
|
|
1709
|
|
1710 @vindex dired-keep-marker-hardlink
|
|
1711 @item dired-keep-marker-hardlink
|
|
1712
|
|
1713 Default: @code{?H}
|
|
1714
|
|
1715 @vindex dired-keep-marker-symlink
|
|
1716 @item dired-keep-marker-symlink
|
|
1717
|
|
1718 Default: @code{?Y}
|
|
1719
|
|
1720 @vindex dired-dwim-target
|
|
1721 @item dired-dwim-target
|
|
1722
|
|
1723 Default: @code{nil}
|
|
1724
|
|
1725 If non-nil, Dired tries to guess a default target directory: If there is
|
|
1726 a Dired buffer displayed in the next window, use its current subdirectory,
|
|
1727 instead of the current subdirectory of this Dired buffer.
|
|
1728
|
|
1729 The target is used in the prompt for file copy, move etc.,
|
|
1730 @xref{Copy and Move Into a Directory}.
|
|
1731
|
|
1732 @item dired-copy-preserve-time
|
|
1733 @vindex dired-copy-preserve-time
|
|
1734
|
|
1735 Default: @code{nil}
|
|
1736
|
|
1737 If non-nil, Dired preserves the last-modified time in a file copy.
|
|
1738 (This works on only some systems.) Use @kbd{c} (@code{dired-do-copy})
|
|
1739 with a zero prefix argument to toggle its value. The prompt of copy
|
|
1740 commands will display @samp{Copy [-p]} instead of just @samp{Copy} if
|
|
1741 preservation of file times is turned on.
|
|
1742
|
|
1743 @item dired-backup-if-overwrite
|
|
1744 @vindex dired-backup-if-overwrite
|
|
1745
|
|
1746 Default: @code{nil}
|
|
1747
|
|
1748 Non-nil if Dired should ask about making backups before overwriting files.
|
|
1749 Special value @code{'always} suppresses confirmation.
|
|
1750
|
|
1751 @end table
|
|
1752
|
|
1753 @node Dired Configuration, Dired Hooks, Dired User Options, Dired Customization
|
|
1754 @subsection Dired Configuration
|
|
1755
|
|
1756 The following variables should have already been installed correctly by
|
|
1757 your system manager. If not, you can still set them in your
|
|
1758 @file{~/.emacs} file.@refill
|
|
1759
|
|
1760 @table @code
|
|
1761
|
|
1762 @vindex dired-chown-program
|
|
1763 @item dired-chown-program
|
|
1764 Pathname of chown command, default @code{"chown"} (or
|
|
1765 @code{"/etc/chown"} on System V derived systems.)
|
|
1766
|
|
1767 @vindex dired-ls-program
|
|
1768 @item dired-ls-program
|
|
1769 Absolute or relative name of the @samp{ls} program used by Dired,
|
|
1770 default @code{"ls"}.
|
|
1771
|
|
1772 @vindex dired-ls-F-marks-symlinks
|
|
1773 @item dired-ls-F-marks-symlinks
|
|
1774 Set this to @code{t} if dired-ls-program with @samp{-lF} marks the
|
|
1775 symbolic link itself with a trailing @samp{@@} (usually the case under
|
|
1776 Ultrix).
|
|
1777
|
|
1778 Example: If
|
|
1779
|
|
1780 @example
|
|
1781 ln -s foo bar; ls -F bar
|
|
1782 @end example
|
|
1783
|
|
1784 gives
|
|
1785
|
|
1786 @example
|
|
1787 bar -> foo
|
|
1788 @end example
|
|
1789
|
|
1790 set it to @code{nil}, if it gives
|
|
1791
|
|
1792 @example
|
|
1793 bar@@ -> foo
|
|
1794 @end example
|
|
1795
|
|
1796 set it to @code{t}.
|
|
1797
|
|
1798 Dired checks if there is really a @@ appended. Thus, if you have a
|
|
1799 marking @samp{ls} program on one host and a non-marking one on another
|
|
1800 host, and do not care about symbolic links which really end in a @@, you
|
|
1801 can always set this variable to @code{t}.
|
|
1802
|
|
1803 @end table
|
|
1804
|
|
1805
|
|
1806 @node Dired Hooks, , Dired Configuration, Dired Customization
|
|
1807 @subsection Dired Hooks
|
|
1808
|
|
1809 @noindent
|
|
1810 Hook variables can contain functions that are run at certain times in
|
|
1811 Dired.
|
|
1812
|
|
1813 @table @code
|
|
1814
|
|
1815 @vindex dired-load-hook
|
|
1816 @item dired-load-hook
|
|
1817
|
|
1818 Run after loading Dired. You can customize key bindings or load
|
|
1819 extensions with this. For example:
|
|
1820
|
|
1821 @example
|
|
1822 (setq dired-load-hook
|
|
1823 (function
|
|
1824 (lambda ()
|
|
1825 ;; Load extras:
|
|
1826 (load "dired-x")
|
|
1827 ;; How to define your own key bindings:
|
|
1828 (define-key dired-mode-map " " 'scroll-up)
|
|
1829 (define-key dired-mode-map "b" 'scroll-down))))
|
|
1830 @end example
|
|
1831
|
|
1832 @vindex dired-mode-hook
|
|
1833 @item dired-mode-hook
|
|
1834
|
|
1835 Run at the very end of @code{dired-mode}, after most buffer local
|
|
1836 variables have been initialized (e.g., @code{default-directory} and
|
|
1837 @code{dired-directory}), but before the directory listing has been read
|
|
1838 in.
|
|
1839
|
|
1840 Do buffer local things here, for example:
|
|
1841
|
|
1842 @example
|
|
1843 (setq dired-mode-hook
|
|
1844 (function
|
|
1845 (lambda ()
|
|
1846 (dired-extra-startup) ;; dired-extra support
|
|
1847 ;; How to set (local) variables in each new Dired buffer:
|
|
1848 (setq case-fold-search t)
|
|
1849 (setq truncate-lines t))))
|
|
1850 @end example
|
|
1851
|
|
1852 Since the listing has not yet been inserted you could still change
|
|
1853 @code{dired-actual-switches}. For example, if you use
|
|
1854 @file{ange-ftp.el}, you might want to replace the @samp{-A} with the
|
|
1855 @samp{-a} switch, depending on whether @code{default-directory}
|
|
1856 corresponds to a System V hosts that does not understand all BSD
|
|
1857 @samp{ls} switches. The @code{dired.README} file gives an example. If
|
|
1858 you set @code{dired-actual-switches} remember that you may also have to
|
|
1859 set @code{dired-sort-mode} to the appropriate string so that the
|
|
1860 modeline looks right.
|
|
1861
|
|
1862 Do not set @code{dired-mode-hook} inside your @code{dired-load-hook},
|
|
1863 simply set it somewhere in your @file{~/.emacs} (before Dired is loaded,
|
|
1864 if you explicitly load Dired). This is so that extensions packages
|
|
1865 loaded via the load hook can add things to the @code{dired-mode-hook} at
|
|
1866 the front or at the end, as they see fit.
|
|
1867
|
|
1868 In case you set @code{truncate-lines} to @code{t} as in the above
|
|
1869 example, here is a function to toggle the value of
|
|
1870 @code{truncate-lines}, in Dired and other buffers:
|
|
1871 @example
|
|
1872 (defun set-truncate-lines ()
|
|
1873 "Toggle value of truncate-lines and refresh window display."
|
|
1874 (interactive)
|
|
1875 (setq truncate-lines (not truncate-lines))
|
|
1876 ;; now refresh window display (an idiom from simple.el):
|
|
1877 (save-excursion
|
|
1878 (set-window-start (selected-window)
|
|
1879 (window-start (selected-window)))))
|
|
1880 @end example
|
|
1881 You could bind it to @kbd{C-x 4 $}:
|
|
1882 @example
|
|
1883 (define-key ctl-x-4-map "$" 'set-truncate-lines)
|
|
1884 @end example
|
|
1885 It is sometimes useful to toggle @code{truncate-lines} in Dired buffers
|
|
1886 to make long filenames completely visible and get the listing properly
|
|
1887 aligned again.
|
|
1888
|
|
1889 @vindex dired-before-readin-hook
|
|
1890 @item dired-before-readin-hook
|
|
1891 This hook is run before a dired buffer is newly read in (created or reverted).
|
|
1892
|
|
1893 @vindex dired-after-readin-hook
|
|
1894 @item dired-after-readin-hook
|
|
1895
|
|
1896 After each listing of a file or directory, this hook is run with the
|
|
1897 buffer narrowed to the listing.
|
|
1898
|
|
1899 The @code{dired-subdir-alist} has already been updated so that the usual
|
|
1900 Dired functions like @code{dired-get-filename} work. It is possible to
|
|
1901 modify the buffer with this hook. The package @file{dired-x.el} does
|
|
1902 this to implement omitting certain uninteresting files from a Dired
|
|
1903 buffer. Under X11, highlighting of certain files is also possible (see
|
|
1904 package @file{dired-x11.el}).
|
|
1905
|
|
1906 @end table
|
|
1907
|
|
1908 @node Tree Dired Extra, Dired Internals, Dired, Top
|
|
1909 @chapter Tree Dired Extra features
|
|
1910
|
|
1911 Numerous ``extra'' features are available, such as omitting certain
|
|
1912 files from listings, minibuffer history, RCS related commands, and more.
|
|
1913
|
|
1914 @menu
|
|
1915 * Tree Dired Extra Features::
|
|
1916 * Dired Minibuffer History::
|
|
1917 * Inserting All Marked Subdirectories::
|
|
1918 * Dynamic Dired Markers::
|
|
1919 * Omitting Files in Dired::
|
|
1920 * Advanced Dired Mark Commands::
|
|
1921 * Virtual Dired::
|
|
1922 * Multiple Dired Directories::
|
|
1923 * Dired Local Variables::
|
|
1924 * Making Relative Symbolic Links in Dired::
|
|
1925 * Letting Dired Guess What Shell Command to Apply::
|
|
1926 * dired-trns.el:: Filename Transformers for Dired Shell Commands
|
|
1927 * dired-cd.el:: Changing the Working Directory for Dired Shell Commands
|
|
1928 * dired-nstd.el:: Nested Dired format
|
|
1929 * find-dired.el:: Feeding Find Output to Dired
|
|
1930 @end menu
|
|
1931
|
|
1932 @node Tree Dired Extra Features, Dired Minibuffer History, Tree Dired Extra, Tree Dired Extra
|
|
1933 @section Tree Dired Extra Features
|
|
1934
|
|
1935 The rest of this manual describes the extra features provided by the
|
|
1936 file @file{dired-x.el} and some other files.
|
|
1937
|
|
1938 To take advantage of these features, you must load the file and set some
|
|
1939 variables and hooks. See the accompanying @file{dired-x.README}
|
|
1940 file for details and a template of code to insert in your @file{.emacs}.
|
|
1941
|
|
1942 Miscellanous features not fitting anywhere else:
|
|
1943
|
|
1944 Variables:
|
|
1945
|
|
1946 @table @code
|
|
1947
|
|
1948 @item dired-find-subdir
|
|
1949 @vindex dired-find-subdir
|
|
1950 Default: @code{nil}
|
|
1951
|
|
1952 If non-nil, Dired does not make a new buffer for a directory if it
|
|
1953 can be found (perhaps as subdirectory) in some existing Dired buffer.
|
|
1954
|
|
1955 If there are several Dired buffers for a directory, the most recently
|
|
1956 used is chosen.
|
|
1957
|
|
1958 Dired avoids switching to the current buffer, so that if you have a
|
|
1959 normal and a wildcard buffer for the same directory, @kbd{C-x d RET}
|
|
1960 will toggle between those two.
|
|
1961
|
|
1962 @end table
|
|
1963
|
|
1964 @table @kbd
|
|
1965
|
|
1966 @findex dired-goto-file
|
|
1967 @kindex M-g
|
|
1968 @item M-g
|
|
1969 (@code{dired-goto-file}) Goto file line of a file (or directory).
|
|
1970
|
|
1971 @findex dired-goto-subdir
|
|
1972 @kindex M-G
|
|
1973 @item M-G
|
|
1974 (@code{dired-goto-subdir}) Goto headerline of an inserted directory.
|
|
1975 This commands reads its argument with completion over the names of the
|
|
1976 inserted subdirectories.
|
|
1977 @end table
|
|
1978
|
|
1979 @table @kbd
|
|
1980
|
|
1981 @findex dired-do-background-shell-command
|
|
1982 @kindex &
|
|
1983 @cindex Input to Dired shell commands
|
|
1984 @cindex Interactive Dired shell commands
|
|
1985 @cindex Background Dired shell commands
|
|
1986 @item &
|
|
1987 (@code{dired-do-background-shell-command}) Run a shell command on the
|
|
1988 marked files, in the background. This requires @file{background.el}
|
|
1989 from Olin Shiver's comint package to work. Note that you can type input
|
|
1990 to the command in its buffer.
|
|
1991
|
|
1992 @item w
|
|
1993 @kindex w
|
|
1994 @findex dired-copy-filename-as-kill
|
|
1995 (@code{dired-copy-filename-as-kill}) The @kbd{w} command puts the names
|
|
1996 of the marked (or next @var{N}) files into the kill ring, as if you had
|
|
1997 killed them with @kbd{C-w}. With a zero prefix argument @var{N}=0, use the
|
|
1998 complete pathname of each file. With a raw (just @kbd{C-u}) prefix argument,
|
|
1999 use the relative pathname of each marked file. As a special case, if no
|
|
2000 prefix argument is given and point is on a directory headerline, it
|
|
2001 gives you the name of that directory, without looking for marked files.
|
|
2002
|
|
2003 @vindex dired-marked-files
|
|
2004 The list of names is also stored onto the variable @code{dired-marked-files}
|
|
2005 for use, e.g., in an @kbd{ESC ESC} (@code{eval-expression}) command.
|
|
2006
|
|
2007 As this command also displays what was pushed onto the kill ring you can
|
|
2008 use it to display the list of currently marked files in the
|
|
2009 echo area (unless you happen to be on a subdirectory headerline).
|
|
2010
|
|
2011 You can then feed the file name to other Emacs commands with @kbd{C-y}.
|
|
2012 For example, say you want to rename a long filename to a slightly
|
|
2013 different name. First type @kbd{w} to push the old name onto the kill
|
|
2014 ring. Then type @kbd{r} to rename it and use @kbd{C-y} inside @kbd{r}'s
|
|
2015 minibuffer prompt to insert the old name at a convenient place.
|
|
2016
|
|
2017 @item T
|
|
2018 @kindex T
|
|
2019 @findex dired-do-toggle
|
|
2020 (@code{dired-do-toggle}) Toggle marks. That is, currently marked
|
|
2021 files become unmarked and vice versa. Files marked with other flags
|
|
2022 (such as `D') are not affected. The special directories `.' and `..'
|
|
2023 are never toggled.
|
|
2024
|
|
2025 @end table
|
|
2026
|
|
2027 @node Dired Minibuffer History, Inserting All Marked Subdirectories, Tree Dired Extra Features, Tree Dired Extra
|
|
2028 @section Minibuffer History for Dired Shell Commands
|
|
2029
|
|
2030 @cindex History of Minibuffer input
|
|
2031 @cindex Minibuffer History
|
|
2032 @cindex Gmhist
|
|
2033 @kindex !
|
|
2034 @kindex &
|
|
2035 @kindex M-p
|
|
2036 @kindex M-n
|
|
2037 If @file{dired-x.el} determines at load-time that the Gmhist package is
|
|
2038 available, the Dired shell commands @kbd{!} and @kbd{&} maintain a
|
|
2039 history of commands. Use @kbd{M-p} and @kbd{M-n} to scroll through them
|
|
2040 while you are prompted in the minibuffer for a shell command.
|
|
2041 @xref{Gmhist Keys in the Minibuffer,Gmhist Keys in the Minibuffer,Gmhist
|
|
2042 Keys in the Minibuffer,gmhist,The Gmhist Manual}, for more info.
|
|
2043
|
|
2044 Gmhist also handles defaults:
|
|
2045
|
|
2046 @table @code
|
|
2047
|
|
2048 @vindex dired-dangerous-shell-command
|
|
2049 @item dired-dangerous-shell-command
|
|
2050 Default: @code{"rm"}
|
|
2051
|
|
2052 Regexp for dangerous shell commands that should never be the default.
|
|
2053 It is deliberately chosen to match @samp{rm} anywhere in the command,
|
|
2054 e.g. in @samp{rmdir}.
|
|
2055 @end table
|
|
2056
|
|
2057 @node Inserting All Marked Subdirectories, Dynamic Dired Markers, Dired Minibuffer History, Tree Dired Extra
|
|
2058 @section Insert all marked subdirectories
|
|
2059
|
|
2060 @table @kbd
|
|
2061
|
|
2062 @kindex I
|
|
2063 @findex dired-do-insert-subdir
|
|
2064 @item I
|
|
2065 (@code{dired-do-insert-subdir}) Insert all marked subdirectories that
|
|
2066 are not already inserted. Non-directories are silently ignored.
|
|
2067
|
|
2068 Thus type @kbd{/I} to insert one more level of subdirectories. You can
|
|
2069 repeat this until no new directories are inserted to fully expand the
|
|
2070 directory tree in this buffer. As a faster alternative, use the prefix
|
|
2071 argument for @kbd{C-x d} (@code{dired}) to add @samp{R} to the switches.
|
|
2072
|
|
2073 @end table
|
|
2074
|
|
2075 @node Dynamic Dired Markers, Omitting Files in Dired, Inserting All Marked Subdirectories, Tree Dired Extra
|
|
2076 @section Dynamic Marker Characters
|
|
2077
|
|
2078 @cindex Dynamic marker characters
|
|
2079 @cindex Marker characters in Dired, changing them
|
|
2080 @cindex Changing marker character in Dired
|
|
2081 @cindex Stack of marker characters in Dired
|
|
2082 You can change the marker character from its usual value @code{*} to
|
|
2083 something else. Use this to mark a different set of files while keeping
|
|
2084 the information on the already marked files. You can nest several
|
|
2085 marker characters. The current stack of marker characters is displayed
|
|
2086 in the Dired mode line, and all prompts of mark-using commands mention
|
|
2087 to which marker they apply.
|
|
2088
|
|
2089 @table @kbd
|
|
2090
|
|
2091 @item (
|
|
2092 @kindex (
|
|
2093 @findex dired-set-marker-char
|
|
2094 (@code{dired-set-marker-char}) Set the marker character to something
|
|
2095 else. Use @kbd{)} to restore the previous value.
|
|
2096
|
|
2097 @item )
|
|
2098 @kindex )
|
|
2099 @findex dired-restore-marker-char
|
|
2100 (@code{dired-restore-marker-char}) Restore the marker character to its
|
|
2101 previous value. Uses @code{dired-default-marker} if the marker stack is
|
|
2102 empty.
|
|
2103 @end table
|
|
2104
|
|
2105 @kindex A
|
|
2106 @kindex Z
|
|
2107 @kindex m
|
|
2108 @kindex (
|
|
2109 Instead of using @kbd{m} inside a @kbd{(}@dots{}@kbd{)}, you can mark
|
|
2110 files ``in passing'' with, say @samp{Z} without changing the
|
|
2111 current marker character. You will probably later use @kbd{(} to
|
|
2112 temporarily make @samp{Z} to the marker and do something on the
|
|
2113 @samp{Z}-files, and then return using @code{)}.
|
|
2114
|
|
2115 @table @code
|
|
2116
|
|
2117 @item dired-mark-keys
|
|
2118 Default: @code{'("Z")}
|
|
2119
|
|
2120 List of keys (strings) that insert themselves as file markers.
|
|
2121
|
|
2122 @end table
|
|
2123
|
|
2124
|
|
2125 @node Omitting Files in Dired, Advanced Dired Mark Commands, Dynamic Dired Markers, Tree Dired Extra
|
|
2126 @section Omitting Files in Dired
|
|
2127
|
|
2128 @cindex Omitting Files in Dired
|
|
2129 @dfn{Omitting} a file means removing it from the directory listing.
|
|
2130 Omitting is useful for keeping Dired buffers free of uninteresting files
|
|
2131 (for instance, auto-save, auxiliary, backup, and revision control files)
|
|
2132 so that the user can concentrate on the interesting files. Like hidden
|
|
2133 files, omitted files are never seen by Dired.
|
|
2134 @xref{Dired Hiding,Hiding in Dired,Hiding in Dired,dired,Tree Dired Manual}.
|
|
2135 Omitting differs from hiding in several respects:
|
|
2136
|
|
2137 @itemize @bullet
|
|
2138
|
|
2139 @item
|
|
2140 Omitting works on individual files, not on directories; an entire
|
|
2141 directory cannot be omitted (though each of its files could be).
|
|
2142
|
|
2143 @item
|
|
2144 Omitting is wholesale; if omitting is turned on for a dired buffer, then
|
|
2145 all ``uninteresting'' files listed in that buffer are omitted. The user
|
|
2146 does not omit (or unomit) files one at a time.
|
|
2147
|
|
2148 @item
|
|
2149 Omitting can be automatic; uninteresting file lines in the buffer can
|
|
2150 be removed before the user ever sees them.
|
|
2151
|
|
2152 @item
|
|
2153 Marked files are never omitted.
|
|
2154 @end itemize
|
|
2155
|
|
2156 @table @kbd
|
|
2157
|
|
2158 @item M-o
|
|
2159 @kindex M-o
|
|
2160 @findex dired-omit-toggle
|
|
2161 (@code{dired-omit-toggle})
|
|
2162 Toggle between displaying and omitting ``uninteresting'' files.
|
|
2163 With a prefix argument, don't toggle and just mark the files, but don't
|
|
2164 actually omit them.
|
|
2165 @end table
|
|
2166
|
|
2167 In order to make omitting work, you must have @code{dired-omit-expunge}
|
|
2168 on your @code{dired-after-readin-hook}, and you must call
|
|
2169 @code{dired-omit-startup} (or @code{dired-extra-startup}, which calls
|
|
2170 @code{dired-omit-startup}) in your @code{dired-mode-hook}. Simply
|
|
2171 loading @file{dired-x.el} inside @code{dired-load-hook} takes care of
|
|
2172 all this.
|
|
2173
|
|
2174 The following variables can be used to customize omitting.
|
|
2175
|
|
2176 @table @code
|
|
2177
|
|
2178 @vindex dired-omit-files-p
|
|
2179 @item dired-omit-files-p
|
|
2180
|
|
2181 Default: @code{nil}
|
|
2182
|
|
2183 @cindex How to make omitting the default in Dired
|
|
2184 If non-nil, ``uninteresting'' files are not listed. Uninteresting files
|
|
2185 are those whose filenames match regexp @code{dired-omit-files}, plus those
|
|
2186 ending with extensions in @code{dired-omit-extensions}. @kbd{M-o}
|
|
2187 (@code{dired-omit-toggle}) toggles its value, which is buffer-local. Do
|
|
2188
|
|
2189 @example
|
|
2190 (setq dired-omit-files-p t)
|
|
2191 @end example
|
|
2192
|
|
2193 inside your @code{dired-mode-hook} to have omitting initially turned on
|
|
2194 in every Dired buffer. Since @file{dired-x.el} prepends the form
|
|
2195 @samp{(dired-extra-startup)} to what you put yourself in your
|
|
2196 @code{dired-mode-hook}, the @code{setq} will take place after
|
|
2197 @code{dired-omit-files-p} has already been made local to the current
|
|
2198 Dired buffer, so modelines of non-dired buffers are not affected. For
|
|
2199 this to work you shouldn't set @code{dired-mode-hook} inside
|
|
2200 @code{dired-load-hook}, but directly in your @file{~/.emacs} (before
|
|
2201 Dired is loaded, if you explicitly load Dired).
|
|
2202
|
|
2203 You can then use @kbd{M-o} to unomit in that buffer.
|
|
2204
|
|
2205 @vindex dired-omit-files
|
|
2206 @item dired-omit-files
|
|
2207
|
|
2208 Default: @code{"^#\\|\\.$"}
|
|
2209
|
|
2210 Filenames matching this buffer-local regexp will not be displayed.
|
|
2211 This only has effect when @code{dired-omit-files-p} is t.
|
|
2212
|
|
2213 The default value omits the special directories @file{.} and @file{..}
|
|
2214 and autosave files (plus other files ending in ``.'').
|
|
2215
|
|
2216 @vindex dired-omit-extensions
|
|
2217 @item dired-omit-extensions
|
|
2218
|
|
2219 Default: The elements of @code{completion-ignored-extensions},
|
|
2220 @code{latex-unclean-extensions}, @code{bibtex-unclean-extensions} and
|
|
2221 @code{texinfo-unclean-extensions}.
|
|
2222
|
|
2223 If non-nil, a list of extensions (strings) to omit from Dired listings.
|
|
2224 Its format is the same as that of @code{completion-ignored-extensions}.
|
|
2225
|
|
2226 @vindex dired-omit-localp
|
|
2227 @item dired-omit-localp
|
|
2228
|
|
2229 Default: @code{'no-dir}
|
|
2230
|
|
2231 The @var{localp} argument @code{dired-omit-expunge} passes to
|
|
2232 @code{dired-get-filename}. If it is @code{'no-dir}, omitting is much
|
|
2233 faster, but you can only match against the non-directory part of the
|
|
2234 filename. Set it to @code{nil} if you need to match the whole pathname
|
|
2235 or @code{t} to match the pathname relative to the buffer's top-level
|
|
2236 directory.
|
|
2237
|
|
2238 @item dired-omit-marker-char
|
|
2239 @vindex dired-omit-marker-char
|
|
2240
|
|
2241 Default: @kbd{C-o}
|
|
2242
|
2
|
2243 Temporary marker used by Dired to implement omitting.
|
0
|
2244 Should never be used as marker by the user or other packages.
|
|
2245 @cindex Omitting additional files
|
|
2246 There is one exception to this rule: by doing
|
|
2247 @example
|
|
2248 (setq dired-mark-keys "\C-o")
|
|
2249 ;; i.e., the value of dired-omit-marker-char
|
|
2250 ;; (which is not defined yet)
|
|
2251 @end example
|
|
2252 anywhere in your @file{~/.emacs}, you will bind the @kbd{C-o} key to
|
|
2253 insert a @key{C-o} marker, thus causing these files to be omitted in
|
|
2254 addition to the usually omitted files. Unfortunately the files you
|
|
2255 omitted manually this way will show up again after reverting the buffer,
|
|
2256 unlike the others.
|
|
2257
|
|
2258 @end table
|
|
2259
|
|
2260 @cindex RCS files, how to omit them in Dired
|
|
2261 @cindex Omitting RCS files in Dired
|
|
2262 To avoid seeing RCS files and the RCS directory, do
|
|
2263 @example
|
|
2264 (setq dired-omit-files "\\.$\\|#\\|^RCS$\\|,v$")
|
|
2265 @end example
|
|
2266 This assumes @code{dired-omit-localp} has its default value of
|
|
2267 @code{'no-dir} to make the @code{^}-anchored matches work. As a slower
|
|
2268 alternative, with @code{dired-omit-localp} set to @code{nil}, you can
|
|
2269 use @code{/} instead of @code{^} in the regexp.
|
|
2270
|
|
2271 @cindex Tib files, how to omit them in Dired
|
|
2272 @cindex Omitting tib files in Dired
|
|
2273 If you use tib, the bibliography program for use with @TeX{} and
|
|
2274 La@TeX{}, you might want to omit the @file{INDEX} and the @file{-t.tex}
|
|
2275 files:
|
|
2276 @example
|
|
2277 (setq dired-omit-files "\\.$\\|#\\|^INDEX$\\|-t\\.tex$")
|
|
2278 @end example
|
|
2279
|
|
2280 @node Advanced Dired Mark Commands, Virtual Dired, Omitting Files in Dired, Tree Dired Extra
|
|
2281 @section Advanced Mark Commands
|
|
2282
|
|
2283 @table @kbd
|
|
2284
|
|
2285 @item M-(
|
|
2286 @kindex M-(
|
|
2287 @findex dired-mark-sexp
|
|
2288 @cindex Lisp expression, marking files with in Dired
|
|
2289 @cindex Mark file by lisp expression
|
|
2290 (@code{dired-mark-sexp}) Mark files for which @var{predicate} returns non-nil.
|
|
2291 With a prefix argument, unflag those files instead.
|
|
2292
|
|
2293 The @var{predicate} is a lisp expression that can refer to the following
|
|
2294 symbols:
|
|
2295 @table @code
|
|
2296 @item inode
|
|
2297 [@i{integer}] the inode of the file (only for @samp{ls -i} output)
|
|
2298 @item s
|
|
2299 [@i{integer}] the size of the file for @samp{ls -s} output (usually in blocks or,
|
|
2300 with @samp{-k}, in KBytes)
|
|
2301 @item mode
|
|
2302 [@i{string}] file permission bits, e.g., @samp{"-rw-r--r--"}
|
|
2303 @item nlink
|
|
2304 [@i{integer}] number of links to file
|
|
2305 @item uid
|
|
2306 [@i{string}] owner
|
|
2307 @item gid
|
|
2308 [@i{string}] group (If the gid is not displayed by @samp{ls}, this
|
|
2309 will still be set (to the same as uid))
|
|
2310 @item size
|
|
2311 [@i{integer}] file size in bytes
|
|
2312 @item time
|
|
2313 [@i{string}] the time that @samp{ls} displays, e.g., @samp{"Feb 12 14:17"}
|
|
2314 @item name
|
|
2315 [@i{string}] the name of the file
|
|
2316 @item sym
|
|
2317 [@i{string}] if file is a symbolic link, the linked-to name, else @samp{""}
|
|
2318 @end table
|
|
2319
|
|
2320 @noindent
|
|
2321 For example, use
|
|
2322 @example
|
|
2323 (equal 0 size)
|
|
2324 @end example
|
|
2325 to mark all zero length files.
|
|
2326
|
|
2327 To find out all not yet compiled Emacs lisp files in a directory, dired
|
|
2328 all @file{.el} files in the lisp directory using the wildcard
|
|
2329 @samp{*.el}. Then use @kbd{M-(} with
|
|
2330 @example
|
|
2331 (not (file-exists-p (concat name "c")))
|
|
2332 @end example
|
|
2333 to mark all @file{.el} files without a corresponding @file{.elc} file.
|
|
2334
|
|
2335 @item M-M
|
|
2336 @kindex M-M
|
|
2337 @cindex Marker character, how to replace it
|
|
2338 @cindex Replacing one marker character with another
|
|
2339 (@code{dired-do-unmark}) Unmark marked files by replacing the marker
|
|
2340 with another character. The new character defaults to a space,
|
|
2341 effectively unmarking them.
|
|
2342
|
|
2343 @item ,
|
|
2344 @kindex ,
|
|
2345 @cindex RCS controlled files, how to mark them
|
|
2346 @cindex Marking RCS controlled files
|
|
2347 (@code{dired-mark-rcs-files}) Mark all files that are under RCS control.
|
|
2348 With prefix argument, unflag all those files. Mentions RCS files for
|
|
2349 which a working file was not found in this buffer. Type @kbd{W}
|
|
2350 (@code{dired-why}) to see them again.
|
|
2351
|
|
2352 @item C-m C-c
|
|
2353 @kindex C-m C-c
|
|
2354 @cindex Compilation files, how to mark them
|
|
2355 @cindex Marking compilation files
|
|
2356 @cindex List of files, how to mark them
|
|
2357 @cindex Marking a list of files from a buffer
|
|
2358 (@kbd{C-m C-c} is the suggested binding for
|
|
2359 @code{dired-mark-files-compilation-buffer}, it is not bound by default.)
|
|
2360 Mark the files mentioned in the @samp{*compilation*} buffer. With an
|
|
2361 argument, you may specify the other buffer and your own regexp instead of
|
|
2362 @code{compilation-error-regexp}. Use @samp{^.+$} (the default with a
|
|
2363 prefix argument) to match complete lines. In conjunction with narrowing the
|
|
2364 other buffer you can mark an arbitrary list of files, one per line, with
|
|
2365 this command. If your regexp contains a subexpression, i.e.
|
|
2366 @samp{\(@var{...}\)}, that subexpression is taken for the file name,
|
|
2367 else the whole match is used. Thus you can easily strip pre- and
|
|
2368 suffixes from filenames by using @samp{@var{prefix}\(.+\)@var{postfix}}
|
|
2369 as regexp.
|
|
2370
|
|
2371 This is especially useful for a list of files obtained from @kbd{M-x
|
|
2372 grep} or output from a similar shell command.
|
|
2373
|
|
2374 @item C-m C-d
|
|
2375 @kindex C-m C-d
|
|
2376 @cindex Corresponding files, how to mark them
|
|
2377 @cindex List of files, how to mark them
|
|
2378 (@kbd{C-m C-d} is the suggested binding for
|
|
2379 @code{dired-mark-files-from-other-dired-buffer}, it is not bound by default.)
|
|
2380 Mark those files in this Dired buffer that have the same name as the
|
|
2381 marked files in the Dired buffer in the other window.
|
|
2382
|
|
2383 In short, mark the corresponding files from the other Dired buffer.
|
|
2384
|
|
2385 @end table
|
|
2386
|
|
2387 @table @kbd
|
|
2388 @item F
|
|
2389 @kindex F
|
|
2390 @cindex Visiting several files at once
|
|
2391 @cindex Simultaneous visiting of several files
|
|
2392 @findex dired-do-find-file
|
|
2393 (@code{dired-do-find-file}) Visit all marked files at once, and
|
|
2394 display them simultaneously. If you want to keep the dired buffer
|
|
2395 displayed, type @kbd{C-x 2} first. If you want just the marked files
|
|
2396 displayed and nothing else, type @kbd{C-x 1} first.
|
|
2397
|
|
2398 The current window is split across all files. Remaining lines go to the
|
|
2399 last window.
|
|
2400
|
|
2401 The number of files that can be displayed this way is restricted by the
|
|
2402 height of the current window and the variable @code{window-min-height}.
|
|
2403
|
|
2404 @end table
|
|
2405
|
|
2406 @table @code
|
|
2407
|
|
2408 @item dired-mark-extension
|
|
2409 @findex dired-mark-extension
|
|
2410 Mark all files with a certain extension for use in later commands.
|
|
2411 A @samp{.} is not automatically prepended to the string entered.
|
|
2412
|
|
2413 When called from lisp, @var{extension} may also be a list of extensions
|
|
2414 and an optional argument @var{marker-char} specifies the marker used.
|
|
2415
|
|
2416 @item dired-flag-extension
|
|
2417 @findex dired-flag-extension
|
|
2418 Flag all files with a certain extension for deletion.
|
|
2419 A @samp{.} is @emph{not} automatically prepended to the string entered.
|
|
2420
|
|
2421 @item dired-clean-patch
|
|
2422 @findex dired-clean-patch
|
|
2423 Flag dispensable files created by the @samp{patch} program for deletion.
|
|
2424 See variable @code{patch-unclean-extensions}.
|
|
2425
|
|
2426 @item dired-clean-tex
|
|
2427 @findex dired-clean-tex
|
|
2428 Flag dispensable files created by @TeX{}, La@TeX{} and @samp{texinfo}
|
|
2429 for deletion. See variables @code{tex-unclean-extensions},
|
|
2430 @code{texinfo-unclean-extensions}, @code{latex-unclean-extensions} and
|
|
2431 @code{bibtex-unclean-extensions}.
|
|
2432
|
|
2433 @end table
|
|
2434
|
|
2435 Variables used by the above cleanup commands (and in the default value
|
|
2436 for variable @code{dired-omit-extensions}):
|
|
2437
|
|
2438 @table @code
|
|
2439
|
|
2440 @item patch-unclean-extensions
|
|
2441 @vindex patch-unclean-extensions
|
|
2442 Default: @code{'(".rej" ".orig")}
|
|
2443
|
|
2444 List of extensions of dispensable files created by the @samp{patch} program.
|
|
2445
|
|
2446 @item tex-unclean-extensions
|
|
2447 @vindex tex-unclean-extensions
|
|
2448 Default: @code{'(".toc" ".log" ".aux")}
|
|
2449
|
|
2450 List of extensions of dispensable files created by @TeX{}.
|
|
2451
|
|
2452 @item texinfo-unclean-extensions
|
|
2453 @vindex texinfo-unclean-extensions
|
|
2454 Default: @code{'(".cp" ".cps" ".fn" ".fns" ".ky" ".kys" ".pg" ".pgs"
|
|
2455 ".tp" ".tps" ".vr" ".vrs")}
|
|
2456
|
|
2457 List of extensions of dispensable files created by texinfo.
|
|
2458
|
|
2459 @item latex-unclean-extensions
|
|
2460 @vindex latex-unclean-extensions
|
|
2461 Default: @code{'(".idx" ".lof" ".lot" ".glo")}
|
|
2462
|
|
2463 List of extensions of dispensable files created by LaTeX.
|
|
2464
|
|
2465 @item bibtex-unclean-extensions
|
|
2466 @vindex bibtex-unclean-extensions
|
|
2467 Default: @code{'(".blg" ".bbl")}
|
|
2468
|
|
2469 List of extensions of dispensable files created by BibTeX.
|
|
2470
|
|
2471 @end table
|
|
2472
|
|
2473
|
|
2474 @node Virtual Dired, Multiple Dired Directories, Advanced Dired Mark Commands, Tree Dired Extra
|
|
2475 @section Virtual Dired
|
|
2476
|
|
2477 @cindex Virtual Dired
|
|
2478 @cindex Perusing ls listings
|
|
2479 @cindex ls listings, how to peruse them in Dired
|
|
2480 Using @dfn{Virtual Dired} means putting a buffer with Dired-like
|
|
2481 contents in Dired mode. The files described by the buffer contents need
|
|
2482 not actually exist. This is useful if you want to peruse an @samp{ls -lR}
|
|
2483 output file, for example one you got from an FTP server. You can use
|
|
2484 all motion commands usually available in Tree Dired. You can also use
|
|
2485 it to save a Dired buffer in a file and resume it in a later session.
|
|
2486
|
|
2487 @findex dired-virtual
|
|
2488 @kindex g
|
|
2489 @findex dired-virtual-revert
|
|
2490 Type @kbd{M-x dired-virtual} to put the current buffer into virtual
|
|
2491 Dired mode. You will be prompted for the top level directory of this
|
|
2492 buffer, with a default value guessed from the buffer contents. To
|
|
2493 convert the virtual to a real Dired buffer again, type @kbd{g} (which
|
|
2494 calls @code{dired-virtual-revert}) in the virtual Dired buffer and
|
|
2495 answer @samp{y}. You don't have to do this, though: you can relist
|
|
2496 single subdirectories using @kbd{l} (@code{dired-do-redisplay}) on the subdirectory
|
|
2497 headerline, leaving the buffer in virtual Dired mode all the time.
|
|
2498
|
|
2499 @findex dired-virtual-mode
|
|
2500 @vindex auto-mode-alist
|
|
2501 The function @samp{dired-virtual-mode} is specially designed to turn on
|
|
2502 virtual Dired mode from the @code{auto-mode-alist}. To automatically
|
|
2503 edit all @file{*.dired} files in virtual Dired mode, put this into your
|
|
2504 @file{~/.emacs}:
|
|
2505
|
|
2506 @example
|
|
2507 (setq auto-mode-alist (cons '("[^/]\\.dired$" . dired-virtual-mode)
|
|
2508 auto-mode-alist))
|
|
2509 @end example
|
|
2510
|
|
2511 The regexp is a bit more complicated than usual to exclude ".dired"
|
|
2512 local variable files.
|
|
2513
|
|
2514 @node Multiple Dired Directories, Dired Local Variables, Virtual Dired, Tree Dired Extra
|
|
2515 @section Multiple Dired Directories and Non-Dired Commands
|
|
2516
|
|
2517 @cindex Multiple Dired directories
|
|
2518 @cindex Working directory
|
|
2519 An Emacs buffer can have but one working directory, stored in the
|
|
2520 buffer-local variable @code{default-directory}. A Dired buffer may have
|
|
2521 several subdirectories inserted, but still has but one working
|
|
2522 directory: that of the top level Dired directory in that buffer. For
|
|
2523 some commands it is appropriate that they use the current Dired
|
|
2524 directory instead of @code{default-directory}, e.g., @code{find-file} and
|
|
2525 @code{compile}.
|
|
2526
|
|
2527 A general mechanism is provided for special handling of the working
|
|
2528 directory in special major modes:
|
|
2529
|
|
2530 @table @code
|
|
2531 @item default-directory-alist
|
|
2532 @vindex default-directory-alist
|
|
2533 Default: @code{((dired-mode . (dired-current-directory)))}
|
|
2534
|
|
2535 Alist of major modes and their opinion on @code{default-directory}, as a
|
|
2536 lisp expression to evaluate. A resulting value of @code{nil} is ignored
|
|
2537 in favor of @code{default-directory}.
|
|
2538
|
|
2539 @item default-directory
|
|
2540 @findex default-directory
|
|
2541 Function with usage like variable @code{default-directory}, but knows about the
|
|
2542 special cases in variable @code{default-directory-alist}.
|
|
2543 @end table
|
|
2544
|
|
2545 The following dired-x commands take special care about the current
|
|
2546 Dired directory:
|
|
2547
|
|
2548 @table @code
|
|
2549
|
|
2550 @item find-this-file
|
|
2551 @findex find-this-file
|
|
2552 @findex find-file
|
|
2553 @kindex C-x C-f
|
|
2554 Bind this to @kbd{C-x C-f} as a replacement for @code{find-file} that
|
|
2555 will prompt for the filename within the current Dired subdirectory, not
|
|
2556 the top level directory.
|
|
2557
|
|
2558 @item find-this-file-other-window
|
|
2559 @findex find-this-file-other-window
|
|
2560 @findex find-file-other-window
|
|
2561 @kindex C-x 4 C-f
|
|
2562 Bind this to @kbd{C-x 4 C-f} as a replacement for
|
|
2563 @code{find-file-other-window}.
|
|
2564
|
|
2565 @item dired-smart-shell-command
|
|
2566 @findex dired-smart-shell-command
|
|
2567 @findex shell-command
|
|
2568 @kindex M-!
|
|
2569 Like function @code{shell-command}, but in the current Tree Dired directory.
|
|
2570 Bound to @kbd{M-!} in Dired buffers.
|
|
2571
|
|
2572 @item dired-smart-background-shell-command
|
|
2573 @findex dired-smart-background-shell-command
|
|
2574 @findex background
|
|
2575 @kindex M-&
|
|
2576 Like function @code{background}, but in the current Tree Dired directory.
|
|
2577 Bound to @kbd{M-&} in Dired buffers.
|
|
2578
|
|
2579 @item dired-jump-back
|
|
2580 @findex dired-jump-back
|
|
2581 @kindex C-x j
|
|
2582 (Suggested binding @kbd{C-x j}) Jump back to dired: If in a file, dired
|
|
2583 the current directory and move to file's line. If in Dired already, pop
|
|
2584 up a level and goto old directory's line. In case the proper Dired file
|
|
2585 line cannot be found, refresh the Dired buffer and try again.
|
|
2586
|
|
2587 @item dired-jump-back-other-window
|
|
2588 @findex dired-jump-back-other-window
|
|
2589 @kindex C-x 4 j
|
|
2590 (Suggested binding @kbd{C-x 4 j}) Like @code{dired-jump-back}, but to
|
|
2591 other window.
|
|
2592
|
|
2593 @item dired-vm
|
|
2594 @kindex V
|
|
2595 @findex dired-vm
|
|
2596 @vindex vm-folder-directory
|
|
2597 (@kbd{V}) Run VM on this file (assumed to be a UNIX mail folder).
|
|
2598 Further `v' commands from within VM in that folder will default to the
|
|
2599 folder's directory, not the usual @code{vm-folder-directory}.
|
|
2600
|
|
2601 @vindex dired-vm-read-only-folders
|
|
2602 If you give this command a prefix argument, it will visit the folder
|
|
2603 read-only. This only works in VM 5, not VM 4.
|
|
2604
|
|
2605 If the variable @code{dired-vm-read-only-folders} is t, @code{dired-vm}
|
|
2606 will visit all folders read-only. If it is neither @code{nil} nor
|
|
2607 @code{t}, e.g., the symbol @code{'if-file-read-only}, only files not
|
|
2608 writable by you are visited read-only. This is the recommended value if
|
|
2609 you run VM 5.
|
|
2610
|
|
2611 @item dired-rmail
|
|
2612 @findex dired-rmail
|
|
2613 Run Rmail on this file (assumed to be mail folder in Rmail/BABYL format).
|
|
2614
|
|
2615 @end table
|
|
2616
|
|
2617 @c subsection Narrow and Widen in a Dired Buffer
|
|
2618
|
|
2619 @node Dired Local Variables, Making Relative Symbolic Links in Dired, Multiple Dired Directories, Tree Dired Extra
|
|
2620 @section Local Variables for Dired Directories
|
|
2621
|
|
2622 @cindex Local Variables for Dired Directories
|
|
2623 @vindex dired-local-variables-file
|
|
2624 When Dired visits a directory, it looks for a file whose name is the
|
|
2625 value of variable @code{dired-local-variables-file} (default:
|
|
2626 @file{.dired}). If such a file is found, Dired will temporarily insert
|
|
2627 it into the Dired buffer and run @code{hack-local-variables}.
|
|
2628 @xref{File Variables,Local Variables in Files,Local Variables in
|
|
2629 Files,emacs,The GNU Emacs Manual}. You can set
|
|
2630 @code{dired-local-variables-file} to @code{nil} to suppress this.
|
|
2631
|
|
2632 For example, put
|
|
2633
|
|
2634 @example
|
|
2635 Local Variables:
|
|
2636 dired-actual-switches: "-lat"
|
|
2637 dired-sort-mode: " by date"
|
|
2638 End:
|
|
2639 @end example
|
|
2640
|
|
2641 into a @file{.dired} file of a directory to sort by date only in that
|
|
2642 directory. Note that since @code{dired-hack-local-variables} is run
|
|
2643 inside @code{dired-mode-hook} the modeline has already been set, so you
|
|
2644 have to update that for yourself by setting @code{dired-sort-mode} in
|
|
2645 addition to changing the switches.
|
|
2646
|
|
2647 @node Making Relative Symbolic Links in Dired, Letting Dired Guess What Shell Command to Apply, Dired Local Variables, Tree Dired Extra
|
|
2648 @section Making Relative Symbolic Links in Dired
|
|
2649
|
|
2650 In GNU Emacs version 18, the built-in function @code{make-symbolic-link}
|
|
2651 always calls @code{expand-file-name} on its arguments, so relative
|
|
2652 symlinks (e.g. @samp{foo -> ../bar/foo}) are impossible to create.
|
|
2653
|
|
2654 Dired Extra uses @code{call-process} and @samp{ln -s} for a workaround.
|
|
2655
|
|
2656 @table @code
|
|
2657
|
|
2658 @item dired-make-symbolic-link
|
|
2659 @findex dired-make-symbolic-link
|
|
2660 Arguments @var{name1} @var{name2} and optional
|
|
2661 @var{ok-if-already-exists}. Create file @var{name2}, a symbolic link
|
|
2662 pointing to @var{name1} (which may be any string whatsoever and is
|
|
2663 passed untouched to @samp{ln -s}). @var{ok-if-already-exists} means that
|
|
2664 @var{name2} will be overwritten if it already exists. If it is an
|
|
2665 integer, user will be asked about this. On error, signals a file-error.
|
|
2666
|
|
2667 @item dired-make-relative-symlink
|
|
2668 @findex dired-make-relative-symlink
|
|
2669 Three arguments: @var{file1} @var{file2} and optional
|
|
2670 @var{ok-if-already-exists}. Make a symbolic link @var{file2} (pointing
|
|
2671 to @var{file1}). The link is relative (if possible), for example
|
|
2672
|
|
2673 @example
|
|
2674 (dired-make-relative-symlink "/vol/tex/bin/foo"
|
|
2675 "/vol/local/bin/foo")
|
|
2676 @end example
|
|
2677
|
|
2678 @noindent
|
|
2679 results in a link
|
|
2680
|
|
2681 @example
|
|
2682 /vol/local/bin/foo -> ../../tex/bin/foo
|
|
2683 @end example
|
|
2684
|
|
2685 @item dired-do-relsymlink
|
|
2686 @findex dired-do-relsymlink
|
|
2687 (binding @kbd{S}) Symbolically link all marked (or next @var{N}) files
|
|
2688 into a directory, or make a symbolic link to the current file. This
|
|
2689 creates relative symbolic links like
|
|
2690
|
|
2691 @example
|
|
2692 foo -> ../bar/foo
|
|
2693 @end example
|
|
2694
|
|
2695 @noindent
|
|
2696 not absolute ones like
|
|
2697 @example
|
|
2698 foo -> /ugly/path/that/may/change/any/day/bar/foo
|
|
2699 @end example
|
|
2700
|
|
2701 @item dired-do-relsymlink-regexp
|
|
2702 @findex dired-do-relsymlink-regexp
|
|
2703 (@kbd{%S}) Symbolically link all marked files containing @var{regexp} to
|
|
2704 @var{newname}, using relative (not absolute) names. See functions
|
|
2705 @code{dired-rename-regexp} and @code{dired-do-relsymlink} for more info.
|
|
2706
|
|
2707 @end table
|
|
2708
|
|
2709 @node Letting Dired Guess What Shell Command to Apply, dired-trns.el, Making Relative Symbolic Links in Dired, Tree Dired Extra
|
|
2710 @section Letting Dired Guess What Shell Command to Apply
|
|
2711
|
|
2712 Based upon the name of a filename, Dired tries to guess what shell
|
|
2713 command you might want to apply to it. For example, if you have point
|
|
2714 on a file named @file{foo.tar} and you press @kbd{!}, Dired will guess
|
|
2715 you want to @samp{tar xvf} it and suggest that as the default shell
|
|
2716 command.
|
|
2717
|
|
2718 If you are using the @file{gmhist} package (@xref{Dired Minibuffer
|
|
2719 History}), the default will be mentioned in brackets and you can type
|
|
2720 @kbd{M-p} to get the default into the minibuffer so that you can edit
|
|
2721 it, e.g., changing @samp{tar xvf} to @samp{tar tvf}. If there are
|
|
2722 several commands for a given file, e.g., @samp{xtex} and @samp{dvips}
|
|
2723 for a @file{.dvi} file, you can type @kbd{M-p} several times to see each
|
|
2724 of the matching commands.
|
|
2725
|
|
2726 Dired only tries to guess a command for a single file, never for a list
|
|
2727 of marked files.
|
|
2728
|
|
2729 @table @code
|
|
2730
|
|
2731 @item dired-auto-shell-command-alist-default
|
|
2732 @vindex dired-auto-shell-command-alist-default
|
|
2733
|
|
2734 Predefined rules for shell commands. Set this to nil to turn guessing off.
|
|
2735 The elements of @code{dired-auto-shell-command-alist} (defined by the
|
|
2736 user) will override these rules.@refill
|
|
2737
|
|
2738 @item dired-auto-shell-command-alist
|
|
2739 @vindex dired-auto-shell-command-alist
|
|
2740
|
|
2741 If non-nil, an alist of file regexps and their suggested commands
|
|
2742 overriding the predefined rules in
|
|
2743 @code{dired-auto-shell-command-alist-default}.@refill
|
|
2744
|
|
2745 Each element of the alist looks like
|
|
2746
|
|
2747 @example
|
|
2748 (@var{regexp} @var{command}@dots{})
|
|
2749 @end example
|
|
2750
|
|
2751 where each @var{command} can either be a string or a lisp expression
|
|
2752 that evaluates to a string. If several @var{COMMAND}s are given, all
|
|
2753 will temporarily be pushed on the history.
|
|
2754
|
|
2755 These rules take precedence over the predefined rules in the variable
|
|
2756 @code{dired-auto-shell-command-alist-default} (to which they are
|
|
2757 prepended when @file{dired-x} is loaded).
|
|
2758
|
|
2759 You can set this variable in your @file{~/.emacs}. For example,
|
|
2760 to add rules for @samp{.foo} and @samp{.bar} file extensions, write
|
|
2761
|
|
2762 @example
|
|
2763 (setq dired-auto-shell-command-alist
|
|
2764 (list
|
|
2765 (list "\\.foo$" "@var{foo-command}");; fixed rule
|
|
2766 ;; possibly more rules...
|
|
2767 (list "\\.bar$";; rule with condition test
|
|
2768 '(if @var{condition}
|
|
2769 "@var{bar-command-1}"
|
|
2770 "@var{bar-command-2}"))))
|
|
2771 @end example
|
|
2772
|
|
2773 @noindent
|
|
2774 This will override any predefined rules for the same extensions.
|
|
2775
|
|
2776 @item dired-guess-have-gnutar
|
|
2777 @vindex dired-guess-have-gnutar
|
|
2778
|
|
2779 Default: @code{nil}
|
|
2780
|
|
2781 If non-nil, name of the GNU tar executable (e.g., @samp{"tar"} or
|
|
2782 @samp{"gnutar"}). GNU tar's @samp{z} switch is used for compressed tar
|
|
2783 files. If you don't have GNU tar, set this to nil: a pipe using
|
|
2784 @samp{zcat} is then used.
|
|
2785
|
|
2786 @end table
|
|
2787
|
|
2788 @node dired-trns.el, dired-cd.el, Letting Dired Guess What Shell Command to Apply, Tree Dired Extra
|
|
2789 @section Filename Transformers for Dired Shell Commands
|
|
2790
|
|
2791 @cindex Transformer
|
|
2792 @cindex Basename of a file, how to use in Dired shell commands
|
|
2793 @cindex Extension of a file, how to use in Dired shell commands
|
|
2794 File name @dfn{transformers} are functions that take a filename (a string)
|
|
2795 as an argument and transform it into some other string (e.g., a filename
|
|
2796 without an extension). This package makes transformers available in
|
|
2797 Dired shell commands.
|
|
2798
|
|
2799 For example, running the Dired shell command (type @kbd{!} or @kbd{M-x}
|
|
2800 @code{dired-do-shell-command})@refill
|
|
2801
|
|
2802 @example
|
|
2803 echo * [b] [db]
|
|
2804 @end example
|
|
2805
|
|
2806 would list the full name, the basename, and the absolute basename of
|
|
2807 each marked file.
|
|
2808
|
|
2809 Each transformer is associated with a dispatch character. The associations
|
|
2810 are stored in a keymap for fast and easy lookup. The dispatch character
|
|
2811 is used to activate the associated transformer function at a particular
|
|
2812 position in a shell command issued in Dired. The dispatch character
|
|
2813 must be enclosed in brackets to distinguish it from normal letters.
|
|
2814
|
|
2815 To take advantage of this package, simply load it after loading Dired,
|
|
2816 e.g., in your @code{dired-load-hook}. You can then use transformers like
|
|
2817 "[b]" for the basename in your Dired shell commands (see below).
|
|
2818
|
|
2819 You can define your own transformers using the macro @code{dired-trans-define}.
|
|
2820
|
|
2821 @table @code
|
|
2822
|
|
2823 @item dired-trans-define
|
|
2824 @findex dired-trans-define
|
|
2825 Macro that assigns the transformer function @code{(lambda (file)
|
|
2826 @var{body})} to @var{char} (a character or string). @var{body} must
|
|
2827 return a string: the transformed file.
|
|
2828 @end table
|
|
2829
|
|
2830 Several transformers are predefined:
|
|
2831
|
|
2832 @table @samp
|
|
2833
|
|
2834 @item *
|
|
2835 returns the unmodified filename (equivalent to @samp{[dbe]}).
|
|
2836
|
|
2837 @item n
|
|
2838 returns the Name component of a filename without directory information
|
|
2839
|
|
2840 @item d
|
|
2841 returns the Directory component of a filename
|
|
2842
|
|
2843 @item b
|
|
2844 returns the Basename of a filename, i.e., the name of the file without
|
|
2845 directory and extension (see variable @code{dired-trans-re-ext})
|
|
2846 A basename with directory component can be obtained by @samp{[db]}.
|
|
2847
|
|
2848 @item e
|
|
2849 returns the Extension of a filename (i.e., whatever
|
|
2850 @code{dired-trans-re-ext} splits off)
|
|
2851
|
|
2852 @item v
|
|
2853 returns a file without directory and without @file{,v} suffixes if any.
|
|
2854
|
|
2855 @item z
|
|
2856 returns a file without directory and without @file{.Z} suffixes if any.
|
|
2857
|
|
2858 @end table
|
|
2859
|
|
2860 @noindent
|
|
2861 The following variables can be used to customize @file{dired-trns.el}:
|
|
2862
|
|
2863 @table @code
|
|
2864
|
|
2865 @item dired-trans-re-ext
|
|
2866 @vindex dired-trans-re-ext
|
|
2867 Default: @code{"\\.[^.]*\\(\\.Z\\)?$"}
|
|
2868
|
|
2869 The part of a filename matching this regexp will be viewed as extension.
|
|
2870
|
|
2871 @item dired-trans-starters
|
|
2872 @vindex dired-trans-starters
|
|
2873 Default: @code{"[#[]"}
|
|
2874
|
|
2875 User definable set of characters to be used to indicate the start of a
|
|
2876 transformer sequence.
|
|
2877
|
|
2878 @item dired-trans-enders
|
|
2879 @vindex dired-trans-enders
|
|
2880 Default: @code{"[]# ]"}
|
|
2881
|
|
2882 User definable set of characters to be used to indicate the end of a
|
|
2883 transformer sequence.
|
|
2884
|
|
2885 @end table
|
|
2886
|
|
2887 @node dired-cd.el, dired-nstd.el, dired-trns.el, Tree Dired Extra
|
|
2888 @section Changing the Working Directory for Dired Shell Commands
|
|
2889
|
|
2890 The package @file{dired-cd.el} permits the working directory of the
|
|
2891 Dired shell commands @kbd{!} (@code{dired-do-shell-command}) and @kbd{&}
|
|
2892 (@code{dired-do-background-shell-command}) to be the files' subdirectory
|
|
2893 under certain circumstances. Loading this extension does not change the
|
|
2894 behavior of Dired until the variables @code{dired-cd-same-subdir} and/or
|
|
2895 @code{dired-cd-on-each} are non-nil.
|
|
2896
|
|
2897 @vindex dired-cd-same-subdir
|
|
2898 If @code{dired-cd-same-subdir} is non-nil and if all the selected files
|
|
2899 (marked, non-zero numeric argument, etc.) are in the same subdirectory,
|
|
2900 then @code{dired-do-shell-command} and
|
|
2901 @code{dired-do-background-shell-command} cause the shell to perform a
|
|
2902 @samp{cd} into that directory before the commands are executed. Also,
|
|
2903 the selected filenames are provided to the command without any directory
|
|
2904 components.
|
|
2905
|
|
2906 @vindex dired-cd-on-each
|
|
2907 If @code{dired-cd-on-each} is non-nil and if the @samp{on-each} option
|
|
2908 is specified (numeric argument of zero), then @kbd{!}
|
|
2909 (@code{dired-do-shell-command}) and @kbd{&}
|
|
2910 (@code{dired-mark-background-shell-command}) use a subshell to perform a
|
|
2911 @samp{cd} into the subdirectory of each file before the commands on that
|
|
2912 file are executed. Also, each filename is provided to the command
|
|
2913 without any directory components. Note that this behavior occurs
|
|
2914 regardless of whether the files are all in the same directory or not.
|
|
2915
|
|
2916 After the above @samp{cd} wrapping has occured, the existing
|
|
2917 @code{dired-shell-stuff-it} is used to do the actual file-name quoting
|
|
2918 and substitution into the command. Thus, custom versions of this
|
|
2919 procedure should work, e.g., the @samp{dired-trans} package will transform
|
|
2920 commands correctly. However, since filenames lack any directory
|
|
2921 components, features that use the directory components will fail, e.g.
|
|
2922 the @samp{[d]} transform specifier will be empty.
|
|
2923
|
|
2924 To use this package, load it in your @code{dired-load-hook}. Do
|
|
2925
|
|
2926 @example
|
|
2927 (setq dired-cd-same-subdir t)
|
|
2928 @end example
|
|
2929
|
|
2930 @noindent
|
|
2931 and perhaps
|
|
2932
|
|
2933 @example
|
|
2934 (setq dired-cd-on-each t)
|
|
2935 @end example
|
|
2936
|
|
2937 @noindent
|
|
2938 in your @file{~/.emacs}. By default, @code{dired-cd} doesn't change the
|
|
2939 behavior of Dired when it is loaded.
|
|
2940
|
|
2941 @vindex dired-cd-same-subdir
|
|
2942 If @code{dired-cd-same-subdir} is non-nil, then the shell commands
|
|
2943 @samp{cd} to the appropriate directory if all the selected files are in
|
|
2944 that directory; however, on-each behavior (with zero prefix argument) is
|
|
2945 not changed.
|
|
2946
|
|
2947 @vindex dired-cd-on-each
|
|
2948 If @code{dired-cd-on-each} is non-nil, then each instance of the command
|
|
2949 for an on-each shell command runs in the file's directory regardless of
|
|
2950 whether the files are all in the same directory.
|
|
2951
|
|
2952 @node dired-nstd.el, find-dired.el, dired-cd.el, Tree Dired Extra
|
|
2953 @section Nested Dired format
|
|
2954
|
|
2955 [NO DOCUMENTATION YET]
|
|
2956
|
|
2957 This is still buggy, @xref{Dired Known Problems}.
|
|
2958
|
|
2959 @node find-dired.el, , dired-nstd.el, Tree Dired Extra
|
|
2960 @section Feeding Find Output to Dired
|
|
2961
|
|
2962 @cindex Find and Dired
|
|
2963 The @code{find-dired} command runs the @samp{find} command in a buffer
|
|
2964 and starts Dired on the inserted file lines, even while @samp{find} is
|
|
2965 still running. For example, with @samp{-type d} as argument, you will
|
|
2966 get a Dired buffer that contains all subdirectories of a given
|
|
2967 directory, but none of the other files.
|
|
2968
|
|
2969 Note that @samp{find} just gives you file lines, not inserted
|
|
2970 subdirectories with associated headerlines as repeated use of the
|
|
2971 @kbd{i} (@code{dired-maybe-insert-subdir}) command would. Also, the
|
|
2972 names contain slashes if they are in a subdirectory, which never occurs
|
|
2973 in a normal Dired buffer. Dired understands these names anyway and you
|
|
2974 can for example type @kbd{f} on such lines as usual. However, while
|
|
2975 @samp{find} is still running you shouldn't type @kbd{i} to insert
|
|
2976 subdirectories, since new @samp{find} output is always appended at the
|
|
2977 end. Use @kbd{f} or @kbd{o} instead to dired the specific subdirectory
|
|
2978 in a new Dired buffer. After @samp{find} has finished (as indicated by
|
|
2979 a message and the modeline) all Dired commands work as usual.
|
|
2980
|
|
2981 @table @code
|
|
2982
|
|
2983 @item find-dired
|
|
2984 @findex find-dired
|
|
2985 Run @samp{find} on a directory @var{dir}, with find arguments
|
|
2986 @var{args}, and go into dired-mode on a buffer of the output. The
|
|
2987 command run (after changing into @var{dir}) is
|
|
2988 @example
|
|
2989 find . \( @var{args} \) -ls
|
|
2990 @end example
|
|
2991
|
|
2992 @item find-name-dired
|
|
2993 @findex find-name-dired
|
|
2994 Search @var{dir} recursively for files matching the globbing pattern
|
|
2995 @var{pattern}, and run Dired on those files. @var{pattern} is a shell
|
|
2996 wildcard (not an Emacs regexp) and need not be quoted. The command
|
|
2997 run (after changing into @var{dir}) is
|
|
2998 @example
|
|
2999 find . -name '@var{pattern}' -ls
|
|
3000 @end example
|
|
3001
|
|
3002 @item find-grep-dired
|
|
3003 @findex find-grep-dired
|
|
3004 Find files in directory @var{dir} containing a regexp @var{arg} and
|
|
3005 start Dired on output. The command run (after changing into @var{dir})
|
|
3006 is
|
|
3007 @example
|
|
3008 find . -exec grep -s @var{arg} @{@} \; -ls
|
|
3009 @end example
|
|
3010 @end table
|
|
3011
|
|
3012 @node Dired Internals, Dired Known Problems, Tree Dired Extra, Top
|
|
3013 @appendix Dired Internals
|
|
3014
|
|
3015 This is a short introduction about how Dired's Tree and Mark features
|
|
3016 work. You are encouraged to read the code (@file{dired.el}) for more
|
|
3017 information.
|
|
3018
|
|
3019 @menu
|
|
3020 * Tree Dired Internals::
|
|
3021 * Dired Mark Internals::
|
|
3022 @end menu
|
|
3023
|
|
3024 @node Tree Dired Internals, Dired Mark Internals, Dired Internals, Dired Internals
|
|
3025 @section Tree Dired Internals
|
|
3026
|
|
3027 @cindex Internals of Tree Dired
|
|
3028 @cindex Tree Dired Internals
|
|
3029 @vindex dired-subdir-alist
|
|
3030 @vindex default-directory
|
|
3031 In Tree Dired, instead of just one directory, all or part of the
|
|
3032 directory @emph{tree} starting at the top level directory (the working
|
|
3033 directory or @code{default-directory} of the buffer) may be in a
|
|
3034 Dired buffer. Each file line belongs to exactly one of those
|
|
3035 subdirectories. After the @code{ls} program has inserted its output,
|
|
3036 Dired parses the buffer once to find out where the subdirectory
|
|
3037 boundaries are and saves them in the variable @code{dired-subdir-alist}.
|
|
3038 The beginning of the headerline inserted by @code{ls} serves as boundary
|
|
3039 between subdirectories.
|
|
3040
|
|
3041 @kindex i
|
|
3042 @findex dired-maybe-insert-subdir
|
|
3043 Subsequent @kbd{i} (@code{dired-maybe-insert-subdir}) commands update this
|
|
3044 alist and insert the appropriate headerline. Each retrieval of the
|
|
3045 filename on the current line first extracts the basename (assuming a
|
|
3046 more or less standard @code{ls} output format), and then function
|
|
3047 @code{dired-current-directory} looks up the current Dired directory in
|
|
3048 @code{dired-subdir-alist}. The lookup is keyed on buffer position, as
|
|
3049 each buffer position is between exactly two subdirectory boundaries. (The end
|
|
3050 of the buffer serves as an implicit subdirectory boundary.)
|
|
3051
|
|
3052 @table @code
|
|
3053
|
|
3054 @item dired-subdir-alist
|
|
3055 @vindex dired-subdir-alist
|
|
3056 Association list of subdirectories and their buffer positions:
|
|
3057
|
|
3058 @example
|
|
3059 ((@var{lastdir} . @var{lastmarker}) @dots{} (@var{default-directory} . @var{firstmarker})).
|
|
3060 @end example
|
|
3061
|
|
3062 The markers point right before the beginning of the line, so that they
|
|
3063 separate subdirectories adjacent in the buffer. The directories must be
|
|
3064 in the form returned by @code{file-name-as-directory}.
|
|
3065
|
|
3066 @item dired-subdir-regexp
|
|
3067 @vindex dired-subdir-regexp
|
|
3068 Value: "^. \\([^ \n\r]+\\)\\(:\\)[\n\r]"
|
|
3069
|
|
3070 Regexp matching a maybe hidden subdirectory line in @samp{ls -lR}
|
|
3071 output. Subexpression 1 is subdirectory proper, no trailing colon. The
|
|
3072 match starts at the beginning of the line and ends after the end of the
|
|
3073 line (@samp{\n} or @samp{\r}). Subexpression 2 must end right before
|
|
3074 the @samp{\n} or @code{\r}. This is so that Dired can easily check
|
|
3075 whether a subdirectory is hidden or not: hidden lines end with @samp{\r}
|
|
3076 (@kbd{C-m}) instead of a newline.
|
|
3077
|
|
3078 This regexp used to be @code{"^. \\(/[^\n\r]*\\)\\(:\\)[\n\r]"},
|
|
3079 allowing spaces, but disallowing relative filenames (which occur when
|
|
3080 browsing ls -lR listing in virtual Dired mode, so I changed it).
|
|
3081
|
|
3082 Note that @code{"^. \\([^\n\r]+\\)\\(:\\)[\n\r]"} (desirable since it
|
|
3083 allows both spaces and relative names) will not always work: if you have
|
|
3084 a file that ends in a colon, its whole line (including permission bits,
|
|
3085 date etc.) would be mistaken for a subdirectory headerline when parsing
|
|
3086 @samp{ls -lR} output.
|
|
3087
|
|
3088 @code{dired-subdir-regexp} is only relevant for parsing @samp{ls -lR}
|
|
3089 output. If Dired inserts subdirectories itself (using
|
|
3090 @code{dired-insert-subdir}), they will always be absolute and there is
|
|
3091 no restriction on the format of filenames, e.g., they can contain
|
|
3092 spaces.
|
|
3093
|
|
3094 @end table
|
|
3095
|
|
3096 @node Dired Mark Internals, , Tree Dired Internals, Dired Internals
|
|
3097 @section Dired Mark Internals
|
|
3098
|
|
3099 This is a short overview about how marking files and retrieving marked
|
|
3100 files in Dired works.
|
|
3101
|
|
3102 @cindex Internal of Dired file marking
|
|
3103 @cindex Dired file marking internals
|
|
3104 @cindex File marking internals in Dired
|
|
3105 @cindex Marking files in Dired, internals of
|
|
3106 @code{ls} output is indented two spaces two make room for an optional
|
|
3107 marker character in front of each file line. Marking simply replaces the
|
|
3108 first space with the marker character, usually @code{*} or, for
|
|
3109 deletions, @code{D}. Indenting just by one would leave the markers
|
|
3110 adjacent to the permission bits.
|
|
3111
|
|
3112 @table @code
|
|
3113
|
|
3114 @item dired-mark-if
|
|
3115 @findex dired-mark-if
|
|
3116 The macro @code{dired-mark-if} is used internally to mark files matching
|
|
3117 certain criteria. It takes two arguments, the @var{predicate}, a lisp
|
|
3118 expression evaluating non-nil on file lines to be marked, and @var{msg},
|
|
3119 a message to be displayed while scanning the buffer. @var{msg} may be
|
|
3120 nil to suppress the message.
|
|
3121
|
|
3122 @findex dired-mark-map
|
|
3123 @item dired-mark-map
|
|
3124 To operate on the marked files, all internal Dired functions ultimately
|
|
3125 call the macro @code{dired-mark-map}. It takes two arguments,
|
|
3126 @var{body} and @var{arg}, plus an optional argument @var{show-progress}:
|
|
3127
|
|
3128 Perform @var{body} with point somewhere on each marked line (inside a
|
|
3129 @code{save-excursion}) and return a list of @var{body}'s results. If no
|
|
3130 marked file could be found, execute @var{body} on the current line.
|
|
3131
|
|
3132 If @var{arg} is an integer, use the next @var{arg} (or previous
|
|
3133 -@var{arg}, if @var{arg}<0) files instead of the marked files. In that
|
|
3134 case point is dragged along. This is so that commands on the next ARG
|
|
3135 (instead of the marked) files can be chained easily. Note that for
|
|
3136 positive ARG point is left on the first file not operated upon, for
|
|
3137 negative on the last file operated upon
|
|
3138
|
|
3139 If @var{arg} is otherwise non-nil, use current file instead.
|
|
3140
|
|
3141 If optional third argument @var{show-progress} evaluates to non-nil, we
|
|
3142 redisplay the Dired buffer after each file is processed. No guarantee
|
|
3143 is made about the position on the marked line. @var{body} must ensure
|
|
3144 this itself if it depends on this. Search starts at the beginning of
|
|
3145 the buffer, thus the @code{car} of the list corresponds to the line nearest to
|
|
3146 the buffer's bottom. This is also true for (positive and negative)
|
|
3147 integer values of @var{arg}. The @var{body} should not be too long as
|
|
3148 it is expanded four times.@refill
|
|
3149
|
|
3150 @c This warning should no longer apply. sk 6-Sep-1991 16:28
|
|
3151 @c Warning: @var{body} must not add new lines before point - this may cause
|
|
3152 @c an endless loop.
|
|
3153
|
|
3154 @end table
|
|
3155
|
|
3156 @noindent
|
|
3157 A common case is to retrieve the names of all marked files:
|
|
3158
|
|
3159 @table @code
|
|
3160
|
|
3161 @findex dired-mark-get-files
|
|
3162 @item dired-mark-get-files
|
|
3163 Return the marked files as list of strings. The list is in the same
|
|
3164 order as the buffer, that is, the car is the first marked file. Values
|
|
3165 returned are normally absolute pathnames. Optional argument @var{localp}
|
|
3166 equal to @code{no-dir} means return the filename proper only, with no
|
|
3167 directory information; any other non-nil value means make them relative
|
|
3168 to default-directory. Optional second argument @var{arg} forces use of
|
|
3169 other files. If @var{arg} is an integer, use the next @var{arg} files.
|
|
3170 If @var{arg} is otherwise non-nil, use the current file.
|
|
3171
|
|
3172 @end table
|
|
3173
|
|
3174 @node Dired Known Problems, Dired Variable Index, Dired Internals, Top
|
|
3175 @appendix Known Problems with Dired
|
|
3176
|
|
3177 There are some problems with Dired that are either not Dired's fault,
|
|
3178 hard to fix or not worth fixing.
|
|
3179
|
|
3180 @itemize @bullet
|
|
3181
|
|
3182 @item
|
|
3183 Renaming directories usually works fine (all affected Dired and file
|
|
3184 buffers are updated), but moving a directory between different
|
|
3185 filesystems (those on different hard disks or different partitions) does
|
|
3186 not work: it creates a plain target file containing the contents of the
|
|
3187 original directory (inodes and filenames) or fails completely.
|
|
3188
|
|
3189 Unfortunately Emacs' builtin function @code{rename-file} does not give
|
|
3190 you a clear error message like @samp{cross-device link attempted}, but
|
|
3191 rather a spurious @code{(file-error "Removing old name" "not owner")},
|
|
3192 at least in Emacs 18.55.
|
|
3193
|
|
3194 On some systems renaming a directory always fails (even within
|
|
3195 the same filesystem) with the spurious @samp{not owner} error.
|
|
3196 @c This was reported for HP-UX.
|
|
3197 @c
|
|
3198 @c On one system (IBM Rs6000 running AIX 3.1.3) date lossage was reported,
|
|
3199 @c but this was not reproducible.
|
|
3200
|
|
3201 @item
|
|
3202 If @file{foo} is a symlink to a non-existing file, @code{(file-exists-p
|
|
3203 "foo")} returns nil. Thus, Dired will overwite such (strange) kinds of
|
|
3204 symlinks without noticing.
|
|
3205
|
|
3206 Dired could test both @code{file-symlink-p} and @code{file-exists-p},
|
|
3207 but this would slow down all file operations to catch a very rare case.
|
|
3208
|
|
3209 @item
|
|
3210 Copying a directory does not work - it results in a zero-length
|
|
3211 target file.
|
|
3212
|
|
3213 This comes from Emacs' @code{copy-file} function, not from Dired.
|
|
3214
|
|
3215 If you really want to copy a directory (recursively), use `!' and
|
|
3216 your favorite shell command to do it (e.g. cp -R or cp -r).
|
|
3217
|
|
3218 @item
|
|
3219 Initial spaces in a filename are not recognized. If I could be sure
|
|
3220 that all @samp{ls} programs insert exactly one space between the time and
|
|
3221 the filename, I could easily fix this. But @samp{ls} programs tend to vary
|
|
3222 in their amount of white space, and even with one @samp{ls} program there
|
|
3223 is a difference between year and clocktime formats
|
|
3224 @example
|
|
3225 drwxr-xr-x 2 ab027 thp 512 Aug 13 1990 thp/
|
|
3226 drwxr-xr-x 4 ab027 thp 512 Feb 3 21:59 ./
|
|
3227 @end example
|
|
3228 If your @samp{ls} supports the @samp{-b} switch and quotes spaces with
|
|
3229 that switch, simply add @samp{b} to your @code{dired-listing-switches}.
|
|
3230 @xref{Listing Files in Dired}.
|
|
3231
|
|
3232 Spaces anywhere but at the beginning do work.
|
|
3233
|
|
3234 @item
|
|
3235 In general, only commands that may have targets outside of the
|
|
3236 current directory tree update other buffers (copy, move and link
|
|
3237 commands).
|
|
3238
|
|
3239 Especially, deletions, (un)compress, chmod/chgrp/chown update only
|
|
3240 the current buffer.
|
|
3241
|
|
3242 @item
|
|
3243 Some compress programs make output even if all goes well. Dired
|
|
3244 takes output as a sign of trouble and assumes that the subprocess
|
|
3245 failed.
|
|
3246
|
|
3247 Redefine function @code{dired-check-process-checker} suitably to
|
|
3248 look closer at the generated output. In Emacs 19, the exit status
|
|
3249 of compress will be checked.
|
|
3250
|
|
3251 @item
|
|
3252 Aliases like @samp{rm -i} for @samp{rm} or @samp{ls -F} for @samp{ls}
|
|
3253 can cause problems in Dired's (and Emacs') shell command. (Aliases for
|
|
3254 @samp{ls} only matter if you dired wildcards, because only then the shell is
|
|
3255 used to run @samp{ls}.) Csh expands aliases only for interactive shells, which
|
|
3256 is probably what you want. In Bash, you can achieve this by testing
|
|
3257 @code{PS1} in your @file{~/.bashrc}:
|
|
3258 @example
|
|
3259 # `.bashrc' file
|
|
3260 # this test fails when invoked by rsh
|
|
3261 if [ "$@{PS1-no@}" != "no" ] # is this an interactive shell?
|
|
3262 then
|
|
3263 . ~/.bash_alias # if so, source aliases
|
|
3264 fi
|
|
3265 @end example
|
|
3266
|
|
3267 @item
|
|
3268 Directory names starting with @file{-} (a minus) may lose when they are
|
|
3269 to be created or removed. If you care about this, and your rmdir
|
|
3270 and mkdir understand about @file{--} meaning end of options, change
|
|
3271 @file{emacs-19.el} accordingly.
|
|
3272
|
|
3273 In Emacs 19 the @code{make-directory} and @code{remove-directory}
|
|
3274 operations will be builtin, not implemented with @samp{rmdir} and
|
|
3275 @samp{mkdir} subprocesses.
|
|
3276
|
|
3277 @item
|
|
3278 @file{dired-nstd.el}: This is still buggy. For example, after you've
|
|
3279 compressed the last file it may not correctly return that file's
|
|
3280 absolute pathname (@code{dired-current-directory} erronously returns nil
|
|
3281 because of markers collapsed during redisplay), ultimately leading to
|
|
3282 lisp errors.
|
|
3283
|
|
3284 @c Not longer a problem as of dired-version 5.242, sk 28-Jan-1992 11:17.
|
|
3285 @c @item
|
|
3286 @c Symbolic links to directories are sometimes strange. On System V
|
|
3287 @c derived systems (e.g., DG/UX, AIX/370), after
|
|
3288 @c @example
|
|
3289 @c mkdir dir; ln -s dir link
|
|
3290 @c @end example
|
|
3291 @c both @file{link} and @file{link/} are considered symbolic links by the
|
|
3292 @c @samp{stat(2)} system call, while on BSD derived systems (e.g., Sun OS,
|
|
3293 @c Mach, HP/UX, Ultrix) @file{link/} is considered a directory. In
|
|
3294 @c general, the BSD behaviour is preferable, at least for Dired. On the
|
|
3295 @c other systems it is cumbersome to get Dired to dereference those links.
|
|
3296
|
|
3297 @item
|
|
3298 The regexp-using @kbd{%}-commands get into an endless loop if you
|
|
3299 specify a regular expression that matches the empty string.
|
|
3300
|
|
3301 @item
|
|
3302 Function @code{find-alternate-file} in Emacs 18.57 has a bug that causes
|
|
3303 @kbd{C-x C-v RET} (which usually re-visits the current buffer) to fail
|
|
3304 on Dired buffers. This is fixed in the version in @file{emacs-19.el},
|
|
3305 automatically loaded by Dired.
|
|
3306
|
|
3307 @item
|
|
3308 It is not possible to resort the Dired buffer without reverting it. That
|
|
3309 would be hard to implement (and slow to run) given that ls date format
|
|
3310 would have to be parsed for @samp{ls -t} sorting order.
|
|
3311
|
|
3312 @end itemize
|
|
3313
|
|
3314 @node Dired Variable Index, Dired Function Index, Dired Known Problems, Top
|
|
3315 @unnumbered Dired Variable Index
|
|
3316 @printindex vr
|
|
3317
|
|
3318 @node Dired Function Index, Dired Key Index, Dired Variable Index, Top
|
|
3319 @unnumbered Dired Function Index
|
|
3320 @printindex fn
|
|
3321
|
|
3322 @node Dired Key Index, Dired Concept Index, Dired Function Index, Top
|
|
3323 @unnumbered Dired Key Index
|
|
3324 @printindex ky
|
|
3325
|
|
3326 @node Dired Concept Index, , Dired Key Index, Top
|
|
3327 @unnumbered Dired Concept Index
|
|
3328 @printindex cp
|
|
3329
|
|
3330 @c @summarycontents
|
|
3331 @contents
|
|
3332
|
|
3333 @bye
|
|
3334
|