;;; dired-x.el --- extra Dired functionality
-;; Copyright (C) 1993-1994, 1997, 2001-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 1997, 2001-2012 Free Software Foundation, Inc.
;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
;; Lawrence R. Dodd <dodd@roebling.poly.edu>
:set (lambda (sym val)
(if (set sym val)
(progn
- (define-key global-map "\C-x\C-j" 'dired-jump)
- (define-key global-map "\C-x4\C-j" 'dired-jump-other-window))
- (if (eq 'dired-jump (lookup-key global-map "\C-x\C-j"))
- (define-key global-map "\C-x\C-j" nil))
- (if (eq 'dired-jump-other-window (lookup-key global-map "\C-x4\C-j"))
- (define-key global-map "\C-x4\C-j" nil))))
+ (define-key ctl-x-map "\C-j" 'dired-jump)
+ (define-key ctl-x-4-map "\C-j" 'dired-jump-other-window))
+ (if (eq 'dired-jump (lookup-key ctl-x-map "\C-j"))
+ (define-key ctl-x-map "\C-j" nil))
+ (if (eq 'dired-jump-other-window (lookup-key ctl-x-4-map "\C-j"))
+ (define-key ctl-x-4-map "\C-j" nil))))
:group 'dired-keys)
(defcustom dired-bind-man t
(other :tag "non-writable only" if-file-read-only))
:group 'dired-x)
+(defcustom dired-omit-size-limit 30000
+ "Maximum size for the \"omitting\" feature.
+If nil, there is no maximum size."
+ :type '(choice (const :tag "no maximum" nil) integer)
+ :group 'dired-x)
+
+;; For backward compatibility
+(define-obsolete-variable-alias 'dired-omit-files-p 'dired-omit-mode "22.1")
(define-minor-mode dired-omit-mode
- "Toggle Dired-Omit mode.
-With numeric ARG, enable Dired-Omit mode if ARG is positive, disable
-otherwise. Enabling and disabling is buffer-local.
-If enabled, \"uninteresting\" files are not listed.
-Uninteresting files are those whose filenames match regexp `dired-omit-files',
-plus those ending with extensions in `dired-omit-extensions'.
+ "Toggle omission of uninteresting files in Dired (Dired-Omit mode).
+With a prefix argument ARG, enable Dired-Omit mode if ARG is
+positive, and disable it otherwise. If called from Lisp, enable
+the mode if ARG is omitted or nil.
+
+Dired-Omit mode is a buffer-local minor mode. When enabled in a
+Dired buffer, Dired does not list files whose filenames match
+regexp `dired-omit-files', nor files ending with extensions in
+`dired-omit-extensions'.
-To enable omitting in every Dired buffer, you can put in your ~/.emacs
+To enable omitting in every Dired buffer, you can put this in
+your init file:
- (add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1)))
+ (add-hook 'dired-mode-hook (lambda () (dired-omit-mode)))
See Info node `(dired-x) Omitting Variables' for more information."
:group 'dired-x
(put 'dired-omit-mode 'safe-local-variable 'booleanp)
-;; For backward compatibility
-(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.
This only has effect when `dired-omit-mode' is t. See interactive function
(defcustom dired-omit-verbose t
"When non-nil, show messages when omitting files.
When nil, don't show messages."
+ :version "24.1"
:type 'boolean
:group 'dired-x)
:type 'boolean
:group 'dired-x)
-(defcustom dired-omit-size-limit 30000
- "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.
This temporarily overrides the value of `enable-local-variables' when
;; Returns t if any work was done, nil otherwise.
(defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp)
"Mark unmarked files matching REGEXP, displaying MSG.
-REGEXP is matched against the entire file name.
-Does not re-mark files which already have a mark.
+REGEXP is matched against the entire file name. When called
+interactively, prompt for REGEXP.
With prefix argument, unflag all those files.
Optional fourth argument LOCALP is as in `dired-get-filename'."
- (interactive "P")
+ (interactive
+ (list (dired-read-regexp
+ "Mark unmarked files matching regexp (default all): ")
+ nil current-prefix-arg nil))
(let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
(dired-mark-if
(and
nil))))
-(defun dired-virtual-revert (&optional arg noconfirm)
+(defun dired-virtual-revert (&optional _arg _noconfirm)
(if (not
(y-or-n-p "Cannot revert a Virtual Dired buffer - switch to Real Dired mode? "))
(error "Cannot revert a Virtual Dired buffer")
(hack-local-variables))
;; Delete this stuff: `eobp' is used to find last subdir by dired.el.
(delete-region opoint (point-max)))
- ;; Make sure that the modeline shows the proper information.
- (dired-sort-set-modeline))))
+ ;; Make sure that the mode line shows the proper information.
+ (dired-sort-set-mode-line))))
(make-obsolete 'dired-hack-local-variables
'hack-dir-local-variables-non-file-buffer "24.1")
;; FIXME "man ./" does not work with dired-do-shell-command,
;; because there seems to be no way for us to modify the filename,
;; only the command. Hmph. `dired-man' works though.
- (list "\\.\\(?:[0-9]\\|man\\)\\'" '(let ((loc (Man-support-local-filenames)))
- (cond ((eq loc 'man-db) "man -l")
- ((eq loc 'man) "man ./")
- (t
- "cat * | tbl | nroff -man -h"))))
+ (list "\\.\\(?:[0-9]\\|man\\)\\'"
+ '(let ((loc (Man-support-local-filenames)))
+ (cond ((eq loc 'man-db) "man -l")
+ ((eq loc 'man) "man ./")
+ (t
+ "cat * | tbl | nroff -man -h | col -b"))))
(list "\\.\\(?:[0-9]\\|man\\)\\.g?z\\'"
'(let ((loc (Man-support-local-filenames)))
(cond ((eq loc 'man-db)
"man -l")
((eq loc 'man)
"man ./")
- (t "gunzip -qc * | tbl | nroff -man -h")))
+ (t "gunzip -qc * | tbl | nroff -man -h | col -b")))
;; Optional decompression.
'(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
- (list "\\.[0-9]\\.Z\\'" '(let ((loc (Man-support-local-filenames)))
- (cond ((eq loc 'man-db) "man -l")
- ((eq loc 'man) "man ./")
- (t "zcat * | tbl | nroff -man -h")))
+ (list "\\.[0-9]\\.Z\\'"
+ '(let ((loc (Man-support-local-filenames)))
+ (cond ((eq loc 'man-db) "man -l")
+ ((eq loc 'man) "man ./")
+ (t "zcat * | tbl | nroff -man -h | col -b")))
;; Optional conversion to gzip format.
'(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
" " dired-guess-shell-znew-switches))
`.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
- '(if condition
- \"BAR-COMMAND-1\"
- \"BAR-COMMAND-2\")))\)"
+ '((\"\\\\.foo\\\\'\" \"FOO-COMMAND\")
+ (\"\\\\.bar\\\\'\"
+ (if condition
+ \"BAR-COMMAND-1\"
+ \"BAR-COMMAND-2\"))))"
:group 'dired-x
:type '(alist :key-type regexp :value-type (repeat sexp)))
:type 'boolean)
(defun dired-guess-default (files)
- "Guess a shell commands for FILES. Return command or list of commands.
+ "Return a shell command, or a list of commands, appropriate for FILES.
See `dired-guess-shell-alist-user'."
(let* ((case-fold-search dired-guess-shell-case-fold-search)
;; Return commands or nil if flist is still non-nil.
;; Evaluate the commands in order that any logical testing will be done.
(if (cdr cmds)
- (mapcar #'eval cmds)
- (eval (car cmds))))) ; single command
+ (delete-dups (mapcar #'eval cmds))
+ (eval (car cmds))))) ; single command
(defun dired-guess-shell-command (prompt files)
"Ask user with PROMPT for a shell command, guessing a default from FILES."
(setq count (1+ count)
start (1+ start)))
;; ... and prepend a "../" for each slash found:
- (dotimes (n count)
+ (dotimes (_n count)
(setq name1 (concat "../" name1)))))
(make-symbolic-link
(directory-file-name name1) ; must not link to foo/
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-below] first.
To display just marked files, type \\[delete-other-windows] first."
(interactive "P")
(dired-simultaneous-find-file (dired-get-marked-files) noselect))
(declare-function Man-getpage-in-background "man" (topic))
+(defvar manual-program) ; from man.el
+
(defun dired-man ()
"Run `man' on this file."
;; Used also to say: "Display old buffer if buffer name matches filename."
\f
;; Does anyone use this? - lrd 6/29/93.
;; Apparently people do use it. - lrd 12/22/97.
+
+(with-no-warnings
+ ;; Warnings are suppressed to avoid "global/dynamic var `X' lacks a prefix".
+ ;; This is unbearably ugly, but not more than having global variables
+ ;; named size, time, name or s, however practical it can be while writing
+ ;; `dired-mark-sexp' predicates.
+ (defvar inode)
+ (defvar s)
+ (defvar mode)
+ (defvar nlink)
+ (defvar uid)
+ (defvar gid)
+ (defvar size)
+ (defvar time)
+ (defvar name)
+ (defvar sym))
+
(defun dired-mark-sexp (predicate &optional unflag-p)
"Mark files for which PREDICATE returns non-nil.
-With a prefix arg, unflag those files instead.
+With a prefix arg, unmark or unflag those files instead.
PREDICATE is a lisp expression that can refer to the following symbols:
is loaded then call \\[dired-x-bind-find-file]."
:type 'boolean
:initialize 'custom-initialize-default
- :set (lambda (sym val)
- (set sym val)
+ :set (lambda (symbol value)
+ (set symbol value)
(dired-x-bind-find-file))
:group 'dired-x)