[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dired.el
From: |
Luc Teirlinck |
Subject: |
dired.el |
Date: |
Wed, 2 Jun 2004 22:43:54 -0500 (CDT) |
My previous patch to dired-aux.el turned out to still require several
changes, for instance to be able to handle the `-R' switch to `ls'.
My patches now require some changes to dired.el as well. If they look
OK, I will install all four patches.
The variable `dired-subdir-switches' allows to get rid of two ugly
alternative functions and bindings for `dired-maybe-insert-subdir' in
locate.el and find-dired.el. It allows to specify different default
switches for the main directory and for inserted subdirectories. It
could potentially be used for user customization as well. But I am
hesitating whether that is true to a sufficient degree to use
defcustom instead of defvar. The patch below uses defvar, but, of
course, it would be trivial to change that.
`dired-switches-alist' already occurred in my previous dired-aux.el
patch. I just had to move it to dired.el.
The change to `dired-insert-old-subdirs' corrects a bug when reverting
buffers containing a subdirectory inserted using the "-R" switch.
The previous version first correctly inserted all subdirectories using
`ls -R' and then went through a lot of work getting things (sometimes)
wrong, by systematically erasing every single subdirectory and
re-inserting it. Subdirectories several levels down could get
inserted, deleted and re-inserted countless times. My patch corrects
this.
In as far as the final change is concerned, it would make
`dired-build-subdir-alist' only print the "Buffer includes %d directories"
message when called interactively. This is yet another auto-revert
noise control issue. I believe the user is only interested in the
info if the function was called interactively. If it was called for
internal reasons by some other command, then I believe that the message
is likely to confuse the user, regardless of the auto-revert issue.
It certainly is confusing when `dired-build-subdir-alist' is indirectly
called by auto-revert.
===File ~/dired-diff========================================
*** dired.el 30 May 2004 15:58:40 -0500 1.286
--- dired.el 02 Jun 2004 16:01:52 -0500
***************
*** 60,65 ****
--- 60,69 ----
:type 'string
:group 'dired)
+ (defvar dired-subdir-switches nil
+ "If non-nil, switches passed to `ls' for inserting subdirectories.
+ If nil, `dired-listing-switches' is used.")
+
; Don't use absolute file names as /bin should be in any PATH and people
; may prefer /usr/local/gnu/bin or whatever. However, chown is
; usually not in PATH.
***************
*** 274,286 ****
(defvar dired-re-perms "[-bcdlps][-r][-w].[-r][-w].[-r][-w].")
(defvar dired-re-dot "^.* \\.\\.?/?$")
! ;; The subdirectory names in this list are expanded.
(defvar dired-subdir-alist nil
"Association list of subdirectories and their buffer positions.
Each subdirectory has an element: (DIRNAME . STARTMARKER).
The order of elements is the reverse of the order in the buffer.
In simple cases, this list contains one element.")
(defvar dired-subdir-regexp "^. \\([^\n\r]+\\)\\(:\\)[\n\r]"
"Regexp matching a maybe hidden subdirectory line in `ls -lR' output.
Subexpression 1 is the subdirectory proper, no trailing colon.
--- 278,294 ----
(defvar dired-re-perms "[-bcdlps][-r][-w].[-r][-w].[-r][-w].")
(defvar dired-re-dot "^.* \\.\\.?/?$")
! ;; The subdirectory names in the next two lists are expanded.
(defvar dired-subdir-alist nil
"Association list of subdirectories and their buffer positions.
Each subdirectory has an element: (DIRNAME . STARTMARKER).
The order of elements is the reverse of the order in the buffer.
In simple cases, this list contains one element.")
+ (defvar dired-switches-alist nil
+ "Keeps track of which switches to use for inserted subdirectories.
+ This is an alist of the form (SUBDIR . SWITCHES).")
+
(defvar dired-subdir-regexp "^. \\([^\n\r]+\\)\\(:\\)[\n\r]"
"Regexp matching a maybe hidden subdirectory line in `ls -lR' output.
Subexpression 1 is the subdirectory proper, no trailing colon.
***************
*** 961,967 ****
(condition-case ()
(progn
(dired-uncache dir)
! (dired-insert-subdir dir))
(error nil))))))
(defun dired-uncache (dir)
--- 969,982 ----
(condition-case ()
(progn
(dired-uncache dir)
! (dired-insert-subdir dir)
! (let ((switches (cdr (assoc-string dir dired-switches-alist))))
! (and switches
! (string-match "R" switches)
! (dolist (cur-ass (copy-sequence old-subdir-alist))
! (when (string-match (concat "\\`" dir) (car cur-ass))
! (setq old-subdir-alist
! (delete cur-ass old-subdir-alist)))))))
(error nil))))))
(defun dired-uncache (dir)
***************
*** 1406,1411 ****
--- 1421,1427 ----
'(dired-font-lock-keywords t nil nil beginning-of-line))
(set (make-local-variable 'desktop-save-buffer)
'dired-desktop-buffer-misc-data)
+ (set (make-local-variable 'dired-switches-alist) nil)
(dired-sort-other dired-actual-switches t)
(run-mode-hooks 'dired-mode-hook)
(when (featurep 'x-dnd)
***************
*** 2073,2079 ****
(goto-char (match-beginning 0))
(beginning-of-line)
(point-marker))))
! (if (> count 1)
(message "Buffer includes %d directories" count))
;; We don't need to sort it because it is in buffer order per
;; constructionem. Return new alist:
--- 2089,2095 ----
(goto-char (match-beginning 0))
(beginning-of-line)
(point-marker))))
! (if (and (> count 1) (interactive-p))
(message "Buffer includes %d directories" count))
;; We don't need to sort it because it is in buffer order per
;; constructionem. Return new alist:
============================================================
- dired.el,
Luc Teirlinck <=
- dired.el, Luc Teirlinck, 2004/06/06
- Re: dired.el, Luc Teirlinck, 2004/06/06
- Re: dired.el, David Kastrup, 2004/06/06
- Re: dired.el, Stefan Monnier, 2004/06/07
- Re: dired.el, Luc Teirlinck, 2004/06/07
- Re: dired.el, Stefan Monnier, 2004/06/09
- Re: dired.el, Luc Teirlinck, 2004/06/09
Re: dired.el, Richard Stallman, 2004/06/07