comparison lisp/dired.el @ 30414:a8e324dcc228

(dired-sort-R-check): Added to allow recursive listing to be undone. (dired-sort-other): Use it.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 24 Jul 2000 12:27:26 +0000
parents 28542f84f184
children 78337ade0189
comparison
equal deleted inserted replaced
30413:d5335ebcf501 30414:a8e324dcc228
2630 (defun dired-sort-other (switches &optional no-revert) 2630 (defun dired-sort-other (switches &optional no-revert)
2631 ;; Specify new ls SWITCHES for current dired buffer. Values matching 2631 ;; Specify new ls SWITCHES for current dired buffer. Values matching
2632 ;; `dired-sort-by-date-regexp' or `dired-sort-by-name-regexp' set the 2632 ;; `dired-sort-by-date-regexp' or `dired-sort-by-name-regexp' set the
2633 ;; minor mode accordingly, others appear literally in the mode line. 2633 ;; minor mode accordingly, others appear literally in the mode line.
2634 ;; With optional second arg NO-REVERT, don't refresh the listing afterwards. 2634 ;; With optional second arg NO-REVERT, don't refresh the listing afterwards.
2635 (dired-sort-R-check switches)
2635 (setq dired-actual-switches switches) 2636 (setq dired-actual-switches switches)
2636 (if (eq major-mode 'dired-mode) (dired-sort-set-modeline)) 2637 (if (eq major-mode 'dired-mode) (dired-sort-set-modeline))
2637 (or no-revert (revert-buffer))) 2638 (or no-revert (revert-buffer)))
2639
2640 (make-variable-buffer-local
2641 (defvar dired-subdir-alist-pre-R nil
2642 "Value of `dired-subdir-alist' before -R switch added."))
2643
2644 (defun dired-sort-R-check (switches)
2645 "Additional processing of -R in ls option string SWITCHES.
2646 Saves `dired-subdir-alist' when R is set and restores saved value
2647 minus any directories explicitly deleted when R is cleared.
2648 To be called first in body of `dired-sort-other', etc."
2649 (cond
2650 ((and (string-match "R" switches)
2651 (not (string-match "R" dired-actual-switches)))
2652 ;; Adding -R to ls switches -- save `dired-subdir-alist':
2653 (setq dired-subdir-alist-pre-R dired-subdir-alist))
2654 ((and (string-match "R" dired-actual-switches)
2655 (not (string-match "R" switches)))
2656 ;; Deleting -R from ls switches -- revert to pre-R subdirs
2657 ;; that are still present:
2658 (setq dired-subdir-alist
2659 (if dired-subdir-alist-pre-R
2660 (let (subdirs)
2661 (while dired-subdir-alist-pre-R
2662 (if (assoc (caar dired-subdir-alist-pre-R)
2663 dired-subdir-alist)
2664 ;; subdir still present...
2665 (setq subdirs
2666 (cons (car dired-subdir-alist-pre-R)
2667 subdirs)))
2668 (setq dired-subdir-alist-pre-R
2669 (cdr dired-subdir-alist-pre-R)))
2670 (reverse subdirs))
2671 ;; No pre-R subdir alist, so revert to main directory
2672 ;; listing:
2673 (list (car (reverse dired-subdir-alist))))))))
2638 2674
2639 ;; To make this file smaller, the less common commands 2675 ;; To make this file smaller, the less common commands
2640 ;; go in a separate file. But autoload them here 2676 ;; go in a separate file. But autoload them here
2641 ;; to make the separation invisible. 2677 ;; to make the separation invisible.
2642 2678