aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Hansen2004-06-05 17:53:03 +0000
committerLars Hansen2004-06-05 17:53:03 +0000
commitce64e046c82d058b61bc54b94eca8c463dfddb36 (patch)
tree74d1f05d2447c7ad59a5ffd8a36967f6c1b7c1d0
parentddfb836996d125b2595c93a364c06ef52b63560e (diff)
downloademacs-ce64e046c82d058b61bc54b94eca8c463dfddb36.tar.gz
emacs-ce64e046c82d058b61bc54b94eca8c463dfddb36.zip
(dired-omit-mode): Rename from dired-omit-files-p. Use define-minor-mode to define it.
(dired-omit-files-p): Add as alias for dired-omit-mode. (dired-omit-toggle): Delete. Replaced by dired-omit-mode and dired-mark-omitted. (dired-mark-omitted): Add. Bind to M-O.
-rw-r--r--lisp/dired-x.el82
1 files changed, 39 insertions, 43 deletions
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 21fe4902e58..caef06a64fb 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -50,7 +50,7 @@
50;; (add-hook 'dired-mode-hook 50;; (add-hook 'dired-mode-hook
51;; (function (lambda () 51;; (function (lambda ()
52;; ;; Set buffer-local variables here. For example: 52;; ;; Set buffer-local variables here. For example:
53;; ;; (setq dired-omit-files-p t) 53;; ;; (dired-omit-mode 1)
54;; ))) 54;; )))
55;; 55;;
56;; At load time dired-x.el will install itself, redefine some functions, and 56;; At load time dired-x.el will install itself, redefine some functions, and
@@ -74,7 +74,7 @@
74;; dired-guess-shell-znew-switches 74;; dired-guess-shell-znew-switches
75;; dired-guess-shell-alist-user 75;; dired-guess-shell-alist-user
76;; dired-clean-up-buffers-too 76;; dired-clean-up-buffers-too
77;; dired-omit-files-p 77;; dired-omit-mode
78;; dired-omit-files 78;; dired-omit-files
79;; dired-omit-extensions 79;; dired-omit-extensions
80;; dired-omit-size-limit 80;; dired-omit-size-limit
@@ -154,19 +154,27 @@ Read-only folders only work in VM 5, not in VM 4."
154 (other :tag "non-writable only" if-file-read-only)) 154 (other :tag "non-writable only" if-file-read-only))
155 :group 'dired-x) 155 :group 'dired-x)
156 156
157(defcustom dired-omit-files-p nil 157(define-minor-mode dired-omit-mode
158 "*If non-nil, \"uninteresting\" files are not listed (buffer-local). 158 "Toggle Dired-Omit mode.
159Use \\[dired-omit-toggle] to toggle its value. 159With numeric ARG, enable Dired-Omit mode if ARG is positive, disable
160otherwise. Enabling and disabling is buffer-local.
161If enabled, \"uninteresting\" files are not listed.
160Uninteresting files are those whose filenames match regexp `dired-omit-files', 162Uninteresting files are those whose filenames match regexp `dired-omit-files',
161plus those ending with extensions in `dired-omit-extensions'." 163plus those ending with extensions in `dired-omit-extensions'."
162 :type 'boolean 164 :group 'dired-x
163 :group 'dired-x) 165 (if dired-omit-mode
164(make-variable-buffer-local 'dired-omit-files-p) 166 ;; This will mention how many lines were omitted:
167 (let ((dired-omit-size-limit nil)) (dired-omit-expunge))
168 (revert-buffer)))
169
170;; For backward compatibility
171(defvaralias 'dired-omit-files-p 'dired-omit-mode)
172(make-obsolete-variable 'dired-omit-files-p 'dired-omit-mode)
165 173
166(defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$" 174(defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$"
167 "*Filenames matching this regexp will not be displayed. 175 "*Filenames matching this regexp will not be displayed.
168This only has effect when `dired-omit-files-p' is t. See interactive function 176This only has effect when `dired-omit-mode' is t. See interactive function
169`dired-omit-toggle' \(\\[dired-omit-toggle]\) and variable 177`dired-omit-mode' \(\\[dired-omit-mode]\) and variable
170`dired-omit-extensions'. The default is to omit `.', `..', auto-save 178`dired-omit-extensions'. The default is to omit `.', `..', auto-save
171files and lock files." 179files and lock files."
172 :type 'regexp 180 :type 'regexp
@@ -230,7 +238,8 @@ to nil: a pipe using `zcat' or `gunzip -c' will be used."
230 238
231;;; KEY BINDINGS. 239;;; KEY BINDINGS.
232 240
233(define-key dired-mode-map "\M-o" 'dired-omit-toggle) 241(define-key dired-mode-map "\M-o" 'dired-omit-mode)
242(define-key dired-mode-map "\M-O" 'dired-mark-omitted)
234(define-key dired-mode-map "\M-(" 'dired-mark-sexp) 243(define-key dired-mode-map "\M-(" 'dired-mark-sexp)
235(define-key dired-mode-map "*(" 'dired-mark-sexp) 244(define-key dired-mode-map "*(" 'dired-mark-sexp)
236(define-key dired-mode-map "*." 'dired-mark-extension) 245(define-key dired-mode-map "*." 'dired-mark-extension)
@@ -268,7 +277,7 @@ to nil: a pipe using `zcat' or `gunzip -c' will be used."
268 \\[dired-info]\t-- run info on file 277 \\[dired-info]\t-- run info on file
269 \\[dired-man]\t-- run man on file 278 \\[dired-man]\t-- run man on file
270 \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously 279 \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously
271 \\[dired-omit-toggle]\t-- toggle omitting of files 280 \\[dired-omit-mode]\t-- toggle omitting of files
272 \\[dired-mark-sexp]\t-- mark by Lisp expression 281 \\[dired-mark-sexp]\t-- mark by Lisp expression
273 \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names into the kill ring. 282 \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names into the kill ring.
274 \t You can feed it to other commands using \\[yank]. 283 \t You can feed it to other commands using \\[yank].
@@ -280,7 +289,7 @@ For more features, see variables
280 `dired-bind-info' 289 `dired-bind-info'
281 `dired-bind-man' 290 `dired-bind-man'
282 `dired-vm-read-only-folders' 291 `dired-vm-read-only-folders'
283 `dired-omit-files-p' 292 `dired-omit-mode'
284 `dired-omit-files' 293 `dired-omit-files'
285 `dired-omit-extensions' 294 `dired-omit-extensions'
286 `dired-omit-size-limit' 295 `dired-omit-size-limit'
@@ -450,9 +459,9 @@ buffer and try again."
450 (dired-insert-subdir (file-name-directory file)) 459 (dired-insert-subdir (file-name-directory file))
451 (dired-goto-file file)) 460 (dired-goto-file file))
452 ;; Toggle omitting, if it is on, and try again. 461 ;; Toggle omitting, if it is on, and try again.
453 (if dired-omit-files-p 462 (if dired-omit-mode
454 (progn 463 (progn
455 (dired-omit-toggle) 464 (dired-omit-mode)
456 (dired-goto-file file)))))))) 465 (dired-goto-file file))))))))
457 466
458(defun dired-jump-other-window () 467(defun dired-jump-other-window ()
@@ -479,31 +488,18 @@ need to match the entire file name.")
479Should never be used as marker by the user or other packages.") 488Should never be used as marker by the user or other packages.")
480 489
481(defun dired-omit-startup () 490(defun dired-omit-startup ()
482 (or (assq 'dired-omit-files-p minor-mode-alist) 491 (or (assq 'dired-omit-mode minor-mode-alist)
483 (setq minor-mode-alist 492 (setq minor-mode-alist
484 (append '((dired-omit-files-p 493 (append '((dired-omit-mode
485 (:eval (if (eq major-mode 'dired-mode) 494 (:eval (if (eq major-mode 'dired-mode)
486 " Omit" "")))) 495 " Omit" ""))))
487 minor-mode-alist)))) 496 minor-mode-alist))))
488 497
489(defun dired-omit-toggle (&optional flag) 498(defun dired-mark-omitted ()
490 "Toggle omitting files matching `dired-omit-files' and `dired-omit-extensions'. 499 "Mark files matching `dired-omit-files' and `dired-omit-extensions'."
491With an arg, and if omitting was off, don't toggle and just mark the 500 (interactive)
492 files but don't actually omit them. 501 (let ((dired-omit-mode nil)) (revert-buffer)) ;; Show omitted files
493With an arg, and if omitting was on, turn it off but don't refresh the buffer." 502 (dired-mark-unmarked-files (dired-omit-regexp) nil nil dired-omit-localp))
494 (interactive "P")
495 (if flag
496 (if dired-omit-files-p
497 (setq dired-omit-files-p (not dired-omit-files-p))
498 (dired-mark-unmarked-files (dired-omit-regexp) nil nil
499 dired-omit-localp))
500 ;; no FLAG
501 (setq dired-omit-files-p (not dired-omit-files-p))
502 (if (not dired-omit-files-p)
503 (revert-buffer)
504 ;; this will mention how many were omitted:
505 (let ((dired-omit-size-limit nil))
506 (dired-omit-expunge)))))
507 503
508(defvar dired-omit-extensions 504(defvar dired-omit-extensions
509 (append completion-ignored-extensions 505 (append completion-ignored-extensions
@@ -515,12 +511,12 @@ Defaults to elements of `completion-ignored-extensions',
515`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and 511`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and
516`dired-texinfo-unclean-extensions'. 512`dired-texinfo-unclean-extensions'.
517 513
518See interactive function `dired-omit-toggle' \(\\[dired-omit-toggle]\) and 514See interactive function `dired-omit-mode' \(\\[dired-omit-mode]\) and
519variables `dired-omit-files-p' and `dired-omit-files'.") 515variables `dired-omit-mode' and `dired-omit-files'.")
520 516
521(defun dired-omit-expunge (&optional regexp) 517(defun dired-omit-expunge (&optional regexp)
522 "Erases all unmarked files matching REGEXP. 518 "Erases all unmarked files matching REGEXP.
523Does nothing if global variable `dired-omit-files-p' is nil, or if called 519Does nothing if global variable `dired-omit-mode' is nil, or if called
524 non-interactively and buffer is bigger than `dired-omit-size-limit'. 520 non-interactively and buffer is bigger than `dired-omit-size-limit'.
525If REGEXP is nil or not specified, uses `dired-omit-files', and also omits 521If REGEXP is nil or not specified, uses `dired-omit-files', and also omits
526 filenames ending in `dired-omit-extensions'. 522 filenames ending in `dired-omit-extensions'.
@@ -529,14 +525,14 @@ If REGEXP is the empty string, this function is a no-op.
529This functions works by temporarily binding `dired-marker-char' to 525This functions works by temporarily binding `dired-marker-char' to
530`dired-omit-marker-char' and calling `dired-do-kill-lines'." 526`dired-omit-marker-char' and calling `dired-do-kill-lines'."
531 (interactive "sOmit files (regexp): ") 527 (interactive "sOmit files (regexp): ")
532 (if (and dired-omit-files-p 528 (if (and dired-omit-mode
533 (or (interactive-p) 529 (or (interactive-p)
534 (not dired-omit-size-limit) 530 (not dired-omit-size-limit)
535 (< (buffer-size) dired-omit-size-limit) 531 (< (buffer-size) dired-omit-size-limit)
536 (progn 532 (progn
537 (message "Not omitting: directory larger than %d characters." 533 (message "Not omitting: directory larger than %d characters."
538 dired-omit-size-limit) 534 dired-omit-size-limit)
539 (setq dired-omit-files-p nil) 535 (setq dired-omit-mode nil)
540 nil))) 536 nil)))
541 (let ((omit-re (or regexp (dired-omit-regexp))) 537 (let ((omit-re (or regexp (dired-omit-regexp)))
542 (old-modified-p (buffer-modified-p)) 538 (old-modified-p (buffer-modified-p))
@@ -589,7 +585,7 @@ Second optional argument LOCALP is as in `dired-get-filename'."
589(defun dired-omit-new-add-entry (filename &optional marker-char relative) 585(defun dired-omit-new-add-entry (filename &optional marker-char relative)
590 ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for 586 ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for
591 ;; files that are going to be omitted anyway. 587 ;; files that are going to be omitted anyway.
592 (if dired-omit-files-p 588 (if dired-omit-mode
593 ;; perhaps return t without calling ls 589 ;; perhaps return t without calling ls
594 (let ((omit-re (dired-omit-regexp))) 590 (let ((omit-re (dired-omit-regexp)))
595 (if (or (string= omit-re "") 591 (if (or (string= omit-re "")
@@ -842,7 +838,7 @@ dired."
842 (save-excursion 838 (save-excursion
843 (set-buffer (get-buffer-create " *dot-dired*")) 839 (set-buffer (get-buffer-create " *dot-dired*"))
844 (erase-buffer) 840 (erase-buffer)
845 (insert "Local Variables:\ndired-omit-files-p: t\nEnd:\n") 841 (insert "Local Variables:\ndired-omit-mode: t\nEnd:\n")
846 (write-file dired-local-variables-file) 842 (write-file dired-local-variables-file)
847 (kill-buffer (current-buffer))) 843 (kill-buffer (current-buffer)))
848 844
@@ -1692,7 +1688,7 @@ If `current-prefix-arg' is non-nil, uses name at point as guess."
1692 'dired-guess-shell-znew-switches 1688 'dired-guess-shell-znew-switches
1693 'dired-guess-shell-alist-user 1689 'dired-guess-shell-alist-user
1694 'dired-clean-up-buffers-too 1690 'dired-clean-up-buffers-too
1695 'dired-omit-files-p 1691 'dired-omit-mode
1696 'dired-omit-files 1692 'dired-omit-files
1697 'dired-omit-extensions 1693 'dired-omit-extensions
1698 ) 1694 )