(help-for-help): Update help text.
[bpt/emacs.git] / lisp / dired-x.el
index 4beefd1..aed4373 100644 (file)
@@ -3,11 +3,11 @@
 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
 ;;     Lawrence R. Dodd <dodd@roebling.poly.edu>
 ;; Maintainer: Lawrence R. Dodd <dodd@roebling.poly.edu>
-;; Version: 2.27
-;; Date: 1994/04/05 12:45:30
+;; Version: 2.37+
+;; Date: 1994/08/18 19:27:42
 ;; Keywords: dired extensions
 
-;; Copyright (C) 1993, 1994 Free Software Foundation
+;; Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
-;;; This is Sebastian Kremer's excellent dired-x.el (Dired Extra), version
-;;; 1.191, hacked up for GNU Emacs 19.  Redundant or conflicting material
-;;; has been removed or renamed in order to work properly with dired of
-;;; GNU Emacs 19.  All suggestions or comments are most welcomed.
-;;;  
-;;; *Please* see the info pages.
-
-;;; BUGS: Type M-x dired-x-submit-report and a report will be generated.
-
-;;; INSTALLATION: In your ~/.emacs,
-;;;
-;;; (add-hook 'dired-load-hook
-;;;           (function (lambda ()
-;;;                       (load "dired-x")
-;;;                       ;; Set variables here.  For example:
-;;;                       ;; (setq dired-guess-shell-gnutar "gtar")
-;;;                       ;; (setq dired-omit-files-p t)
-;;;                       )))
-;;;
-;;; At load time dired-x.el will install itself, redefine some functions, and
-;;; bind some dired keys.  *Please* see the info pages for more details.
-
-;;; User defined variables:
-;;;
-;;;      dired-bind-vm
-;;;      dired-vm-read-only-folders
-;;;      dired-bind-jump
-;;;      dired-bind-info
-;;;      dired-bind-man
-;;;      dired-find-subdir
-;;;      dired-enable-local-variables
-;;;      dired-local-variables-file
-;;;      dired-guess-shell-gnutar
-;;;      dired-guess-shell-gzip-quiet
-;;;      dired-guess-shell-znew-switches
-;;;      dired-guess-shell-alist-user
-;;;      dired-clean-up-buffers-too
-;;;      dired-omit-files-p
-;;;      dired-omit-files
-;;;      dired-omit-extensions
-;;;
-;;; To find out more about these variables, load this file, put your cursor at
-;;; the end of any of the variable names, and hit C-h v [RET].  *Please* see
-;;; the info pages for more details.
-
-;;; When loaded this code redefines the following functions of GNU Emacs
-;;;
-;;;   Function                         Found in this file of GNU Emacs
-;;;   --------                         -------------------------------
-;;;   dired-clean-up-after-deletion    ../lisp/dired.el
-;;;   dired-find-buffer-nocreate       ../lisp/dired.el
-;;;   dired-initial-position           ../lisp/dired.el
-;;;   dired-up-directory               ../lisp/dired.el
-;;;
-;;;   dired-add-entry                  ../lisp/dired-aux.el
-;;;   dired-read-shell-command         ../lisp/dired-aux.el
-;;;
-;;; One drawback is that dired-x.el will load dired-aux.el as soon as dired is
-;;; loaded.  Thus, the advantage of separating out non-essential dired stuff
-;;; into dired-aux.el and only loading when necessary will be lost.  Please
-;;; note also that some of the comments in dired.el and dired-aux.el are
-;;; Kremer's that referred to the old dired-x.el.  This now should be referring
-;;; to this program.  (This is also a good reason to call this dired-x.el
-;;; instead of dired-x19.el.)
+;; This is Sebastian Kremer's excellent dired-x.el (Dired Extra), version
+;; 1.191, hacked up for GNU Emacs 19.  Redundant or conflicting material
+;; has been removed or renamed in order to work properly with dired of
+;; GNU Emacs 19.  All suggestions or comments are most welcomed.
+
+;;  
+;; Please, PLEASE, *PLEASE* see the info pages.
+;; 
+
+;; BUGS: Type M-x dired-x-submit-report and a report will be generated.
+
+;; INSTALLATION: In your ~/.emacs,
+;;
+;; (add-hook 'dired-load-hook
+;;           (function (lambda ()
+;;                       (load "dired-x")
+;;                       ;; Set global variables here.  For example:
+;;                       ;; (setq dired-guess-shell-gnutar "gtar")
+;;                       )))
+;; (add-hook 'dired-mode-hook
+;;           (function (lambda ()
+;;                       ;; Set buffer-local variables here.  For example:
+;;                       ;; (setq dired-omit-files-p t)
+;;                       )))
+;;
+;; At load time dired-x.el will install itself, redefine some functions, and
+;; bind some dired keys.  *Please* see the info pages for more details.
+
+;; CAUTION: If you are using a version of GNU Emacs earlier than 19.20 than
+;; you may have to edit dired.el.  The copy of dired.el in GNU Emacs versions
+;; earlier than 19.20 incorrectly had the call to run-hooks *before* the call
+;; to provide.  In such a case, it is possible that byte-compiling and/or
+;; loading dired can cause an infinite loop.  To prevent this, make sure the
+;; line of code
+;;  
+;;         (run-hooks 'dired-load-hook) 
+;;  
+;; is the *last* executable line in the file dired.el.  That is, make sure it
+;; comes *after* the line
+;;  
+;;         (provide 'dired) 
+;; 
+;; *Please* see the info pages for more details. 
+
+;; User defined variables:
+;;
+;;      dired-bind-vm
+;;      dired-vm-read-only-folders
+;;      dired-bind-jump
+;;      dired-bind-info
+;;      dired-bind-man
+;;      dired-x-hands-off-my-keys 
+;;      dired-find-subdir
+;;      dired-enable-local-variables
+;;      dired-local-variables-file
+;;      dired-guess-shell-gnutar
+;;      dired-guess-shell-gzip-quiet
+;;      dired-guess-shell-znew-switches
+;;      dired-guess-shell-alist-user
+;;      dired-clean-up-buffers-too
+;;      dired-omit-files-p
+;;      dired-omit-files
+;;      dired-omit-extensions
+;;      dired-omit-size-limit
+;;
+;; To find out more about these variables, load this file, put your cursor at
+;; the end of any of the variable names, and hit C-h v [RET].  *Please* see
+;; the info pages for more details.
+
+;; When loaded this code redefines the following functions of GNU Emacs
+;;
+;;   Function                         Found in this file of GNU Emacs
+;;   --------                         -------------------------------
+;;   dired-clean-up-after-deletion    ../lisp/dired.el
+;;   dired-find-buffer-nocreate       ../lisp/dired.el
+;;   dired-initial-position           ../lisp/dired.el
+;;
+;;   dired-add-entry                  ../lisp/dired-aux.el
+;;   dired-read-shell-command         ../lisp/dired-aux.el
+;;
+;; One drawback is that dired-x.el will load dired-aux.el as soon as dired is
+;; loaded.  Thus, the advantage of separating out non-essential dired stuff
+;; into dired-aux.el and only loading when necessary will be lost.  Please
+;; note also that some of the comments in dired.el and dired-aux.el are
+;; Kremer's that referred to the old dired-x.el.  This now should be referring
+;; to this program.  (This is also a good reason to call this dired-x.el
+;; instead of dired-x19.el.)
 
 \f
-;;;; Code:
+;;; Code:
+
+;; LOAD.
 
-;;; LOAD.
+;; This is a no-op if dired-x is being loaded via `dired-load-hook'.  It is
+;; here in case the user has autoloaded dired-x via the dired-jump key binding
+;; (instead of autoloading to dired as is suggested in the info-pages).
 
-;;; This is a no-op if dired-x is being loaded via `dired-load-hook'.  It is
-;;; here in case the user has autoloaded dired-x via the dired-jump key binding
-;;; (instead of autoloading to dired as is suggested in the info-pages).
+(require 'dired)
 
-;;; WARNING: The copy of dired.el in GNU Emacs versions earlier than 19.20 had
-;;; the `provide' *after* the `run-hooks'.  In such a case, loading dired below
-;;; will cause an infinite loop.  To prevent this we test the value of the GNU
-;;; Emacs major version number before requiring dired.
+;; We will redefine some functions and also need some macros so we need to
+;; load dired stuff of GNU Emacs.
 
-(if (string< "19.19"
-             ;; Compare with major version number (i.e., 19.22 not 19.22.11).
-             (substring emacs-version 0
-                        (and (string-match "^[0-9]*\\.[0-9]*" emacs-version)
-                             (match-end 0))))
-    (require 'dired))
+(require 'dired-aux)
 
-;;; We will redefine some functions and also need some macros so we need to
-;;; load dired stuff of GNU Emacs.  Since dired-aux.el (at least up to GNU
-;;; Emacs 19.22) does not `provide' itself, we do it here.  This avoids the
-;;; possibility recursive loading because of the nasty `eval-when-compile' that
-;;; is in dired-aux.el.
+;;; User-defined variables.
 
-(and (not (featurep 'dired-aux))
-     (load "dired-aux" nil t)
-     (not (featurep 'dired-aux))
-     (provide 'dired-aux))
+(defgroup dired-x nil
+  "Extended directory editing (dired-x)."
+  :group 'dired)
 
-;;;; User-defined variables.
+(defgroup dired-keys nil
+  "Dired keys customizations."
+  :prefix "dired-"
+  :group 'dired-x)
 
-(defvar dired-bind-vm nil
+(defcustom dired-bind-vm nil
   "*t says \"V\" in dired-mode will `dired-vm', otherwise \"V\" is `dired-rmail'.
 Also, RMAIL files contain -*- rmail -*- at the top so \"f\",
-`dired-advertised-find-file', will run rmail.")
-
-(defvar dired-bind-jump t
-  "*t says bind `dired-jump' to C-x C-j, otherwise do not.")
-
-(defvar dired-bind-man t
-  "*t says bind `dired-man' to \"N\" in dired-mode, otherwise do not.")
-
-(defvar dired-bind-info t
-  "*t says bind `dired-info' to \"I\" in dired-mode, otherwise do not.")
-
-(defvar dired-vm-read-only-folders nil
+`dired-advertised-find-file', will run rmail."
+  :type 'boolean
+  :group 'dired-keys)
+
+(defcustom dired-bind-jump t
+  "*t says bind `dired-jump' to C-x C-j, otherwise do not."
+  :type 'boolean
+  :group 'dired-keys)
+
+(defcustom dired-bind-man t
+  "*t says bind `dired-man' to \"N\" in dired-mode, otherwise do not."
+  :type 'boolean
+  :group 'dired-keys)
+
+(defcustom dired-bind-info t
+  "*t says bind `dired-info' to \"I\" in dired-mode, otherwise do not."
+  :type 'boolean
+  :group 'dired-keys)
+
+(defcustom dired-vm-read-only-folders nil
   "*If t, \\[dired-vm] will visit all folders read-only.
 If neither nil nor t, e.g. the symbol `if-file-read-only', only
 files not writable by you are visited read-only.
 
-Read-only folders only work in VM 5, not in VM 4.")
+Read-only folders only work in VM 5, not in VM 4."
+  :type '(choice (const :tag "off" nil)
+                (const :tag "on" t)
+                (sexp :tag "non-writable only" if-file-read-only))
+  :group 'dired-x)
 
-(defvar dired-omit-files-p nil
+(defcustom dired-omit-files-p nil
   "*If non-nil, \"uninteresting\" files are not listed (buffer-local).
 Use \\[dired-omit-toggle] to toggle its value.
 Uninteresting files are those whose filenames match regexp `dired-omit-files',
-plus those ending with extensions in `dired-omit-extensions'.")
-
-(defvar dired-omit-files "^#\\|\\.$"
-  "*Filenames matching this regexp will not be displayed (buffer-local).
-This only has effect when `dired-omit-files-p' is t.
-See also `dired-omit-extensions'.")
-
-(defvar dired-find-subdir nil           ; t is pretty near to DWIM...
-  "*If non-nil, Dired does not make a new buffer for a directory if it
-can be found (perhaps as subdir) in some existing Dired buffer.
+plus those ending with extensions in `dired-omit-extensions'."
+  :type 'boolean
+  :group 'dired-x)
+(make-variable-buffer-local 'dired-omit-files-p)
+
+(defcustom dired-omit-files "^#\\|^\\.$\\|^\\.\\.$"
+  "*Filenames matching this regexp will not be displayed.
+This only has effect when `dired-omit-files-p' is t.  See interactive function
+`dired-omit-toggle' \(\\[dired-omit-toggle]\) and variable
+`dired-omit-extensions'.  The default is to omit  `.', `..', and auto-save
+files."
+  :type 'regexp
+  :group 'dired-x)
+
+(defcustom dired-find-subdir nil           ; t is pretty near to DWIM...
+  "*If non-nil, Dired always finds a directory in a buffer of its own.
+If nil, Dired finds the directory as a subdirectory in some other buffer
+if it is present as one.
 
 If there are several Dired buffers for a directory, the most recently
 used is chosen.
 
 Dired avoids switching to the current buffer, so that if you have
 a normal and a wildcard buffer for the same directory, C-x d RET will
-toggle between those two.")
+toggle between those two."
+  :type 'boolean
+  :group 'dired-x)
+
+(defcustom dired-omit-size-limit 20000
+  "*Maximum size for the \"omitting\" feature.
+If nil, there is no maximum size."
+  :type '(choice (const :tag "no maximum" nil) integer)
+  :group 'dired-x)
 
-(defvar dired-enable-local-variables t
+(defcustom dired-enable-local-variables t
   "*Control use of local-variables lists in dired.
 The value can be t, nil or something else.
 A value of t means local-variables lists are obeyed;
 nil means they are ignored; anything else means query.
 
 This temporarily overrides the value of `enable-local-variables' when listing
-a directory.  See also `dired-local-variables-file'.")
+a directory.  See also `dired-local-variables-file'."
+  :type 'boolean
+  :group 'dired-x)
 
-(defvar dired-guess-shell-gnutar nil
+(defcustom dired-guess-shell-gnutar nil
   "*If non-nil, name of GNU tar executable (e.g., \"tar\" or \"gtar\") and `z'
 switch will be used for compressed or gzip'ed tar files.  If no GNU tar, set
-to nil: a pipe using `zcat' or `gunzip -c' will be used.")
+to nil: a pipe using `zcat' or `gunzip -c' will be used."
+  :type 'boolean
+  :group 'dired-x)
 
-(defvar dired-guess-shell-gzip-quiet t
-  "*non-nil says pass -q to gzip overriding verbose GZIP environment.")
+(defcustom dired-guess-shell-gzip-quiet t
+  "*non-nil says pass -q to gzip overriding verbose GZIP environment."
+  :type 'boolean
+  :group 'dired-x)
 
-(defvar dired-guess-shell-znew-switches nil
-  "*If non-nil, then string of switches passed to `znew', example: \"-K\"")
+(defcustom dired-guess-shell-znew-switches nil
+  "*If non-nil, then string of switches passed to `znew', example: \"-K\""
+  :type 'boolean
+  :group 'dired-x)
 
-(defvar dired-clean-up-buffers-too t
-  "*t says offer to kill buffers visiting files and dirs deleted in dired.")
+(defcustom dired-clean-up-buffers-too t
+  "*t says offer to kill buffers visiting files and dirs deleted in dired."
+  :type 'boolean
+  :group 'dired-x)
 
-;;;; KEY BINDINGS.
+;;; KEY BINDINGS.
 
 (define-key dired-mode-map "\M-o" 'dired-omit-toggle)
 (define-key dired-mode-map "\M-(" 'dired-mark-sexp)
+(define-key dired-mode-map "*(" 'dired-mark-sexp)
+(define-key dired-mode-map "*." 'dired-mark-extension)
 (define-key dired-mode-map "\M-!" 'dired-smart-shell-command)
 (define-key dired-mode-map "T" 'dired-do-toggle)
+(define-key dired-mode-map "*t" 'dired-do-toggle)
 (define-key dired-mode-map "w" 'dired-copy-filename-as-kill)
 (define-key dired-mode-map "\M-g" 'dired-goto-file)
 (define-key dired-mode-map "\M-G" 'dired-goto-subdir)
@@ -219,7 +277,7 @@ to nil: a pipe using `zcat' or `gunzip -c' will be used.")
       (define-key global-map "\C-x4\C-j" 'dired-jump-other-window)))
 
 \f
-;;;; Install into appropriate hooks.
+;;; Install into appropriate hooks.
 
 (add-hook 'dired-mode-hook 'dired-extra-startup)
 (add-hook 'dired-after-readin-hook 'dired-omit-expunge)
@@ -248,6 +306,7 @@ For more features, see variables
   dired-omit-files-p
   dired-omit-files
   dired-omit-extensions
+  dired-omit-size-limit
   dired-find-subdir
   dired-enable-local-variables
   dired-local-variables-file
@@ -275,9 +334,9 @@ See also functions
   (dired-omit-startup))
 
 \f
-;;;; BUFFER CLEANING.
+;;; BUFFER CLEANING.
 
-;;; REDEFINE.
+;; REDEFINE.
 (defun dired-clean-up-after-deletion (fn)
 
   ;; Clean up after a deleted file or directory FN.
@@ -296,7 +355,7 @@ See also functions
                                 (file-name-nondirectory fn)))
                (save-excursion ; you never know where kill-buffer leaves you
                  (kill-buffer buf))))
-        (let ((buf-list (dired-buffers-for-dir fn))
+        (let ((buf-list (dired-buffers-for-dir (expand-file-name fn)))
               (buf nil))
           (and buf-list
                (y-or-n-p (format "Kill dired buffer%s of %s, too? "
@@ -309,7 +368,7 @@ See also functions
   )
 
 \f
-;;;; EXTENSION MARKING FUNCTIONS.
+;;; EXTENSION MARKING FUNCTIONS.
 
 ;;; Mark files with some extension.
 (defun dired-mark-extension (extension &optional marker-char)
@@ -385,8 +444,9 @@ See variables `dired-texinfo-unclean-extensions',
                                 dired-tex-unclean-extensions
                                 (list ".dvi"))))
 \f
-;;;; JUMP.
+;;; JUMP.
 
+;;;###autoload
 (defun dired-jump (&optional other-window)
   "Jump to dired buffer corresponding to current buffer.
 If in a file, dired the current directory and move to file's line.
@@ -410,43 +470,22 @@ buffer and try again."
         (dired dir))
       (if file
           (or (dired-goto-file file)
-              ;; Toggle omitting, if necessary, and try again.
-              (progn
-                (dired-omit-toggle t)
-                (dired-goto-file file))
               ;; refresh and try again
               (progn
                 (dired-insert-subdir (file-name-directory file))
-                (dired-goto-file file)))))))
+                (dired-goto-file file))
+              ;; Toggle omitting, if it is on, and try again.
+             (if dired-omit-files-p
+                 (progn
+                   (dired-omit-toggle)
+                   (dired-goto-file file))))))))
 
 (defun dired-jump-other-window ()
   "Like \\[dired-jump] (dired-jump) but in other window."
   (interactive)
   (dired-jump t))
-
-;;; REDEFINE.
-;;; This replaces the version in dired.el
-;;; It simply adds the OTHER-WINDOW option to the one in dired.el.
-(defun dired-up-directory (&optional other-window)
-  "Run dired on parent directory of current directory.
-Find the parent directory either in this buffer or another buffer.
-Finds in current window or in other window with optional OTHER-WINDOW.
-Creates a buffer if necessary."
-  (interactive "P")
-  (let* ((dir (dired-current-directory))
-         (up (file-name-directory (directory-file-name dir))))
-    (or (dired-goto-file (directory-file-name dir))
-        ;; Only try dired-goto-subdir if buffer has more than one dir.
-        (and (cdr dired-subdir-alist)
-             (dired-goto-subdir up))
-        (progn
-          (if other-window
-              (dired-other-window up)
-            (dired up))
-          (dired-goto-file dir)))))
-
 \f
-;;;; TOGGLE.
+;;; TOGGLE.
 ;;; Toggle marked files with unmarked files.
 
 (defun dired-do-toggle ()
@@ -473,7 +512,7 @@ As always, hidden subdirs are not affected."
         (forward-line 1)))))
 
 \f
-;;;; COPY NAMES OF MARKED FILES INTO KILL-RING.
+;;; COPY NAMES OF MARKED FILES INTO KILL-RING.
 
 (defun dired-copy-filename-as-kill (&optional arg)
   "Copy names of marked (or next ARG) files into the kill ring.
@@ -502,7 +541,7 @@ You can then feed the file name(s) to other commands with \\[yank]."
     (message "%s" string)))
 
 \f
-;;;; OMITTING.
+;;; OMITTING.
 
 ;;; Enhanced omitting of lines from directory listings.
 ;;; Marked files are never omitted.
@@ -521,13 +560,12 @@ whole pathname.")
 Should never be used as marker by the user or other packages.")
 
 (defun dired-omit-startup ()
-  (make-local-variable 'dired-omit-files-p)
   (or (assq 'dired-omit-files-p minor-mode-alist)
       (setq minor-mode-alist
             (append '((dired-omit-files-p " Omit")) minor-mode-alist))))
 
 (defun dired-omit-toggle (&optional flag)
-  "Toggle between displaying and omitting files matching `dired-omit-files'.
+  "Toggle omitting files matching `dired-omit-files' and `dired-omit-extensions'.
 With an arg, and if omitting was off, don't toggle and just mark the
   files but don't actually omit them.
 With an arg, and if omitting was on, turn it off but don't refresh the buffer."
@@ -542,21 +580,26 @@ With an arg, and if omitting was on, turn it off but don't refresh the buffer."
     (if (not dired-omit-files-p)
         (revert-buffer)
       ;; this will mention how many were omitted:
-      (dired-omit-expunge))))
+      (let ((dired-omit-size-limit nil))
+        (dired-omit-expunge)))))
 
 (defvar dired-omit-extensions
   (append completion-ignored-extensions
           dired-latex-unclean-extensions
           dired-bibtex-unclean-extensions
           dired-texinfo-unclean-extensions)
-  "If non-nil, a list of extensions (strings) to omit from Dired
-listings.  Defaults to the elements of
-`completion-ignored-extensions', `dired-latex-unclean-extensions',
-`dired-bibtex-unclean-extensions' and `dired-texinfo-unclean-extensions'.")
+  "If non-nil, a list of extensions \(strings\) to omit from Dired listings.  
+Defaults to elements of `completion-ignored-extensions',
+`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and
+`dired-texinfo-unclean-extensions'.  
+
+See interactive function `dired-omit-toggle' \(\\[dired-omit-toggle]\) and
+variables `dired-omit-files-p' and `dired-omit-files'.")
 
 (defun dired-omit-expunge (&optional regexp)
   "Erases all unmarked files matching REGEXP.
-Does nothing if global variable `dired-omit-files-p' is nil.
+Does nothing if global variable `dired-omit-files-p' is nil, or if called
+  non-interactively and buffer is bigger than `dired-omit-size-limit'.
 If REGEXP is nil or not specified, uses `dired-omit-files', and also omits
   filenames ending in `dired-omit-extensions'.
 If REGEXP is the empty string, this function is a no-op.
@@ -564,8 +607,12 @@ If REGEXP is the empty string, this function is a no-op.
 This functions works by temporarily binding `dired-marker-char' to
 `dired-omit-marker-char' and calling `dired-do-kill-lines'."
   (interactive "sOmit files (regexp): ")
-  (if dired-omit-files-p
+  (if (and dired-omit-files-p
+           (or (interactive-p)
+               (not dired-omit-size-limit)
+               (< (buffer-size) dired-omit-size-limit)))
       (let ((omit-re (or regexp (dired-omit-regexp)))
+            (old-modified-p (buffer-modified-p))
             count)
         (or (string= omit-re "")
             (let ((dired-marker-char dired-omit-marker-char))
@@ -573,9 +620,14 @@ This functions works by temporarily binding `dired-marker-char' to
               (if (dired-mark-unmarked-files omit-re nil nil dired-omit-localp)
                   (progn
                     (setq count (dired-do-kill-lines nil "Omitted %d line%s."))
-                    ;; Force an update of modeline.
-                    (set-buffer-modified-p (buffer-modified-p)))
+                    (force-mode-line-update))
                 (message "(Nothing to omit)"))))
+        ;; Try to preserve modified state of buffer.  So `%*' doesn't appear
+        ;; in mode-line of omitted buffers.
+        (set-buffer-modified-p (and old-modified-p 
+                                    (save-excursion
+                                      (goto-char (point-min))
+                                      (re-search-forward dired-re-mark nil t))))
         count)))
 
 (defun dired-omit-regexp ()
@@ -642,7 +694,7 @@ Second optional argument LOCALP is as in `dired-get-filename'."
 (fset 'dired-add-entry 'dired-omit-new-add-entry)
 
 \f
-;;;; VIRTUAL DIRED MODE.
+;;; VIRTUAL DIRED MODE.
 
 ;;; For browsing `ls -lR' listings in a dired-like fashion.
 
@@ -761,13 +813,13 @@ to put saved dired buffers automatically into virtual dired mode.
 
 Also useful for `auto-mode-alist' (which see) like this:
 
-  \(setq auto-mode-alist (cons '(\"[^/]\\.dired$\" . dired-virtual-mode)
+  \(setq auto-mode-alist (cons '(\"[^/]\\.dired\\'\" . dired-virtual-mode)
                               auto-mode-alist)\)"
   (interactive)
   (dired-virtual (dired-virtual-guess-dir)))
 
 \f
-;;;; SMART SHELL.
+;;; SMART SHELL.
 
 ;;; An Emacs buffer can have but one working directory, stored in the
 ;;; buffer-local variable `default-directory'.  A Dired buffer may have
@@ -801,7 +853,7 @@ cases in variable `default-directory-alist' (which see)."
     (shell-command cmd insert)))
 
 \f
-;;;; LOCAL VARIABLES FOR DIRED BUFFERS.
+;;; LOCAL VARIABLES FOR DIRED BUFFERS.
 
 ;;; Brief Description:
 ;;;
@@ -822,7 +874,7 @@ cases in variable `default-directory-alist' (which see)."
 ;;;   `dired-enable-local-variables' and run `hack-local-variables' on the
 ;;;   Dired Buffer.
 
-(defvar dired-local-variables-file ".dired"
+(defvar dired-local-variables-file (convert-standard-filename ".dired")
   "Filename, as string, containing local dired buffer variables to be hacked.
 If this file found in current directory, then it will be inserted into dired
 buffer and `hack-local-variables' will be run.  See Emacs Info pages for more
@@ -872,7 +924,7 @@ dired."
     (dired-revert)))
 
 \f
-;;;; GUESS SHELL COMMAND.
+;;; GUESS SHELL COMMAND.
 
 ;;; Brief Description:
 ;;;
@@ -889,11 +941,11 @@ dired."
 ;;;   that matches the first file in the file list.
 ;;;
 ;;; * If the REGEXP matches all the entries of the file list then evaluate
-;;;   COMMAND, which is either a string or an elisp expression returning a
+;;;   COMMAND, which is either a string or a Lisp expression returning a
 ;;;   string.  COMMAND may be a list of commands.
 ;;;
 ;;; * Return this command to `dired-guess-shell-command' which prompts user
-;;;   with it.  The list of commands are temporaily put into the history list.
+;;;   with it.  The list of commands is temporarily put into the history list.
 ;;;   If a command is used successfully then it is stored permanently in
 ;;;   `dired-shell-command-history'.
 
@@ -934,11 +986,11 @@ dired."
    '("\\.shar.Z$" "zcat * | unshar")
    '("\\.shar.g?z$" "gunzip -qc * | unshar")
 
-   '("\\.ps$" "ghostview" "xv" "lpr")
-   (list "\\.ps.g?z$" "gunzip -qc * | ghostview -"
+   '("\\.e?ps$" "ghostview" "xv" "lpr")
+   (list "\\.e?ps.g?z$" "gunzip -qc * | ghostview -"
          ;; Optional decompression.
          '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
-   (list "\\.ps.Z$" "zcat * | ghostview -"
+   (list "\\.e?ps.Z$" "zcat * | ghostview -"
          ;; Optional conversion to gzip format.
          '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
                   " " dired-guess-shell-znew-switches))
@@ -1116,7 +1168,7 @@ You can set this variable in your ~/.emacs.  For example, to add rules for
    files))                                       ; FILES
 
 \f
-;;;; RELATIVE SYMBOLIC LINKS.
+;;; RELATIVE SYMBOLIC LINKS.
 
 (defvar dired-keep-marker-relsymlink ?S
   "See variable `dired-keep-marker-move'.")
@@ -1147,7 +1199,7 @@ results in
                   ;; `/', so NEXT is *one plus* the result of the
                   ;; string-match.
                   ;; E.g., consider the case of linking "/tmp/a/abc"
-                  ;; to "/tmp/abc" erronously giving "/tmp/a" instead
+                  ;; to "/tmp/abc" erroneously giving "/tmp/a" instead
                   ;; of "/tmp/" as common initial component
                   (string-equal (substring file1 0 next)
                                 (substring file2 0 next)))
@@ -1199,7 +1251,7 @@ for more info."
    "RelSymLink" nil regexp newname whole-path dired-keep-marker-relsymlink))
 
 \f
-;;;; VISIT ALL MARKED FILES SIMULTANEOUSLY.
+;;; VISIT ALL MARKED FILES SIMULTANEOUSLY.
 
 ;;; Brief Description:
 ;;;
@@ -1281,58 +1333,18 @@ To display just marked files, type \\[delete-other-windows] first."
       (setq file-list (cdr file-list)))))
 
 \f
-;;;; MISCELLANEOUS COMMANDS.
+;;; MISCELLANEOUS COMMANDS.
 
 ;;; Run man on files.
 
 (defun dired-man ()
   "Run man on this file.  Display old buffer if buffer name matches filename.
-Results displayed based on value of `Man-notify'.  See that variable."
+Uses ../lisp/man.el of \\[manual-entry] fame."
   (interactive)
-  (let* ((file (dired-get-filename))
-         (string (format "*man %s*" (file-name-nondirectory file)))
-         (Man-buffer (get-buffer string))
-         (msg "Expanding manual page...cleaning...done"))
-
-    ;; If Man-buffer already exists and has not been modified, display it.
-    ;; Otherwise, create a fresh one.
-    (if (and Man-buffer
-             (save-excursion
-               (set-buffer Man-buffer)
-               (not (buffer-modified-p))
-               buffer-read-only))
-
-        (setq msg "Displaying pre-existing manual page.")
-
-      ;; Create Man-buffer.
-      (save-excursion
-
-        ;; Prepare buffer.
-        (setq Man-buffer (get-buffer-create string))
-        (set-buffer Man-buffer)
-        (setq buffer-read-only nil)
-        (erase-buffer)
-
-        ;; Expand and clean man page.
-        (message "Expanding manual page...")
-        (call-process shell-file-name nil t nil "-c"
-                      (concat " nroff -man -h " file))
-        (message "Expanding manual page...cleaning...")
-        (call-process-region (point-min) (point-max)
-                             shell-file-name t t nil "-c" " col -b")
-        (goto-char (point-min))
-
-        ;; Reset buffer.
-        (setq buffer-read-only t)
-        (buffer-disable-undo (current-buffer))
-        (set-buffer-modified-p nil)))
-
-    ;; Display results.  Use display function of ../lisp/man.el whose behavior
-    ;; is determined by user-defined variable Man-notify.
-    (require 'man)
-    (Man-notify-when-ready Man-buffer)
-    ;; Overrides any message issued by above function.
-    (message msg)))
+  (require 'man)
+  (let ((file (dired-get-filename))
+        (manual-program "nroff -man -h"))
+    (Man-getpage-in-background file)))
 
 ;;; Run Info on files.
 
@@ -1377,7 +1389,7 @@ See also variable `dired-vm-read-only-folders'."
     (dired-rmail)))
 
 \f
-;;;; MISCELLANEOUS INTERNAL FUNCTIONS.
+;;; MISCELLANEOUS INTERNAL FUNCTIONS.
 
 (or (fboundp 'dired-old-find-buffer-nocreate)
     (fset 'dired-old-find-buffer-nocreate
@@ -1385,19 +1397,22 @@ See also variable `dired-vm-read-only-folders'."
 
 ;;; REDEFINE.
 ;;; Redefines dired.el's version of `dired-find-buffer-nocreate'
-(defun dired-find-buffer-nocreate (dirname)
-  (if dired-find-subdir
+(defun dired-find-buffer-nocreate (dirname &optional mode)
+  (if (and dired-find-subdir
+          ;; don't try to find a wildcard as a subdirectory
+          (string-equal dirname (file-name-directory dirname)))
       (let* ((cur-buf (current-buffer))
-             (buffers (nreverse (dired-buffers-for-dir dirname)))
-             (cur-buf-matches (and (memq cur-buf buffers)
-                                   ;; wildcards must match, too:
-                                   (equal dired-directory dirname))))
-        ;; We don't want to switch to the same buffer---
-        (setq buffers (delq cur-buf buffers));;need setq with delq
-        (or (car (sort buffers (function dired-buffer-more-recently-used-p)))
-            ;; ---unless it's the only possibility:
-            (and cur-buf-matches cur-buf)))
-    (dired-old-find-buffer-nocreate dirname)))
+            (buffers (nreverse
+                      (dired-buffers-for-dir (expand-file-name dirname))))
+            (cur-buf-matches (and (memq cur-buf buffers)
+                                  ;; wildcards must match, too:
+                                  (equal dired-directory dirname))))
+       ;; We don't want to switch to the same buffer---
+       (setq buffers (delq cur-buf buffers));;need setq with delq
+       (or (car (sort buffers (function dired-buffer-more-recently-used-p)))
+           ;; ---unless it's the only possibility:
+           (and cur-buf-matches cur-buf)))
+    (dired-old-find-buffer-nocreate dirname mode)))
 
 ;; This should be a builtin
 (defun dired-buffer-more-recently-used-p (buffer1 buffer2)
@@ -1454,7 +1469,7 @@ PREDICATE is a lisp expression that can refer to the following symbols:
 
     inode  [integer] the inode of the file (only for ls -i output)
     s      [integer] the size of the file for ls -s output
-                     (ususally in blocks or, with -k, in KByte)
+                     (usually in blocks or, with -k, in KByte)
     mode   [string]  file permission bits, e.g. \"-rw-r--r--\"
     nlink  [integer] number of links to file
     uid    [string]  owner
@@ -1537,25 +1552,72 @@ to mark all zero length files."
      (format "'%s file" predicate))))
 
 \f
-;;;; FIND FILE AT POINT.
-(defun dired-find-this-file (&optional other-window)
-  "Edit filename or directory at point.
-Switch to a buffer visiting filename, creating one if none already exists.
-With non-nil prefix argument OTHER-WINDOW do so in the other window.
-
-Useful for editing the file mentioned in the buffer you are viewing, or to
-test if that file exists.  Use minibuffer after snatching the filename."
-
-  (interactive "P")
-  (let* ((guess (dired-filename-at-point))
-         (file (read-file-name "Find file: " guess guess nil nil)))
-    (if other-window
-        (find-file-other-window (expand-file-name file))
-      (find-file (expand-file-name file)))))
-
-(fset 'find-this-file 'dired-find-this-file)
-
-;;; Internal function.
+;;; FIND FILE AT POINT.
+
+(defvar dired-x-hands-off-my-keys t
+  "*t means don't bind `dired-x-find-file' over `find-file' on keyboard.
+Similarly for `dired-x-find-file-other-window' over `find-file-other-window'.
+If you change this variable after dired-x.el is loaded then do
+\\[dired-x-bind-find-file].")
+
+;;; Bind `dired-x-find-file{-other-window}' over wherever
+;;; `find-file{-other-window}' is bound?
+(defun dired-x-bind-find-file ()
+  "Bind `dired-x-find-file' in place of `find-file' \(or reverse\).
+Similarly for `dired-x-find-file-other-window' and `find-file-other-window'.
+Binding direction based on `dired-x-hands-off-my-keys'.
+This function part of `after-init-hook'."
+  (interactive)
+  (if (interactive-p)
+      (setq dired-x-hands-off-my-keys
+            (not (y-or-n-p "Bind dired-x-find-file over find-file? "))))
+  (cond ((not dired-x-hands-off-my-keys)
+         (substitute-key-definition 'find-file
+                                    'dired-x-find-file
+                                    (current-global-map))
+         (substitute-key-definition 'find-file-other-window
+                                    'dired-x-find-file-other-window
+                                    (current-global-map)))
+        (t
+         (substitute-key-definition 'dired-x-find-file
+                                    'find-file
+                                    (current-global-map))
+         (substitute-key-definition 'dired-x-find-file-other-window
+                                    'find-file-other-window
+                                    (current-global-map))))
+  ;; Clear mini-buffer.
+  (message nil))
+
+;;; Now call it so binding is correct and put on `after-init-hook' in case
+;;; user changes binding.
+(dired-x-bind-find-file)
+(add-hook 'after-init-hook 'dired-x-bind-find-file)
+
+(defun dired-x-find-file (filename)
+  "Edit file FILENAME.
+May create a new window, or reuse an existing one.
+See the function `display-buffer'.
+
+Identical to `find-file' except when called interactively, with a prefix arg
+\(e.g., \\[universal-argument]\), in which case it guesses filename near
+point.  Useful for editing file mentioned in buffer you are viewing, or to
+test if that file exists.  Use minibuffer after snatching filename."
+  (interactive (list (read-filename-at-point "Find file: ")))
+  (find-file (expand-file-name filename)))
+
+(defun dired-x-find-file-other-window (filename)
+  "Edit file FILENAME, in another window.
+May create a new window, or reuse an existing one.
+See the function `display-buffer'.
+
+Identical to `find-file-other-window' except when called interactively, with a
+prefix arg \(e.g., \\[universal-argument]\), in which case it guesses filename
+near point.  Useful for editing file mentioned in buffer you are viewing, or
+to test if that file exists.  Use minibuffer after snatching filename."
+  (interactive (list (read-filename-at-point "Find file: ")))
+  (find-file-other-window (expand-file-name filename)))
+
+;;; Internal functions.
 (defun dired-filename-at-point ()
 
   ;; Get the filename closest to point, but do not change position.  Has a
@@ -1590,13 +1652,24 @@ test if that file exists.  Use minibuffer after snatching the filename."
       ;; Return string.
       (expand-file-name (buffer-substring start (point))))))
 
+(defun read-filename-at-point (prompt)
+  ;;; Returns filename prompting with PROMPT with completion.  If
+  ;;; `current-prefix-arg' is non-nil, uses name at point as guess.
+  (if current-prefix-arg
+      (let ((guess (dired-filename-at-point)))
+        (read-file-name prompt
+                        (file-name-directory guess)
+                        guess
+                        nil (file-name-nondirectory guess)))
+    (read-file-name prompt default-directory)))
+
 \f
-;;;; BUG REPORTS
+;;; BUG REPORTS
 
 ;;; This section is provided for reports.  It uses Barry A. Warsaw's
 ;;; reporter.el which is bundled with GNU Emacs v19.
 
-(defconst dired-x-version "2.27"
+(defconst dired-x-version "2.37"
   "Revision number of dired-x.el -- dired extra for GNU Emacs v19.
 Type \\[dired-x-submit-report] to send a bug report.  Available via anonymous
 ftp in