*** empty log message ***
[bpt/emacs.git] / man / dired-x.texi
CommitLineData
6bf7aab6
DL
1\input texinfo @comment -*-texinfo-*-
2
3@c dired-x.texi --- Sebastian Kremer's Extra DIRED hacked up for GNU Emacs19
4@c
5@c Author: Sebastian Kremer <sk@thp.uni-koeln.de>
6@c Lawrence R. Dodd <dodd@roebling.poly.edu>
7@c Maintainer: Lawrence R. Dodd <dodd@roebling.poly.edu>
8@c Version: 2.52
9@c Date: 1994/08/09 16:51:31
10@c Keywords: dired extensions
11@c dired-x.el REVISION NUMBER: 2
12
13@c State: Released
14@c Ident: dired-x.texi,v 2.52 1994/08/09 16:51:31 dodd Released
15
16@comment %**start of header (This is for running Texinfo on a region.)
17@c FOR GNU EMACS USE ../info/dired-x BELOW
18@setfilename ../info/dired-x
19@c dired-x.el REVISION NUMBER
20@settitle Dired Extra Version 2 User's Manual
21
22@dircategory Editors
23@direntry
24* Dired-X: (dired-x). Dired Extra Features.
25@end direntry
26
27@iftex
28@finalout
29@end iftex
30@c @setchapternewpage odd % For book style double sided manual.
31@comment %**end of header (This is for running Texinfo on a region.)
32@c @smallbook
33@tex
34\overfullrule=0pt
35%\global\baselineskip 30pt % For printing in double spaces
36@end tex
37
38@ifinfo
39@node Copyright, Top, (dir), (dir)
40@comment node-name, next, previous, up
41This documents the ``extra'' features for Dired Mode for GNU Emacs 19 found in
42the file @file{dired-x.el}.
43
44Copyright @copyright{} 1993, 1994 Free Software Foundation, Inc.
45
46Permission is granted to make and distribute verbatim copies of this
47manual provided the copyright notice and this permission notice are
48preserved on all copies.
49
50Permission is granted to copy and distribute modified versions of
51this manual under the conditions for verbatim copying, provided that
52the entire resulting derived work is distributed under the terms of
53a permission notice identical to this one.
54
55Permission is granted to copy and distribute translations of this
56manual into another language, under the above conditions for
57modified versions, except that this permission notice may be stated
58in a translation approved by the Free Software Foundation.
59
60The file used to create this is called @file{dired-x.texi}, but the
61original work that was altered to make that file was called
62@file{dired.texi} written by Sebastian Kremer.
63
64@ignore
65Permission is granted to process this file through TeX and print the
66results, provided the printed document carries copying permission
67notice identical to this one except for the removal of this paragraph
68(this paragraph not being relevant to the printed manual).
69
70@end ignore
71@end ifinfo
72
73@c
74@titlepage
75@sp 6
76@c dired-x.el REVISION NUMBER
77@center @titlefont{Dired Extra Version 2}
78@sp 2
79@center @titlefont{For The GNU Emacs 19}
80@sp 1
81@center @titlefont{Directory Editor}
82@sp 4
83@center Manual Revision: 2.52
84@center 1994/08/09 16:51:31
85@sp 5
86@center Lawrence R@. Dodd
87@center @t{dodd@@roebling.poly.edu}
88@sp 5
89@center (Based on @file{dired.texi} by Sebastian Kremer <sk@@thp.uni-koeln.de>)
90@page
91@vskip 0pt plus 1filll
92Copyright @copyright{} 1993, 1994 Free Software Foundation
93
94Permission is granted to make and distribute verbatim copies of
95this manual provided the copyright notice and this permission notice
96are preserved on all copies.
97
98Permission is granted to copy and distribute modified versions of
99this manual under the conditions for verbatim copying, provided that
100the entire resulting derived work is distributed under the terms of
101a permission notice identical to this one.
102
103Permission is granted to copy and distribute translations of this
104manual into another language, under the above conditions for
105modified versions, except that this permission notice may be stated
106in a translation approved by the Free Software Foundation.
107
108The file used to create this is called @file{dired-x.texi}, but the
109original work that was altered to make that file was called
110@file{dired.texi} written by Sebastian Kremer.
111
112@end titlepage
113
114@page
115
116@ifinfo
117
118@node Top, Introduction, Copyright, (dir)
119@comment node-name, next, previous, up
120
121@noindent
122This documents the ``extra'' features for Dired Mode for GNU Emacs 19 that are
123provided by the file @file{dired-x.el}.
124
125@itemize @bullet
126
127@item
128Based on @file{dired.texi} by Sebastian Kremer <sk@@thp.uni-koeln.de>
129
130@c dired-x.el REVISION NUMBER
131@item
132For @file{dired-x.el} revision 2
133
134@item
135Revision of this manual: 2.52 (1994/08/09 16:51:31)
136
137@item
138Bugs to Lawrence R. Dodd <dodd@@roebling.poly.edu>. @emph{Please} type
139@kbd{M-x dired-x-submit-report} to submit a bug report (@xref{Bugs}).
140
141@item
142You can obtain a copy of this package via anonymous ftp in
143@t{/roebling.poly.edu:/pub/packages/dired-x.tar.gz}
144
145@end itemize
146
147@menu
148* Introduction::
149* Installation::
150* Omitting Files in Dired::
151* Local Variables::
152* Shell Command Guessing::
153* Virtual Dired::
154* Advanced Mark Commands::
155* Multiple Dired Directories::
156* Find File At Point::
157* Miscellaneous Commands::
158* Bugs::
159
160* Concept Index::
161* Command Index::
162* Key Index::
163* Variable Index::
164
165@end menu
166
167@end ifinfo
168
169@node Introduction, Features, Top, Top
170@comment node-name, next, previous, up
171@chapter Introduction
172
173This documents the @emph{extra} features for Dired Mode for GNU Emacs 19. It
174is derived from version 1.191 of Sebastian Kremer's @file{dired-x.el} and is
175GNU Emacs v19 compatible.
176
177In adopting this @file{dired-x.el} to GNU Emacs v19 some material that has
178been incorporated into @file{dired.el} and @file{dired-aux.el} of the GNU Emacs
17919 distribution has been removed and some material was modified for agreement
180with the functions in @file{dired.el} and @file{dired-aux.el}. For example,
181the code using @code{gmhist} history functions was replaced with code using
182the mini-buffer history now built into GNU Emacs 19. Finally, a few other
183features have been added and a few more functions have been bound to keys.
184
185Please note that @file{dired-x.el} and this texinfo file @file{dired-x.texi}
186are bundled with GNU Emacs versions 19.23 and later.
187
188@ifinfo
189@menu
190* Features::
191* Technical Details::
192@end menu
193@end ifinfo
194
195@node Features, Technical Details, Introduction, Introduction
196@comment node-name, next, previous, up
197@section Features
198@cindex Features
199
200Some features provided by Dired Extra
201
202@enumerate
203@item
204Omitting of uninteresting files from dired listing.
205@itemize @bullet
206@xref{Omitting Files in Dired}
207@end itemize
208@item
209Local variables for dired directories.
210@itemize @bullet
211@xref{Local Variables}
212@end itemize
213@item
214Guessing shell commands in dired buffers.
215@itemize @bullet
216@xref{Shell Command Guessing}
217@end itemize
218@item
219Running dired command in non-dired buffers.
220@itemize @bullet
221@xref{Virtual Dired}
222@end itemize
223@item
224Finding a file mentioned in a buffer
225@itemize @bullet
226@xref{Find File At Point}
227@end itemize
228@item
229Commands using file marking.
230@itemize @bullet
231@xref{Advanced Mark Commands}
232@end itemize
233@end enumerate
234
235@noindent
236@file{dired-x.el} binds some functions to keys in Dired Mode (@xref{Key
237Index}) and also binds @kbd{C-x C-j} and @kbd{C-x 4 C-j} @emph{globally} to
238@code{dired-jump} (@xref{Miscellaneous Commands}). It may also bind @kbd{C-x
239C-f} and @kbd{C-x 4 C-f} to @code{dired-x-find-file} and
240@code{dired-x-find-file-other-window}, respectively (@xref{Find File At
241Point}).
242
243@node Technical Details, Installation, Features, Introduction
244@comment node-name, next, previous, up
245@section Technical Details
246@cindex Redefined functions
247@cindex @file{dired-aux.el}
248
249When loaded this code @emph{redefines} the following functions of GNU Emacs
250from @file{dired.el}
251
252@itemize @bullet
253@item
254@code{dired-clean-up-after-deletion}
255@item
256@code{dired-find-buffer-nocreate}
257@item
258@code{dired-initial-position}
259@item
260@code{dired-up-directory}
261@end itemize
262
263@noindent
264and the following functions from @file{dired-aux.el}
265
266@itemize @bullet
267@item
268@code{dired-add-entry}
269@item
270@code{dired-read-shell-command}
271@end itemize
272
273One drawback is that @file{dired-x.el} will load @file{dired-aux.el} as soon
274as dired is loaded. Thus, the advantage of separating out non-essential dired
275stuff into @file{dired-aux.el} and only loading when necessary will be lost
276when @file{dired-x.el} is used.
277
278@node Installation, Optional Installation Dired Jump, Technical Details, Top
279@comment node-name, next, previous, up
280@chapter Installation
281
282@noindent
283This manual describes the dired features provided by the file
284@file{dired-x.el}. To take advantage of these features, you must load the
285file and (optionally) set some variables.
286
287@noindent
288In your @file{.emacs} file in your home directory, or in the system-wide
289initialization file @file{default.el} in the @file{site-lisp} directory, put
290
291@example
292(add-hook 'dired-load-hook
293 (function (lambda ()
294 (load "dired-x")
295 ;; Set dired-x global variables here. For example:
296 ;; (setq dired-guess-shell-gnutar "gtar")
297 ;; (setq dired-x-hands-off-my-keys nil)
298 )))
299(add-hook 'dired-mode-hook
300 (function (lambda ()
301 ;; Set dired-x buffer-local variables here. For example:
302 ;; (setq dired-omit-files-p t)
303 )))
304@end example
305
306@noindent
307This will load @file{dired-x.el} when dired is first invoked (for example,
308when you first do @kbd{C-x d}).
309
310@ifinfo
311@menu
312* Optional Installation Dired Jump::
313* Optional Installation File At Point::
314* Special Notes::
315@end menu
316@end ifinfo
317
318@node Optional Installation Dired Jump, Optional Installation File At Point, Installation, Installation
319@comment node-name, next, previous, up
320@section Optional Installation Dired Jump
321
322@cindex Autoloading @code{dired-jump} and @code{dired-jump-other-window}
323
324In order to have @code{dired-jump} and @code{dired-jump-other-window}
325(@xref{Miscellaneous Commands}) work @emph{before} @code{dired} and
326@code{dired-x} have been properly loaded the user should set-up an autoload
327for these functions. In your @file{.emacs} file put
328
329@example
330;;; Autoload `dired-jump' and `dired-jump-other-window'.
331;;; We autoload from FILE dired.el. This will then load dired-x.el
332;;; and hence define `dired-jump' and `dired-jump-other-window'.
333(define-key global-map "\C-x\C-j" 'dired-jump)
334(define-key global-map "\C-x4\C-j" 'dired-jump-other-window)
335
336(autoload (quote dired-jump) "dired" "\
337Jump to dired buffer corresponding to current buffer.
338If in a file, dired the current directory and move to file's line.
339If in dired already, pop up a level and goto old directory's line.
340In case the proper dired file line cannot be found, refresh the dired
341buffer and try again." t nil)
342
343(autoload (quote dired-jump-other-window) "dired" "\
344Like \\[dired-jump] (dired-jump) but in other window." t nil)
345@end example
346
347Note that in recent releases of GNU Emacs 19 (i.e., 19.25 or later) the file
348@file{../lisp/loaddefs.el} of the Emacs distribution already contains the
349proper auto-loading for @code{dired-jump} so you need only put
350
351@example
352(define-key global-map "\C-x\C-j" 'dired-jump)
353@end example
354
355@noindent in your @file{.emacs} file in order to have @kbd{C-x C-j} work
356before @code{dired} is loaded.
357
358@node Optional Installation File At Point, Special Notes, Optional Installation Dired Jump, Installation
359@comment node-name, next, previous, up
360@section Optional Installation File At Point
361
362@cindex Binding @code{dired-x-find-file}
363If you choose to have @file{dired-x.el} bind @code{dired-x-find-file} over
364@code{find-file} (@xref{Find File At Point}), then you will need to set
365@code{dired-x-hands-off-my-keys} and make a call to the function
366@code{dired-x-bind-find-file} in the @code{dired-load-hook}:
367
368@example
369(add-hook 'dired-load-hook
370 (function (lambda ()
371 (load "dired-x")
372 ;; Bind dired-x-find-file.
373 (setq dired-x-hands-off-my-keys nil)
374 ;; Make sure our binding preference is invoked.
375 (dired-x-bind-find-file)
376 )))
377@end example
378
379Alternatively, you can set the variable @emph{before} @file{dired-x.el} is
380loaded
381
382@example
383(add-hook 'dired-load-hook
384 (function (lambda ()
385 ;; Bind dired-x-find-file.
386 (setq dired-x-hands-off-my-keys nil)
387 (load "dired-x")
388 )))
389@end example
390
391@node Special Notes, Omitting Files in Dired, Optional Installation File At Point, Installation
392@comment node-name, next, previous, up
393@section Special Notes
394
395If @file{dired-x.el} was @emph{not} bundled with the version of GNU Emacs
396installed at your site (i.e., not in the default @file{../lisp} directory)
397then you must put the file @file{dired-x.el} in a directory known to GNU
398Emacs. Examine the variable @code{load-path} for a list of these directories.
399If you wish to add a new directory on this list of directories use something
400like this in your @file{.emacs} file
401
402@example
403;;; LOAD PATH
404(setq load-path (append
405 load-path ; default at top
406 (list
407 "/the/directory/where/you/put/dired-x")))
408@end example
409
410@noindent If you wish to put the new directory at the head of the list (where
411it will be found first) then you should use instead
412
413@example
414;;; LOAD PATH
415(setq load-path (append
416 (list
417 "/the/directory/where/you/put/dired-x")
418 load-path)) ; default at bottom
419@end example
420
421You must also byte compile the file (for example, hitting @kbd{B} in
422@code{dired-mode}). When byte-compiling @file{dired-x.el} you may get
423messages about functions @code{vm-visit-folder}, @code{Man-notify-when-ready},
424and @code{reporter-submit-bug-report} not being defined. These are warnings
425and should be ignored.
426
427@noindent CAUTION: If you are using a version of GNU Emacs earlier than 19.20
428than you may have to edit @file{dired.el}. The copy of @file{dired.el} in GNU
429Emacs versions earlier than 19.20 incorrectly had the call to @code{run-hooks}
430@emph{before} the call to @code{provide}. In such a case, it is possible that
431byte-compiling and/or loading dired can cause an infinite loop. To prevent
432this, make sure the line of code
433
434@example
435 (run-hooks 'dired-load-hook)
436@end example
437
438@noindent is the @emph{last} executable line in the file @file{dired.el}.
439That is, make sure it comes @emph{after} the line
440
441@example
442 (provide 'dired)
443@end example
444
445@node Omitting Files in Dired, Omitting Variables, Special Notes, Top
446@comment node-name, next, previous, up
447@chapter Omitting Files in Dired
448
449@cindex Omitting Files in Dired
450@dfn{Omitting} a file means removing it from the directory listing. Omitting
451is useful for keeping Dired buffers free of ``uninteresting'' files (for
452instance, auto-save, auxiliary, backup, and revision control files) so that
453the user can concentrate on the interesting files. Like hidden files, omitted
454files are never seen by Dired. Omitting differs from hiding in several
455respects:
456
457@itemize @bullet
458
459@item
460Omitting works on individual files, not on directories; an entire directory
461cannot be omitted (though each of its files could be).
462
463@item
464Omitting is wholesale; if omitting is turned on for a dired buffer, then all
465uninteresting files listed in that buffer are omitted. The user does not omit
466(or unomit) files one at a time.
467
468@item
469Omitting can be automatic; uninteresting file lines in the buffer can be
470removed before the user ever sees them.
471
472@item
473Marked files are never omitted.
474@end itemize
475
476@table @kbd
477@item M-o
478@kindex M-o
479@findex dired-omit-toggle
480(@code{dired-omit-toggle}) Toggle between displaying and omitting
481``uninteresting'' files. With a prefix argument, don't toggle and just mark
482the files, but don't actually omit them.
483@end table
484
485@noindent
486In order to make Dired Omit work you first need to load @file{dired-x.el}
487inside @code{dired-load-hook} (@xref{Installation}) and then set
488@code{dired-omit-files-p} in some way (@xref{Omitting Variables}).
489
490@ifinfo
491@menu
492* Omitting Variables::
493* Omitting Examples::
494* Omitting Technical::
495@end menu
496@end ifinfo
497
498@node Omitting Variables, Omitting Examples, Omitting Files in Dired, Omitting Files in Dired
499@comment node-name, next, previous, up
500
501@section Omitting Variables
502
503The following variables can be used to customize omitting.
504
505@table @code
506
507@vindex dired-omit-files-p
508@item dired-omit-files-p
509
510Default: @code{nil}
511
512@cindex How to make omitting the default in Dired
513If non-@code{nil}, ``uninteresting'' files are not listed. Uninteresting
514files are those whose filenames match regexp @code{dired-omit-files}, plus
515those ending with extensions in @code{dired-omit-extensions}. @kbd{M-o}
516(@code{dired-omit-toggle}) toggles its value, which is buffer-local. Put
517
518@example
519(setq dired-omit-files-p t)
520@end example
521
522inside your @code{dired-mode-hook} to have omitting initially turned on in
523@emph{every} Dired buffer (@xref{Installation}). You can then use @kbd{M-o} to
524unomit in that buffer.
525
526To enable omitting automatically only in certain directories one can use Dired
527Local Variables and put
528
529@example
530Local Variables:
531dired-omit-files-p: t
532End:
533@end example
534
535@noindent
536into a file @file{.dired} (the default value of
537@code{dired-local-variables-file}) in that directory (@xref{Local Variables}).
538
539@table @code
540@findex dired-omit-here-always
541@item dired-omit-here-always
542
543This is an interactive function that creates a local variables file exactly
544like the example above (if it does not already exist) in the file
545@code{dired-local-variables-file} in the current directory and then refreshes
546the directory listing (@xref{Local Variables}).
547@end table
548
549@vindex dired-omit-files
550@item dired-omit-files
551
552Default: @code{"^#\\|\\.$"}
553
554Filenames matching this buffer-local regexp will not be displayed.
555This only has effect when @code{dired-omit-files-p} is t.
556
557The default value omits the special directories @file{.} and @file{..} and
558autosave files (plus other files ending in ``.'') (@xref{Omitting Examples}).
559
560@vindex dired-omit-extensions
561@item dired-omit-extensions
562
563Default: The elements of @code{completion-ignored-extensions} (as defined in
564the file @file{loaddefs.el} of the GNU Emacs distribution),
565@code{dired-latex-unclean-extensions}, @code{dired-bibtex-unclean-extensions}
566and @code{dired-texinfo-unclean-extensions}.
567
568If non-@code{nil}, a list of extensions (strings) to omit from Dired listings.
569Its format is the same as that of @code{completion-ignored-extensions}.
570
571@vindex dired-omit-localp
572@item dired-omit-localp
573
574Default: @code{'no-dir}
575
576The @var{localp} argument @code{dired-omit-expunge} passes to
577@code{dired-get-filename}. If it is @code{'no-dir}, omitting is much faster,
578but you can only match against the non-directory part of the filename. Set it
579to @code{nil} if you need to match the whole pathname or @code{t} to match the
580pathname relative to the buffer's top-level directory.
581
582@item dired-omit-marker-char
583@vindex dired-omit-marker-char
584@cindex Omitting additional files
585Default: @kbd{C-o}
586
587Temporary marker used by by Dired to implement omitting. Should never be used
588as marker by the user or other packages. There is one exception to this rule:
589by doing
590
591@example
592(setq dired-mark-keys "\C-o")
593;; i.e., the value of dired-omit-marker-char
594;; (which is not defined yet)
595@end example
596
597anywhere in your @file{~/.emacs}, you will bind the @kbd{C-o} key to insert a
598@kbd{C-o} marker, thus causing these files to be omitted in addition to the
599usually omitted files. Unfortunately the files you omitted manually this way
600will show up again after reverting the buffer, unlike the others.
601
602@end table
603
604@node Omitting Examples, Omitting Technical, Omitting Variables, Omitting Files in Dired
605@comment node-name, next, previous, up
606@section Examples of Omitting Various File Types
607
608@itemize @bullet
609
610@item
611@cindex RCS files, how to omit them in Dired
612@cindex Omitting RCS files in Dired
613If you wish to avoid seeing RCS files and the RCS directory, then put
614
615@example
616(setq dired-omit-files
617 (concat dired-omit-files "\\|^RCS$\\|,v$"))
618@end example
619@noindent
620in the @code{dired-load-hook} (@xref{Installation}). This assumes
621@code{dired-omit-localp} has its default value of @code{'no-dir} to make the
622@code{^}-anchored matches work. As a slower alternative, with
623@code{dired-omit-localp} set to @code{nil}, you can use @code{/} instead of
624@code{^} in the regexp.
625
626@item
627@cindex Tib files, how to omit them in Dired
628@cindex Omitting tib files in Dired
629If you use tib, the bibliography program for use with @TeX{} and La@TeX{}, you
630might want to omit the @file{INDEX} and the @file{-t.tex} files, then put
631
632@example
633(setq dired-omit-files
634 (concat dired-omit-files "\\|^INDEX$\\|-t\\.tex$"))
635@end example
636
637@noindent
638in the @code{dired-load-hook} (@xref{Installation}).
639
640@item
641@cindex Dot files, how to omit them in Dired
642@cindex Omitting dot files in Dired
643If you do not wish to see @samp{dot} files (files starting with a @samp{.}),
644then put
645
646@example
647(setq dired-omit-files
648 (concat dired-omit-files "\\|^\\..+$"))
649@end example
650
651@noindent
652in the @code{dired-load-hook} (@xref{Installation}).
653
654@end itemize
655
656@node Omitting Technical, Local Variables, Omitting Examples, Omitting Files in Dired
657@comment node-name, next, previous, up
658@section Some Technical Details of Omitting
659
660Loading @file{dired-x.el} will install Dired Omit by putting
661@code{dired-omit-expunge} on your @code{dired-after-readin-hook}, and will
662call @code{dired-extra-startup}, which in turn calls @code{dired-omit-startup}
663in your @code{dired-mode-hook}.
664
665@node Local Variables, Shell Command Guessing, Omitting Technical, Top
666@comment node-name, next, previous, up
667@chapter Local Variables for Dired Directories
668
669@cindex Local Variables for Dired Directories
670@vindex dired-local-variables-file
671@vindex dired-enable-local-variables
672@noindent
673When Dired visits a directory, it looks for a file whose name is the value of
674variable @code{dired-local-variables-file} (default: @file{.dired}). If such
675a file is found, Dired will temporarily insert it into the Dired buffer and
676run @code{hack-local-variables}.
677
678@noindent
679For example, if the user puts
680
681@example
682Local Variables:
683dired-actual-switches: "-lat"
684dired-omit-files-p: t
685End:
686@end example
687
688@noindent
689into a file called @file{.dired} in a directory then when that directory is
690viewed it will be
691
692@enumerate
693@item
694sorted by date
695@item
696omitted automatically
697@end enumerate
698
699@noindent
700You can set @code{dired-local-variables-file} to @code{nil} to suppress this.
701The value of @code{dired-enable-local-variables} controls if and how these
702local variables are read. This variable exists so that if may override the
703default value of @code{enable-local-variables}.
704
705@noindent
706Please see the GNU Emacs Manual to learn more about local variables.
707@xref{File Variables,Local Variables in Files,Local Variables in
708Files,emacs,The GNU Emacs Manual}.
709
710@noindent
711The following variables affect Dired Local Variables
712
713@table @code
714@vindex dired-local-variables-file
715@item dired-local-variables-file
716Default: @code{".dired"}
717
718If non-@code{nil}, filename for local variables for Dired. If Dired finds a
719file with that name in the current directory, it will temporarily insert it
720into the dired buffer and run `hack-local-variables'.
721
722@vindex dired-enable-local-variables
723@item dired-enable-local-variables
724Default: @code{t}
725
726Controls use of local-variables lists in dired. The value can be @code{t},
727@code{nil}, or something else. A value of @code{t} means local-variables
728lists are obeyed in the @code{dired-local-variables-file}; @code{nil} means
729they are ignored; anything else means query. This variable temporarily
730overrides the value of @code{enable-local-variables} when the Dired Local
731Variables are hacked.
732@end table
733
734@node Shell Command Guessing, Virtual Dired, Local Variables, Top
735@comment node-name, next, previous, up
736@chapter Shell Command Guessing
737@cindex Guessing shell commands for files.
738
739Based upon the name of a filename, Dired tries to guess what shell
740command you might want to apply to it. For example, if you have point
741on a file named @file{foo.tar} and you press @kbd{!}, Dired will guess
742you want to @samp{tar xvf} it and suggest that as the default shell
743command.
744
745The default will be mentioned in brackets and you can type @kbd{M-p} to get
746the default into the minibuffer so that you can edit it, e.g., changing
747@samp{tar xvf} to @samp{tar tvf}. If there are several commands for a given
748file, e.g., @samp{xtex} and @samp{dvips} for a @file{.dvi} file, you can type
749@kbd{M-p} several times to see each of the matching commands.
750
751Dired only tries to guess a command for a single file, never for a list
752of marked files.
753
754@table @code
755@item dired-guess-shell-alist-default
756@vindex dired-guess-shell-alist-default
757Predefined rules for shell commands. Set this to @code{nil} to turn guessing off.
758The elements of @code{dired-guess-shell-alist-user} (defined by the
759user) will override these rules.@refill
760
761@item dired-guess-shell-alist-user
762@vindex dired-guess-shell-alist-user
763If non-@code{nil}, a user-defined alist of file regexps and their suggested
764commands. These rules take precedence over the predefined rules in the
765variable @code{dired-guess-shell-alist-default} (to which they are prepended)
766when @code{dired-do-shell-command} is run).
767@refill
768
769Each element of the alist looks like
770
771@example
772(@var{regexp} @var{command}@dots{})
773@end example
774
775where each @var{command} can either be a string or a lisp expression
776that evaluates to a string. If several @var{COMMAND}s are given, all
777will temporarily be pushed on the history.
778
779You can set this variable in your @file{~/.emacs}. For example,
780to add rules for @samp{.foo} and @samp{.bar} file extensions, write
781
782@example
783(setq dired-guess-shell-alist-user
784 (list
785 (list "\\.foo$" "@var{foo-command}");; fixed rule
786 ;; possibly more rules...
787 (list "\\.bar$";; rule with condition test
788 '(if @var{condition}
789 "@var{bar-command-1}"
790 "@var{bar-command-2}"))))
791@end example
792
793@noindent
794This will override any predefined rules for the same extensions.
795
796@item dired-guess-shell-gnutar
797@vindex dired-guess-shell-gnutar
798@cindex Passing GNU tar its `z' switch.
799Default: @code{nil}
800
801If non-@code{nil}, name of the GNU tar executable (e.g., @samp{"tar"} or
802@samp{"gnutar"}). GNU tar's @samp{z} switch is used for compressed tar files.
803If you don't have GNU tar, set this to @code{nil}: a pipe using @samp{zcat} is
804then used.
805
806@item dired-guess-shell-gzip-quiet
807@vindex dired-guess-shell-gzip-quiet
808@cindex GNU zip.
809Default: @code{t}
810
811A non-@code{nil} value means that @code{-q} is passed to gzip overriding a
812verbose GNU zip's @samp{GZIP} environment variable.
813
814@item dired-guess-shell-znew-switches nil
815@vindex dired-guess-shell-znew-switches nil
816@cindex GNU zip.
817Default: @code{nil}
818
819A string of switches passed to GNU zip's @file{znew}. An example is
820@samp{"-K"} which will make @file{znew} keep a .Z file when it is smaller than
821the .gz file.
822
823@item dired-shell-command-history nil
824@vindex dired-shell-command-history nil
825
826History list for commands that read dired-shell commands.
827@end table
828
829@node Virtual Dired, Advanced Mark Commands, Shell Command Guessing, Top
830@comment node-name, next, previous, up
831@chapter Virtual Dired
832
833@cindex Virtual Dired
834@cindex Perusing ls listings
835@cindex ls listings, how to peruse them in Dired
836Using @dfn{Virtual Dired} means putting a buffer with Dired-like
837contents in Dired mode. The files described by the buffer contents need
838not actually exist. This is useful if you want to peruse an @samp{ls -lR}
839output file, for example one you got from an FTP server. You can use
840all motion commands usually available in Dired. You can also use
841it to save a Dired buffer in a file and resume it in a later session.
842
843@findex dired-virtual
844@kindex g
845@findex dired-virtual-revert
846Type @kbd{M-x dired-virtual} to put the current buffer into virtual
847Dired mode. You will be prompted for the top level directory of this
848buffer, with a default value guessed from the buffer contents. To
849convert the virtual to a real Dired buffer again, type @kbd{g} (which
850calls @code{dired-virtual-revert}) in the virtual Dired buffer and
851answer @samp{y}. You don't have to do this, though: you can relist
852single subdirectories using @kbd{l} (@code{dired-do-redisplay}) on the subdirectory
853headerline, leaving the buffer in virtual Dired mode all the time.
854
855@findex dired-virtual-mode
856@vindex auto-mode-alist
857The function @samp{dired-virtual-mode} is specially designed to turn on
858virtual Dired mode from the @code{auto-mode-alist}. To edit all
859@file{*.dired} files automatically in virtual Dired mode, put this into your
860@file{~/.emacs}:
861
862@example
863(setq auto-mode-alist (cons '("[^/]\\.dired$" . dired-virtual-mode)
864 auto-mode-alist))
865@end example
866
867The regexp is a bit more complicated than usual to exclude ".dired"
868local variable files.
869
870@node Advanced Mark Commands, Advanced Cleaning Functions, Virtual Dired, Top
871@comment node-name, next, previous, up
872@chapter Advanced Mark Commands
873
874@table @kbd
875@item F
876@kindex F
877@cindex Visiting several files at once
878@cindex Simultaneous visiting of several files
879@findex dired-do-find-marked-files
880(@code{dired-do-find-marked-files}) Find all marked files at once displaying
881simultaneously. If optional NOSELECT is non-@code{nil} then just find the
882files but do not select. If you want to keep the dired buffer displayed, type
883@kbd{C-x 2} first. If you want just the marked files displayed and nothing
884else, type @kbd{C-x 1} first.
885
886The current window is split across all files marked, as evenly as possible.
887Remaining lines go to the bottom-most window. The number of files that can be
888displayed this way is restricted by the height of the current window and the
889variable @code{window-min-height}.
890@end table
891
892@table @code
893@item dired-mark-extension
894@findex dired-mark-extension
895Mark all files with a certain extension for use in later commands. A @samp{.}
896is not automatically prepended to the string entered.
897
898When called from lisp, @var{extension} may also be a list of extensions
899and an optional argument @var{marker-char} specifies the marker used.
900
901@item dired-flag-extension
902@findex dired-flag-extension
903Flag all files with a certain extension for deletion. A @samp{.} is
904@emph{not} automatically prepended to the string entered.
905@end table
906
907@ifinfo
908@menu
909* Advanced Cleaning Functions::
910* Advanced Cleaning Variables::
911* Special Marking Function::
912@end menu
913@end ifinfo
914
915@node Advanced Cleaning Functions, Advanced Cleaning Variables, Advanced Mark Commands, Advanced Mark Commands
916@comment node-name, next, previous, up
917
918@section Advanced Cleaning Functions
919
920@table @code
921@item dired-clean-patch
922@findex dired-clean-patch
923Flag dispensable files created by the @samp{patch} program for deletion. See
924variable @code{dired-patch-unclean-extensions}.
925
926@item dired-clean-tex
927@findex dired-clean-tex
928Flag dispensable files created by @TeX{}, La@TeX{}, and @samp{texinfo} for
929deletion. See the following variables (@xref{Advanced Cleaning Variables})
930
931@itemize @bullet
932@item
933@code{dired-tex-unclean-extensions}
934@item
935@code{dired-texinfo-unclean-extensions}
936@item
937@code{dired-latex-unclean-extensions}
938@item
939@code{dired-bibtex-unclean-extensions}
940@end itemize
941
942@item dired-very-clean-tex
943@findex dired-very-clean-tex
944Flag dispensable files created by @TeX{}, La@TeX{}, @samp{texinfo}, and ".dvi"
945files for deletion.
946@end table
947
948@node Advanced Cleaning Variables, Special Marking Function, Advanced Cleaning Functions, Advanced Mark Commands
949@comment node-name, next, previous, up
950
951@section Advanced Cleaning Variables
952
953@noindent Variables used by the above cleaning commands (and in the default value for
954variable @code{dired-omit-extensions}, @xref{Omitting Variables})
955
956@table @code
957@item dired-patch-unclean-extensions
958@vindex dired-patch-unclean-extensions
959Default: @code{'(".rej" ".orig")}
960
961List of extensions of dispensable files created by the @samp{patch} program.
962
963@item dired-tex-unclean-extensions
964@vindex dired-tex-unclean-extensions
965Default: @code{'(".toc" ".log" ".aux")}
966
967List of extensions of dispensable files created by @TeX{}.
968
969@item dired-texinfo-unclean-extensions
970@vindex dired-texinfo-unclean-extensions
971Default: @code{'(".cp" ".cps" ".fn" ".fns" ".ky" ".kys"}
972@code{".pg" ".pgs" ".tp" ".tps" ".vr" ".vrs")}
973
974List of extensions of dispensable files created by @samp{texinfo}.
975
976@item dired-latex-unclean-extensions
977@vindex dired-latex-unclean-extensions
978Default: @code{'(".idx" ".lof" ".lot" ".glo")}
979
980List of extensions of dispensable files created by La@TeX{}.
981
982@item dired-bibtex-unclean-extensions
983@vindex dired-bibtex-unclean-extensions
984Default: @code{'(".blg" ".bbl")}
985
986List of extensions of dispensable files created by Bib@TeX{}.
987@end table
988
989@node Special Marking Function, Multiple Dired Directories, Advanced Cleaning Variables, Advanced Mark Commands
990@comment node-name, next, previous, up
991
992@section Special Marking Function
993
994@table @kbd
995@item M-(
996@kindex M-(
997@findex dired-mark-sexp
998@cindex Lisp expression, marking files with in Dired
999@cindex Mark file by lisp expression
1000(@code{dired-mark-sexp}) Mark files for which @var{predicate} returns
1001non-@code{nil}. With a prefix argument, unflag those files instead.
1002
1003The @var{predicate} is a lisp expression that can refer to the following
1004symbols:
1005@table @code
1006@item inode
1007[@i{integer}] the inode of the file (only for @samp{ls -i} output)
1008@item s
1009[@i{integer}] the size of the file for @samp{ls -s} output (usually in blocks or,
1010with @samp{-k}, in KBytes)
1011@item mode
1012[@i{string}] file permission bits, e.g., @samp{"-rw-r--r--"}
1013@item nlink
1014[@i{integer}] number of links to file
1015@item uid
1016[@i{string}] owner
1017@item gid
1018[@i{string}] group (If the gid is not displayed by @samp{ls}, this
1019will still be set (to the same as uid))
1020@item size
1021[@i{integer}] file size in bytes
1022@item time
1023[@i{string}] the time that @samp{ls} displays, e.g., @samp{"Feb 12 14:17"}
1024@item name
1025[@i{string}] the name of the file
1026@item sym
1027[@i{string}] if file is a symbolic link, the linked-to name, else @samp{""}
1028@end table
1029
1030@noindent
1031For example, use
1032@example
1033(equal 0 size)
1034@end example
1035to mark all zero length files.
1036
1037To find out all not yet compiled Emacs lisp files in a directory, dired
1038all @file{.el} files in the lisp directory using the wildcard
1039@samp{*.el}. Then use @kbd{M-(} with
1040@example
1041(not (file-exists-p (concat name "c")))
1042@end example
1043to mark all @file{.el} files without a corresponding @file{.elc} file.
1044
1045@end table
1046
1047@node Multiple Dired Directories, Find File At Point, Special Marking Function, Top
1048@comment node-name, next, previous, up
1049@chapter Multiple Dired Directories and Non-Dired Commands
1050
1051@cindex Multiple Dired directories
1052@cindex Working directory
1053An Emacs buffer can have but one working directory, stored in the
1054buffer-local variable @code{default-directory}. A Dired buffer may have
1055several subdirectories inserted, but still has but one working
1056directory: that of the top level Dired directory in that buffer. For
1057some commands it is appropriate that they use the current Dired
1058directory instead of @code{default-directory}, e.g., @code{find-file} and
1059@code{compile}.
1060
1061A general mechanism is provided for special handling of the working
1062directory in special major modes:
1063
1064@table @code
1065@item default-directory-alist
1066@vindex default-directory-alist
1067Default: @code{((dired-mode . (dired-current-directory)))}
1068
1069Alist of major modes and their opinion on @code{default-directory}, as a
1070lisp expression to evaluate. A resulting value of @code{nil} is ignored
1071in favor of @code{default-directory}.
1072
1073@item default-directory
1074@findex default-directory
1075Function with usage like variable @code{default-directory}, but knows about the
1076special cases in variable @code{default-directory-alist}.
1077@end table
1078
1079@node Find File At Point, Miscellaneous Commands, Multiple Dired Directories, Top
1080@comment node-name, next, previous, up
1081
1082@section Find File At Point
1083@cindex Visiting a file mentioned in a buffer
1084@cindex Finding a file at point
1085
1086@file{dired-x} provides a method of visiting or editing a file mentioned in
1087the buffer you are viewing (e.g., a mail buffer, a news article, a README
1088file, etc.) or to test if that file exists. You can then modify this in the
1089minibuffer after snatching the filename.
1090
1091When installed @file{dired-x} will substitute @code{dired-x-find-file} for
1092@code{find-file} (normally bound to @kbd{C-x C-f}) and
1093@code{dired-x-find-file-other-window} for @code{find-file-other-window}
1094(normally bound to @kbd{C-x 4 C-f}).
1095
1096In order to use this feature, you will need to set
1097@code{dired-x-hands-off-my-keys} to @code{nil} inside @code{dired-load-hook}
1098(@xref{Optional Installation File At Point}).
1099
1100@table @code
1101@item dired-x-find-file
1102@findex dired-x-find-file
1103@kindex C-x C-f
1104
1105@code{dired-x-find-file} behaves exactly like @code{find-file} (normally bound
1106to @kbd{C-x C-f}) unless a prefix argument is passed to the function in which
1107case it will use the filename at point as a guess for the file to visit.
1108
1109For example, if the buffer you were reading contained the words
1110
1111@example
1112Available via anonymous ftp in
1113
1114 /roebling.poly.edu:/pub/lisp/crypt++.el.gz
1115@end example
1116
1117then you could move your cursor to the line containing the ftp address and
1118type @kbd{C-u C-x C-f} (the @kbd{C-u} is a universal argument). The
1119minibuffer would read
1120
1121@example
1122Find file: /roebling.poly.edu:/pub/lisp/crypt++.el.gz
1123@end example
1124
1125with the point after the last @code{/}. If you hit return emacs will visit
1126the file at that address. This also works with files on your own computer.
1127
1128@item dired-x-find-file-other-window
1129@findex dired-x-find-file-other-window
1130@kindex C-x 4 C-f
1131
1132@code{dired-x-find-file-other-window} behaves exactly like
1133@code{find-file-other-window} (normally bound to @kbd{C-x 4 C-f}) unless a
1134prefix argument is used. See @code{dired-x-find-file} for more information.
1135
1136@item dired-x-hands-off-my-keys
1137@vindex dired-x-hands-off-my-keys
1138If set to @code{t}, then it means that @file{dired-x} should @emph{not} bind
1139@code{dired-x-find-file} over @code{find-file} on keyboard. Similarly, it
1140should not bind @code{dired-x-find-file-other-window} over
1141@code{find-file-other-window}. If you change this variable after
1142@file{dired-x.el} is loaded then do @kbd{M-x dired-x-bind-find-file}. The
1143default value of this variable is @kbd{t}; by default, the binding is not
1144done. See @xref{Optional Installation File At Point}.
1145
1146@item dired-x-bind-find-file
1147@findex dired-x-bind-find-file
1148A function, which can be called interactively or in your @file{~/.emacs} file,
1149that uses the value of @code{dired-x-hands-off-my-keys} to determine if
1150@code{dired-x-find-file} should be bound over @code{find-file} and
1151@code{dired-x-find-file-other-window} bound over
1152@code{find-file-other-window}. See @xref{Optional Installation File At Point}.
1153@end table
1154
1155@node Miscellaneous Commands, Bugs, Find File At Point, Top
1156@comment node-name, next, previous, up
1157@chapter Miscellaneous Commands
1158
1159Miscellaneous features not fitting anywhere else:
1160
1161@table @code
1162@item dired-find-subdir
1163@vindex dired-find-subdir
1164Default: @code{nil}
1165
1166If non-@code{nil}, Dired does not make a new buffer for a directory if it can
1167be found (perhaps as subdirectory) in some existing Dired buffer.
1168
1169If there are several Dired buffers for a directory, the most recently
1170used is chosen.
1171
1172Dired avoids switching to the current buffer, so that if you have a
1173normal and a wildcard buffer for the same directory, @kbd{C-x d RET}
1174will toggle between those two.
1175@end table
1176
1177@table @kbd
1178@findex dired-goto-file
1179@kindex M-g
1180@item M-g
1181(@code{dired-goto-file}) Goto file line of a file (or directory).
1182
1183@findex dired-goto-subdir
1184@kindex M-G
1185@item M-G
1186(@code{dired-goto-subdir}) Goto headerline of an inserted directory.
1187This commands reads its argument with completion over the names of the
1188inserted subdirectories.
1189@end table
1190
1191@table @kbd
1192@item w
1193@cindex Adding to the kill ring in dired.
1194@kindex w
1195@findex dired-copy-filename-as-kill
1196(@code{dired-copy-filename-as-kill}) The @kbd{w} command puts the names
1197of the marked (or next @var{N}) files into the kill ring, as if you had
1198killed them with @kbd{C-w}. With a zero prefix argument @var{N}=0, use the
1199complete pathname of each file. With a raw (just @kbd{C-u}) prefix argument,
1200use the relative pathname of each marked file. As a special case, if no
1201prefix argument is given and point is on a directory headerline, it
1202gives you the name of that directory, without looking for marked files.
1203
1204@vindex dired-marked-files
1205The list of names is also stored onto the variable @code{dired-marked-files}
1206for use, e.g., in the @kbd{M-:} (@code{eval-expression}) command.
1207
1208As this command also displays what was pushed onto the kill ring you can
1209use it to display the list of currently marked files in the
1210echo area (unless you happen to be on a subdirectory headerline).
1211
1212You can then feed the file name to other Emacs commands with @kbd{C-y}.
1213For example, say you want to rename a long filename to a slightly
1214different name. First type @kbd{w} to push the old name onto the kill
1215ring. Then type @kbd{R} to rename it and use @kbd{C-y} inside @kbd{R}'s
1216minibuffer prompt to insert the old name at a convenient place.
1217
1218@item T
1219@kindex T
1220@cindex Toggling marks.
1221@findex dired-do-toggle
1222(@code{dired-do-toggle}) Toggle marks. That is, currently marked
1223files become unmarked and vice versa. Files marked with other flags
1224(such as `D') are not affected. The special directories `.' and `..'
1225are never toggled.
1226@end table
1227
1228@table @code
1229@item dired-smart-shell-command
1230@findex dired-smart-shell-command
1231@findex shell-command
1232@kindex M-!
1233Like function @code{shell-command}, but in the current Dired directory.
1234Bound to @kbd{M-!} in Dired buffers.
1235
1236@item dired-jump
1237@findex dired-jump
1238@kindex C-x C-j
1239@cindex Jumping to dired listing containing file.
1240Bound to @kbd{C-x C-j}. Jump back to dired: If in a file, dired the current
1241directory and move to file's line. If in Dired already, pop up a level and
1242goto old directory's line. In case the proper Dired file line cannot be
1243found, refresh the Dired buffer and try again.
1244
1245@item dired-jump-other-window
1246@findex dired-jump-other-window
1247@kindex C-x 4 C-j
1248Bound to @kbd{C-x 4 C-j}. Like @code{dired-jump}, but to other window.
1249
1250These functions can be autoloaded so they work even though @file{dired-x.el}
1251has not been loaded yet (@xref{Optional Installation Dired Jump}).
1252
1253@vindex dired-bind-jump
1254If the variable @code{dired-bind-jump} is @code{nil}, @code{dired-jump} will not be
1255bound to @kbd{C-x C-j} and @code{dired-jump-other-window} will not be bound to
1256@kbd{C-x 4 C-j}.
1257
1258@item dired-vm
1259@cindex Reading mail.
1260@kindex V
1261@findex dired-vm
1262Bound to @kbd{V} if @code{dired-bind-vm} is t. Run VM on this file (assumed
1263to be a UNIX mail folder).
1264
1265@vindex dired-vm-read-only-folders
1266If you give this command a prefix argument, it will visit the folder
1267read-only. This only works in VM~5, not VM~4.
1268
1269If the variable @code{dired-vm-read-only-folders} is t, @code{dired-vm} will
1270visit all folders read-only. If it is neither @code{nil} nor @code{t}, e.g.,
1271the symbol @code{'if-file-read-only}, only files not writable by you are
1272visited read-only. This is the recommended value if you run VM 5.
1273
1274@vindex dired-bind-vm
1275If the variable @code{dired-bind-vm} is t, @code{dired-vm} will be bound to
1276@kbd{V}. Otherwise, @code{dired-bind-rmail} will be bound.
1277
1278@item dired-rmail
1279@cindex Reading mail.
1280@findex dired-rmail
1281Bound to @kbd{V} if @code{dired-bind-vm} is @code{nil}. Run Rmail on this
1282file (assumed to be mail folder in Rmail/BABYL format).
1283
1284@item dired-info
1285@kindex I
1286@cindex Running info.
1287@findex dired-info
1288Bound to @kbd{I}. Run Info on this file (assumed to be a file in Info
1289format).
1290
1291@vindex dired-bind-info
1292If the variable @code{dired-bind-info} is @code{nil}, @code{dired-info} will
1293not be bound to I.
1294
1295@item dired-man
1296@cindex Running man.
1297@kindex N
1298@findex dired-man
1299Bound to @kbd{N}. Run man on this file (assumed to be a file in nroff
1300format).
1301
1302@vindex dired-bind-man
1303If the variable @code{dired-bind-man} is @code{nil}, @code{dired-man} will not
1304be bound to N.
1305
1306@item dired-do-relative-symlink
1307@cindex Relative symbolic links.
1308@kindex Y
1309@findex dired-do-relative-symlink
1310Bound to @kbd{Y}. Relative symlink all marked (or next ARG) files into a
1311directory, or make a relative symbolic link to the current file. This creates
1312relative symbolic links like
1313
1314 foo -> ../bar/foo
1315
1316not absolute ones like
1317
1318 foo -> /ugly/path/that/may/change/any/day/bar/foo
1319
1320@item dired-do-relative-symlink-regexp
1321@kindex %Y
1322@findex dired-do-relative-symlink-regexp
1323Bound to @kbd{%Y}. Relative symlink all marked files containing REGEXP to
1324NEWNAME. See functions `dired-do-rename-regexp' and `dired-do-relsymlink' for
1325more info.
1326@end table
1327
1328@node Bugs, Concept Index, Miscellaneous Commands, Top
1329@comment node-name, next, previous, up
1330@chapter Bugs
1331@cindex Bugs
1332@findex dired-x-submit-report
1333
1334@noindent
1335If you encounter a bug in this package, wish to suggest an
1336enhancement, or want to make a smart remark, then type
1337
1338@example
1339@kbd{M-x dired-x-submit-report}
1340@end example
1341
1342@noindent
1343to set up an outgoing mail buffer, with the proper address to the
1344@file{dired-x.el} maintainer automatically inserted in the @samp{To:@:} field.
1345This command also inserts information that the Dired X maintainer can use to
1346recreate your exact setup, making it easier to verify your bug or social
1347maladjustment.
1348
1349Lawrence R. Dodd <dodd@@roebling.poly.edu>
1350
1351@node Concept Index, Command Index, Bugs, Top
1352@comment node-name, next, previous, up
1353@unnumbered Concept Index
1354@printindex cp
1355
1356@node Command Index, Key Index, Concept Index, Top
1357@comment node-name, next, previous, up
1358@unnumbered Function Index
1359@printindex fn
1360
1361@node Key Index, Variable Index, Command Index, Top
1362@comment node-name, next, previous, up
1363@unnumbered Key Index
1364@printindex ky
1365
1366@node Variable Index, , Key Index, Top
1367@comment node-name, next, previous, up
1368@unnumbered Variable Index
1369@printindex vr
1370
1371@c @summarycontents
1372@contents
1373
1374@bye
1375@c dired-x.texi ends here.