]> code.delx.au - gnu-emacs/blobdiff - lisp/dired-x.el
(calendar-astro-from-absolute): Autoload it.
[gnu-emacs] / lisp / dired-x.el
index 9ea749223ba35b1932132ba4f9fc883923847148..c8300886cdc9fbe40314fff34162a5ffb7da9d8e 100644 (file)
@@ -3,8 +3,8 @@
 ;; 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.14
-;; Date: 1994/01/03 15:47:50 
+;; Version: 2.37+
+;; Date: 1994/08/18 19:27:42
 ;; Keywords: dired extensions
 
 ;; Copyright (C) 1993, 1994 Free Software Foundation
@@ -13,7 +13,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
-;;; Commentary: 
+;;; Commentary:
 
-;;; This is Sebastian Kremer's 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.  All
-;;; suggestions or comments are most welcomed.  There is also a texinfo file.
+;;; 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, 
+;;; INSTALLATION: In your ~/.emacs,
 ;;;
-;;; (add-hook 'dired-load-hook 
+;;; (add-hook 'dired-load-hook
 ;;;           (function (lambda ()
 ;;;                       (load "dired-x")
-;;;                       ;; Set variables here.  For example:
+;;;                       ;; 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.  See also the info pages.
+;;; 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-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].
+;;;
+;;; 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-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 
-;;; 
+;;;   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 a good reason to call this dired-x.el
+;;; 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
 
 ;;; 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).
+
+(require 'dired)
+
 ;;; We will redefine some functions and also need some macros so we need to
-;;; load dired stuff of GNU Emacs.  Since dired-aux.el does not `provide'
-;;; itself, we do it here.  This avoids the possibility recursive loading
-;;; because of the nasty `eval-when-compile' in dired-aux.el.
-
-(and (not (featurep 'dired-aux))
-     (load "dired-aux" nil t)
-     (provide 'dired-aux))
-                                         
+;;; load dired stuff of GNU Emacs.
+
+(require 'dired-aux)
+
 ;;;; User-defined variables.
 
 (defvar dired-bind-vm nil
@@ -130,15 +158,19 @@ Read-only folders only work in VM 5, not in VM 4.")
 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'.")
+(make-variable-buffer-local 'dired-omit-files-p)
 
-(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-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.")
 
 (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.
+  "*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.
@@ -190,7 +222,7 @@ to nil: a pipe using `zcat' or `gunzip -c' will be used.")
 (if dired-bind-info
     (define-key dired-mode-map "I" 'dired-info))
 
-;;; GLOBAL BINDING. 
+;;; GLOBAL BINDING.
 (if dired-bind-jump
     (progn
       (define-key global-map "\C-x\C-j" 'dired-jump)
@@ -233,7 +265,7 @@ For more features, see variables
   dired-guess-shell-gzip-quiet
   dired-guess-shell-znew-switches
   dired-guess-shell-alist-user
-  dired-clean-up-buffers-too 
+  dired-clean-up-buffers-too
 
 See also functions
 
@@ -274,7 +306,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? "
@@ -283,13 +315,13 @@ See also functions
                (while buf-list
                  (save-excursion (kill-buffer (car buf-list)))
                  (setq buf-list (cdr buf-list)))))))
-  ;; Anything else? 
+  ;; Anything else?
   )
 
 \f
 ;;;; EXTENSION MARKING FUNCTIONS.
 
-;;; Mark files with some extension. 
+;;; Mark files with some extension.
 (defun dired-mark-extension (extension &optional marker-char)
   "Mark all files with a certain extension for use in later commands.
 A `.' is not automatically prepended to the string entered."
@@ -341,23 +373,31 @@ See variable `dired-patch-unclean-extensions'."
   (dired-flag-extension dired-patch-unclean-extensions))
 
 (defun dired-clean-tex ()
-  "Flag dispensable files created by tex etc. for deletion.
-See variable `dired-texinfo-unclean-extensions', `dired-latex-unclean-extensions',
-`dired-bibtex-unclean-extensions' and `dired-texinfo-unclean-extensions'."
+  "Flag dispensable files created by [La]TeX etc. for deletion.
+See variables `dired-texinfo-unclean-extensions',
+`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and
+`dired-texinfo-unclean-extensions'."
   (interactive)
   (dired-flag-extension (append dired-texinfo-unclean-extensions
                                 dired-latex-unclean-extensions
                                 dired-bibtex-unclean-extensions
                                 dired-tex-unclean-extensions)))
 
-(defun dired-clean-dvi ()
-  "Flag dispensable `.dvi' files from tex etc. for deletion."
+(defun dired-very-clean-tex ()
+  "Flag dispensable files created by [La]TeX *and* \".dvi\" for deletion.
+See variables `dired-texinfo-unclean-extensions',
+`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and
+`dired-texinfo-unclean-extensions'."
   (interactive)
-  (dired-flag-extension ".dvi"))
-
+  (dired-flag-extension (append dired-texinfo-unclean-extensions
+                                dired-latex-unclean-extensions
+                                dired-bibtex-unclean-extensions
+                                dired-tex-unclean-extensions
+                                (list ".dvi"))))
 \f
 ;;;; 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.
@@ -373,7 +413,7 @@ buffer and try again."
           (dired-up-directory other-window)
           (or (dired-goto-file dir)
               ;; refresh and try again
-              (progn     
+              (progn
                 (dired-insert-subdir (file-name-directory dir))
                 (dired-goto-file dir))))
       (if other-window
@@ -381,8 +421,12 @@ 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                            
+              (progn
                 (dired-insert-subdir (file-name-directory file))
                 (dired-goto-file file)))))))
 
@@ -390,28 +434,6 @@ buffer and try again."
   "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 marked files with unmarked files.
@@ -441,7 +463,7 @@ As always, hidden subdirs are not affected."
 
 \f
 ;;;; 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.
 The names are separated by a space.
@@ -488,13 +510,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."
@@ -516,10 +537,13 @@ With an arg, and if omitting was on, turn it off but don't refresh the buffer."
           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.
@@ -533,6 +557,7 @@ This functions works by temporarily binding `dired-marker-char' to
   (interactive "sOmit files (regexp): ")
   (if dired-omit-files-p
       (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))
@@ -540,9 +565,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 ()
@@ -573,7 +603,7 @@ Second optional argument LOCALP is as in `dired-get-filename'."
         (and fn (string-match regexp fn))))
      msg)))
 
-;;; REDEFINE. 
+;;; REDEFINE.
 (defun dired-omit-new-add-entry (filename &optional marker-char)
   ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for
   ;; files that are going to be omitted anyway.
@@ -600,7 +630,7 @@ Second optional argument LOCALP is as in `dired-get-filename'."
     ;; omitting is not turned on at all
     (dired-omit-old-add-entry filename marker-char)))
 
-;;; REDEFINE. 
+;;; REDEFINE.
 ;;; Redefine dired-aux.el's version of `dired-add-entry'
 ;;; Save old defun if not already done:
 (or (fboundp 'dired-omit-old-add-entry)
@@ -728,7 +758,7 @@ 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)))
@@ -770,21 +800,21 @@ cases in variable `default-directory-alist' (which see)."
 \f
 ;;;; LOCAL VARIABLES FOR DIRED BUFFERS.
 
-;;; Brief Description: 
-;;; 
-;;; * `dired-extra-startup' is part of the `dired-mode-hook'. 
-;;; 
+;;; Brief Description:
+;;;
+;;; * `dired-extra-startup' is part of the `dired-mode-hook'.
+;;;
 ;;; * `dired-extra-startup' calls `dired-hack-local-variables'
-;;; 
+;;;
 ;;; * `dired-hack-local-variables' checks the value of
-;;;   `dired-local-variables-file' 
-;;; 
+;;;   `dired-local-variables-file'
+;;;
 ;;; * Check if `dired-local-variables-file' is a non-nil string and is a
 ;;;   filename found in the directory of the Dired Buffer being created.
-;;; 
+;;;
 ;;; * If `dired-local-variables-file' satisfies the above, then temporarily
 ;;;   include it in the Dired Buffer at the bottom.
-;;;  
+;;;
 ;;; * Set `enable-local-variables' temporarily to the user variable
 ;;;   `dired-enable-local-variables' and run `hack-local-variables' on the
 ;;;   Dired Buffer.
@@ -816,13 +846,13 @@ information on local variables.  See also `dired-enable-local-variables'.")
         ;; Make sure that the modeline shows the proper information.
         (dired-sort-set-modeline)
         ;; Delete this stuff: `eobp' is used to find last subdir by dired.el.
-        (delete-region opoint (point-max)))))        
+        (delete-region opoint (point-max)))))
 
-(defun dired-omit-here-always () 
+(defun dired-omit-here-always ()
   "Creates `dired-local-variables-file' for omitting and reverts directory.
 Sets dired-omit-file-p to t in a local variables file that is readable by
 dired."
-  (interactive) 
+  (interactive)
   (if (file-exists-p dired-local-variables-file)
       (message "File `./%s' already exists." dired-local-variables-file)
 
@@ -841,24 +871,24 @@ dired."
 \f
 ;;;; GUESS SHELL COMMAND.
 
-;;; Brief Description: 
-;;; 
-;;; `dired-do-shell-command' is bound to `!' by dired.el. 
-;;; 
+;;; Brief Description:
+;;;
+;;; `dired-do-shell-command' is bound to `!' by dired.el.
+;;;
 ;;; * Redefine `dired-do-shell-command' so it calls
 ;;;   `dired-guess-shell-command'.
-;;;  
+;;;
 ;;; * `dired-guess-shell-command' calls `dired-guess-default' with list of
 ;;;    marked files.
-;;;  
+;;;
 ;;; * Parse `dired-guess-shell-alist-user' and
 ;;;   `dired-guess-shell-alist-default' (in that order) for the first REGEXP
 ;;;   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.
 ;;;   If a command is used successfully then it is stored permanently in
@@ -868,7 +898,7 @@ dired."
 (defvar dired-shell-command-history nil
   "History list for commands that read dired-shell commands.")
 
-;;; Default list of shell commands. 
+;;; Default list of shell commands.
 
 ;;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files.  Some do not
 ;;; install GNU zip's version of zcat.
@@ -905,7 +935,7 @@ dired."
    (list "\\.ps.g?z$" "gunzip -qc * | ghostview -"
          ;; Optional decompression.
          '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
-   (list "\\.ps.Z$" "zcat * | ghostview -" 
+   (list "\\.ps.Z$" "zcat * | ghostview -"
          ;; Optional conversion to gzip format.
          '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
                   " " dired-guess-shell-znew-switches))
@@ -917,7 +947,7 @@ dired."
                   " " dired-guess-shell-znew-switches))
 
    '("\\.dvi$" "xdvi" "dvips")          ; preview and printing
-   '("\\.au$" "play")                   ; play Sun audiofiles 
+   '("\\.au$" "play")                   ; play Sun audiofiles
    '("\\.mpg$" "mpeg_play")
    '("\\.uu$" "uudecode")               ; for uudecoded files
    '("\\.hqx$" "mcvert")
@@ -947,7 +977,7 @@ dired."
          '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
                   " " dired-guess-shell-znew-switches))
    )
-  
+
   "Default alist used for shell command guessing.
 See `dired-guess-shell-alist-user'")
 
@@ -979,8 +1009,8 @@ You can set this variable in your ~/.emacs.  For example, to add rules for
 
 (defun dired-guess-default (files)
 
-  ;; Guess a shell commands for FILES.  Return command or list of commands. 
-  ;; See `dired-guess-shell-alist-user'. 
+  ;; Guess a shell commands for FILES.  Return command or list of commands.
+  ;; See `dired-guess-shell-alist-user'.
 
   (let* ((case-fold-search nil) ; case-sensitive matching
          ;; Prepend the user's alist to the default alist.
@@ -1003,13 +1033,13 @@ You can set this variable in your ~/.emacs.  For example, to add rules for
     (while (and flist
                 (string-match regexp (car flist)))
       (setq flist (cdr flist)))
-    
+
     ;; If flist is still non-nil, then do not guess since this means that not
     ;; all the files in FILES were matched by the regexp.
     (setq cmds (and (not flist) cmds))
 
-    ;; Return commands or nil if flist is still non-nil. 
-    ;; Evaluate the commands in order that any logical testing will be done. 
+    ;; Return commands or nil if flist is still non-nil.
+    ;; Evaluate the commands in order that any logical testing will be done.
     (cond ((not (cdr cmds))
            (eval (car cmds))) ; single command
           (t
@@ -1069,7 +1099,7 @@ You can set this variable in your ~/.emacs.  For example, to add rules for
                       (cons val dired-shell-command-history))))))))
 
 
-;;; REDEFINE. 
+;;; REDEFINE.
 ;;; Redefine dired-aux.el's version:
 (defun dired-read-shell-command (prompt arg files)
 ;;  "Read a dired shell command prompting with PROMPT (using read-string).
@@ -1168,26 +1198,26 @@ for more info."
 \f
 ;;;; VISIT ALL MARKED FILES SIMULTANEOUSLY.
 
-;;; Brief Description: 
-;;; 
-;;; `dired-do-find-marked-files' is bound to `F' by dired-x.el. 
-;;; 
+;;; Brief Description:
+;;;
+;;; `dired-do-find-marked-files' is bound to `F' by dired-x.el.
+;;;
 ;;; * Use `dired-get-marked-files' to collect the marked files in the current
-;;;   Dired Buffer into a list of filenames `FILE-LIST'. 
-;;; 
+;;;   Dired Buffer into a list of filenames `FILE-LIST'.
+;;;
 ;;; * Pass FILE-LIST to `dired-simultaneous-find-file' all with
 ;;;   `dired-do-find-marked-files''s prefix argument NOSELECT.
-;;; 
+;;;
 ;;; * `dired-simultaneous-find-file' runs through FILE-LIST decrementing the
 ;;;   list each time.
-;;; 
+;;;
 ;;; * If NOSELECT is non-nil then just run `find-file-noselect'  on each
 ;;;   element of FILE-LIST.
-;;;  
+;;;
 ;;; * If NOSELECT is nil then calculate the `size' of the window for each file
 ;;;   by dividing the `window-height' by length of FILE-LIST.  Thus, `size' is
 ;;;   cognizant of the window-configuration.
-;;; 
+;;;
 ;;; * If `size' is too small abort, otherwise run `find-file' on each element
 ;;;   of FILE-LIST giving each a window of height `size'.
 
@@ -1200,7 +1230,7 @@ Remaining lines go to bottom-most window.  The number of files that can be
 displayed this way is restricted by the height of the current window and
 `window-min-height'.
 
-To keep dired buffer displayed, type \\[split-window-vertically] first.  
+To keep dired buffer displayed, type \\[split-window-vertically] first.
 To display just marked files, type \\[delete-other-windows] first."
 
   (interactive "P")
@@ -1214,7 +1244,7 @@ To display just marked files, type \\[delete-other-windows] first."
   ;; files that can be displayed this way is restricted by the height of the
   ;; current window and the variable `window-min-height'.  With non-nil
   ;; NOSELECT the files are merely found but not selected.
-  
+
   ;; We don't make this function interactive because it is usually too clumsy
   ;; to specify FILE-LIST interactively unless via dired.
 
@@ -1250,26 +1280,16 @@ To display just marked files, type \\[delete-other-windows] first."
 \f
 ;;;; MISCELLANEOUS COMMANDS.
 
-;;; Run man on files. 
+;;; Run man on files.
+
 (defun dired-man ()
-  "Run man on this file."
+  "Run man on this file.  Display old buffer if buffer name matches filename.
+Uses ../lisp/man.el of \\[manual-entry] fame."
   (interactive)
-  (let* ((file (dired-get-filename))
-         (man-buffer (generate-new-buffer
-                      (format "*man %s*" (file-name-nondirectory file)))))
-    (save-excursion
-      (set-buffer man-buffer)
-      (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))
-      (set-buffer-modified-p nil))
-    (display-buffer man-buffer 'not-this-window))
-  (message "Expanding manual page...cleaning...done"))
+  (require 'man)
+  (let ((file (dired-get-filename))
+        (manual-program "nroff -man -h"))
+    (Man-getpage-in-background file)))
 
 ;;; Run Info on files.
 
@@ -1280,6 +1300,10 @@ To display just marked files, type \\[delete-other-windows] first."
 
 ;;; Run mail on mail folders.
 
+;;; (and (not (fboundp 'vm-visit-folder))
+;;;      (defun vm-visit-folder (file &optional arg)
+;;;        nil))
+
 (defun dired-vm (&optional read-only)
   "Run VM on this file.
 With prefix arg, visit folder read-only (this requires at least VM 5).
@@ -1316,21 +1340,24 @@ See also variable `dired-vm-read-only-folders'."
     (fset 'dired-old-find-buffer-nocreate
           (symbol-function 'dired-find-buffer-nocreate)))
 
-;;; REDEFINE. 
+;;; 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)
@@ -1370,7 +1397,7 @@ See also variable `dired-vm-read-only-folders'."
 ;;;           (setq dired-buffers (delq elt dired-buffers)))))
 ;;;     result))
 
-;;; REDEFINE. 
+;;; REDEFINE.
 ;;; Redefines dired.el's version of `dired-initial-position'
 (defun dired-initial-position (dirname)
   (end-of-line)
@@ -1471,31 +1498,78 @@ to mark all zero length files."
 
 \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.
+(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
   ;; preference for looking backward when not directly on a symbol.  Not
   ;; perfect - point must be in middle of or end of filename.
 
-  (let ((filename-chars ".a-zA-Z0-9---_/:$")
+  (let ((filename-chars ".a-zA-Z0-9---_/:$+")
         (bol (save-excursion (beginning-of-line) (point)))
         (eol (save-excursion (end-of-line) (point)))
         start end filename)
@@ -1508,7 +1582,7 @@ test if that file exists.  Use minibuffer after snatching the filename."
                 (skip-chars-backward " \n\t\r({[]})")
                 (if (not (bobp))
                     (backward-char 1)))))
-      
+
       (if (string-match (concat "[" filename-chars "]")
                         (char-to-string (following-char)))
           (progn
@@ -1520,18 +1594,29 @@ test if that file exists.  Use minibuffer after snatching the filename."
 
         (error "No file found around point!"))
 
-      ;; Return string. 
+      ;; 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
 
 ;;; 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.14"
+(defconst dired-x-version "2.37"
   "Revision number of dired-x.el -- dired extra for GNU Emacs v19.
-Type M-x dired-x-submit-report to send a bug report.  Available via anonymous
+Type \\[dired-x-submit-report] to send a bug report.  Available via anonymous
 ftp in
 
    /roebling.poly.edu:/pub/packages/dired-x.tar.gz")
@@ -1546,7 +1631,7 @@ ftp in
   "Name of file containing emacs lisp code.")
 
 (defconst dired-x-variable-list
-  (list 
+  (list
    'dired-bind-vm
    'dired-vm-read-only-folders
    'dired-bind-jump
@@ -1586,7 +1671,7 @@ listing variables `dired-x-variable-list' in the message."
          (concat dired-x-maintainer ",")))              ; salutation
 
     ;; ...fail gracefully.
-    (error 
+    (error
      (beep)
      (message "Sorry, reporter.el not found."))))