Add 2010 to copyright years.
[bpt/emacs.git] / lisp / dired-x.el
index a23b901..f919840 100644 (file)
@@ -1,7 +1,7 @@
-;;; dired-x.el --- extra Dired functionality -*-byte-compile-dynamic: t;-*-
+;;; dired-x.el --- extra Dired functionality
 
-;; Copyright (C) 1993, 1994, 1997, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1997, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
 ;;     Lawrence R. Dodd <dodd@roebling.poly.edu>
   :group 'dired-x)
 
 (defcustom dired-bind-vm nil
-  "*Non-nil means \"V\" runs `dired-vm', otherwise \"V\" runs `dired-rmail'.
-Also, RMAIL files contain -*- rmail -*- at the top so \"f\",
-`dired-advertised-find-file', will run rmail."
+  "Non-nil means \"V\" runs `dired-vm', otherwise \"V\" runs `dired-rmail'.
+
+RMAIL files in the old Babyl format (used before before Emacs 23.1)
+contain \"-*- rmail -*-\" at the top, so `dired-find-file'
+will run `rmail' on these files.  New RMAIL files use the standard
+mbox format, and so cannot be distinguished in this way."
   :type 'boolean
   :group 'dired-keys)
 
 (defcustom dired-bind-jump t
-  "*Non-nil means bind `dired-jump' to C-x C-j, otherwise do not."
+  "Non-nil means bind `dired-jump' to C-x C-j, otherwise do not."
   :type 'boolean
   :group 'dired-keys)
 
 (defcustom dired-bind-man t
-  "*Non-nil means bind `dired-man' to \"N\" in dired-mode, otherwise do not."
+  "Non-nil means bind `dired-man' to \"N\" in dired-mode, otherwise do not."
   :type 'boolean
   :group 'dired-keys)
 
 (defcustom dired-bind-info t
-  "*Non-nil means bind `dired-info' to \"I\" in dired-mode, otherwise do not."
+  "Non-nil means bind `dired-info' to \"I\" in dired-mode, otherwise do not."
   :type 'boolean
   :group 'dired-keys)
 
 (defcustom dired-vm-read-only-folders nil
-  "*If non-nil, \\[dired-vm] will visit all folders read-only.
+  "If non-nil, \\[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.
 
@@ -171,7 +174,7 @@ plus those ending with extensions in `dired-omit-extensions'."
 (define-obsolete-variable-alias 'dired-omit-files-p 'dired-omit-mode "22.1")
 
 (defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$"
-  "*Filenames matching this regexp will not be displayed.
+  "Filenames matching this regexp will not be displayed.
 This only has effect when `dired-omit-mode' is t.  See interactive function
 `dired-omit-mode' \(\\[dired-omit-mode]\) and variable
 `dired-omit-extensions'.  The default is to omit  `.', `..', auto-save
@@ -180,7 +183,7 @@ files and lock files."
   :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 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.
 
@@ -194,26 +197,26 @@ toggle between those two."
   :group 'dired-x)
 
 (defcustom dired-omit-size-limit 30000
-  "*Maximum size for the \"omitting\" feature.
+  "Maximum size for the \"omitting\" feature.
 If nil, there is no maximum size."
   :type '(choice (const :tag "no maximum" nil) integer)
   :group 'dired-x)
 
 (defcustom dired-enable-local-variables t
-  "*Control use of local-variables lists in Dired.
+  "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'."
+This temporarily overrides the value of `enable-local-variables' when
+listing a directory.  See also `dired-local-variables-file'."
   :type 'boolean
   :group 'dired-x)
 
 (defcustom dired-guess-shell-gnutar (when (or (eq system-type 'gnu)
                                              (eq system-type 'gnu/linux))
                                      "tar")
-  "*If non-nil, name of GNU tar executable.
+  "If non-nil, name of GNU tar executable.
 \(E.g., \"tar\" or \"gtar\").  The `z' switch will be used with it for
 compressed or gzip'ed tar files.  If you don't have GNU tar, set this
 to nil: a pipe using `zcat' or `gunzip -c' will be used."
@@ -222,18 +225,18 @@ to nil: a pipe using `zcat' or `gunzip -c' will be used."
   :group 'dired-x)
 
 (defcustom dired-guess-shell-gzip-quiet t
-  "*Non-nil says pass -q to gzip overriding verbose GZIP environment."
+  "Non-nil says pass -q to gzip overriding verbose GZIP environment."
   :type 'boolean
   :group 'dired-x)
 
 (defcustom dired-guess-shell-znew-switches nil
-  "*If non-nil, then string of switches passed to `znew', example: \"-K\"."
+  "If non-nil, then string of switches passed to `znew', example: \"-K\"."
   :type '(choice (const :tag "None" nil)
                 (string :tag "Switches"))
   :group 'dired-x)
 
 (defcustom dired-clean-up-buffers-too t
-  "*Non-nil means offer to kill buffers visiting files and dirs deleted in Dired."
+  "Non-nil means offer to kill buffers visiting files and dirs deleted in Dired."
   :type 'boolean
   :group 'dired-x)
 
@@ -550,7 +553,7 @@ need to match the entire file name.")
 
 ;; \017=^O for Omit - other packages can chose other control characters.
 (defvar dired-omit-marker-char ?\017
-  "Temporary marker used by dired-omit.
+  "Temporary marker used by Dired-Omit.
 Should never be used as marker by the user or other packages.")
 
 (defun dired-omit-startup ()
@@ -592,7 +595,7 @@ 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 (and dired-omit-mode
-           (or (interactive-p)
+           (or (called-interactively-p 'interactive)
                (not dired-omit-size-limit)
                (< (buffer-size) dired-omit-size-limit)
               (progn
@@ -840,14 +843,10 @@ Knows about the special cases in variable `default-directory-alist'."
   "Like function `shell-command', but in the current Virtual Dired directory."
   (interactive
    (list
-    (minibuffer-with-setup-hook
-       (lambda ()
-         (set (make-local-variable 'minibuffer-default-add-function)
-              'minibuffer-default-add-shell-commands))
-      (read-shell-command "Shell command: " nil nil
-                         (cond
-                          (buffer-file-name (file-relative-name buffer-file-name))
-                          ((eq major-mode 'dired-mode) (dired-get-filename t t)))))
+    (read-shell-command "Shell command: " nil nil
+                       (cond
+                        (buffer-file-name (file-relative-name buffer-file-name))
+                        ((eq major-mode 'dired-mode) (dired-get-filename t t))))
     current-prefix-arg
     shell-command-default-error-buffer))
   (let ((default-directory (dired-default-directory)))
@@ -1018,6 +1017,16 @@ dired."
         ;; Optional decompression.
         "bunzip2")
 
+   ;; xz'ed archives
+   (list "\\.t\\(ar\\.\\)?xz$"
+        "unxz -c * | tar xvf -"
+        ;; Extract files into a separate subdirectory
+        '(concat "mkdir " (file-name-sans-extension file)
+                 "; unxz -c * | tar -C "
+                 (file-name-sans-extension file) " -xvf -")
+        ;; Optional decompression.
+        "unxz")
+
    '("\\.shar\\.Z$" "zcat * | unshar")
    '("\\.shar\\.g?z$" "gunzip -qc * | unshar")
 
@@ -1062,6 +1071,8 @@ dired."
    '("\\.dvi$" "xdvi" "dvips")         ; preview and printing
    '("\\.au$" "play")                  ; play Sun audiofiles
    '("\\.mpe?g$\\|\\.avi$" "xine -p")
+   '("\\.ogg$" "ogg123")
+   '("\\.mp3$" "mpg123")
    '("\\.wav$" "play")
    '("\\.uu$" "uudecode")              ; for uudecoded files
    '("\\.hqx$" "mcvert")
@@ -1097,6 +1108,7 @@ dired."
    (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
    (list "\\.dz$" "dictunzip")
    (list "\\.bz2$" "bunzip2")
+   (list "\\.xz$" "unxz")
    (list "\\.Z$" "uncompress"
         ;; Optional conversion to gzip format.
         '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
@@ -1121,13 +1133,16 @@ to a string.  If several COMMANDs are given, the first one will be the default
 and the rest will be added temporarily to the history and can be retrieved
 with \\[previous-history-element] (M-p) .
 
+The variable `dired-guess-shell-case-fold-search' controls whether
+REGEXP is matched case-sensitively.
+
 You can set this variable in your ~/.emacs.  For example, to add rules for
 `.foo' and `.bar' files, write
 
  \(setq dired-guess-shell-alist-user
        (list (list \"\\\\.foo\\\\'\" \"FOO-COMMAND\");; fixed rule
               ;; possibly more rules ...
-              (list \"\\\\.bar\\\'\";; rule with condition test
+              (list \"\\\\.bar\\\\'\";; rule with condition test
                     '(if condition
                           \"BAR-COMMAND-1\"
                         \"BAR-COMMAND-2\")))\)"
@@ -1183,7 +1198,7 @@ See `dired-guess-shell-alist-user'."
         default-list val)
     (if (null default)
         ;; Nothing to guess
-        (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history)
+        (read-shell-command prompt nil 'dired-shell-command-history)
       (if (listp default)
           ;; More than one guess
           (setq default-list default
@@ -1196,24 +1211,28 @@ See `dired-guess-shell-alist-user'."
       ;; Put the first guess in the prompt but not in the initial value.
       (setq prompt (concat prompt (format "[%s] " default)))
       ;; All guesses can be retrieved with M-n
-      (setq val (read-from-minibuffer prompt nil nil nil
-                                      'dired-shell-command-history
-                                      default-list))
+      (setq val (read-shell-command prompt nil
+                                    'dired-shell-command-history
+                                    default-list))
       ;; If we got a return, then return default.
       (if (equal val "") default val))))
 
 ;; 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).
+  "Read a dired shell command prompting with PROMPT (using `read-shell-command').
 ARG is the prefix arg and may be used to indicate in the prompt which
-  files are affected.
+FILES are affected.
 This is an extra function so that you can redefine it."
-  (dired-mark-pop-up
-   nil 'shell files
-   'dired-guess-shell-command
-   (format prompt (dired-mark-prompt arg files)) ; PROMPT
-   files))                                       ; FILES
+  (minibuffer-with-setup-hook
+      (lambda ()
+        (set (make-local-variable 'minibuffer-default-add-function)
+             'minibuffer-default-add-dired-shell-commands))
+    (dired-mark-pop-up
+     nil 'shell files
+     'dired-guess-shell-command
+     (format prompt (dired-mark-prompt arg files)) ; PROMPT
+     files)))                                      ; FILES
 
 \f
 ;;; RELATIVE SYMBOLIC LINKS.
@@ -1317,7 +1336,7 @@ for more info."
 ;; * `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
+;; * 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
@@ -1632,7 +1651,7 @@ 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 is part of `after-init-hook'."
   (interactive)
-  (if (interactive-p)
+  (if (called-interactively-p 'interactive)
       (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)
@@ -1674,8 +1693,8 @@ or to test if that file exists.  Use minibuffer after snatching filename."
 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.
+Identical to `find-file-other-window' except when called interactively, with
+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: ")))
@@ -1686,8 +1705,8 @@ or to test if that file exists.  Use minibuffer after snatching filename."
 ;; Fixme: This should probably use `thing-at-point'.  -- fx
 (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."
+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 "-.[:alnum:]_/:$+@")
         start end filename prefix)
@@ -1767,7 +1786,7 @@ If `current-prefix-arg' is non-nil, uses name at point as guess."
 
 (defun dired-x-submit-report ()
   "Submit via `reporter.el' a bug report on program.
-Send report on `dired-x-file' version `dired-x-version,' to
+Send report on `dired-x-file' version `dired-x-version', to
 `dired-x-maintainer' at address `dired-x-help-address' listing
 variables `dired-x-variable-list' in the message."
   (interactive)
@@ -1783,5 +1802,10 @@ variables `dired-x-variable-list' in the message."
 ;; As Barry Warsaw would say: "This might be useful..."
 (provide 'dired-x)
 
+;; Local Variables:
+;; byte-compile-dynamic: t
+;; generated-autoload-file: "dired.el"
+;; End:
+
 ;; arch-tag: 71a43ba2-7a00-4793-a028-0613dd7765ae
 ;;; dired-x.el ends here