[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: directory names ending with a colon confuse dired
From: |
Richard Stallman |
Subject: |
Re: directory names ending with a colon confuse dired |
Date: |
Fri, 22 Sep 2006 13:01:36 -0400 |
Here's a patch. I've left the indendation as it was to make the patch
shorter, but the function will need reindenting. I removed a seemingly
unneeded call to save-match-data():
The reason for the call to `save-match-data' is so that
(save-excursion
(goto-char (match-beginning 1))
will get what was matched by the previous search.
In fact, I am surprised it works at all once you delete that
call to `save-match-data'.
Does this version of the function work? It contains the rest
of your patch, but without removing the `save-match-data'.
(defun dired-build-subdir-alist (&optional switches)
"Build `dired-subdir-alist' by parsing the buffer.
Returns the new value of the alist.
If optional arg SWITCHES is non-nil, use its value
instead of `dired-actual-switches'."
(interactive)
(dired-clear-alist)
(save-excursion
(let* ((count 0)
(buffer-read-only nil)
(buffer-undo-list t)
(switches (or switches dired-actual-switches))
new-dir-name
(R-ftp-base-dir-regex
;; Used to expand subdirectory names correctly in recursive
;; ange-ftp listings.
(and (string-match "R" switches)
(string-match "\\`/.*:\\(/.*\\)" default-directory)
(concat "\\`" (match-string 1 default-directory)))))
(goto-char (point-min))
(setq dired-subdir-alist nil)
(while (re-search-forward dired-subdir-regexp nil t)
;; Avoid taking a file name ending in a colon
;; as a subdir name.
(unless (save-excursion
(goto-char (match-beginning 0))
(beginning-of-line)
(forward-char 2)
(save-match-data (looking-at dired-re-perms)))
(save-excursion
(goto-char (match-beginning 1))
(setq new-dir-name
(buffer-substring-no-properties (point) (match-end 1))
new-dir-name
(save-match-data
(if (and R-ftp-base-dir-regex
(not (string= new-dir-name default-directory))
(string-match R-ftp-base-dir-regex new-dir-name))
(concat default-directory
(substring new-dir-name (match-end 0)))
(expand-file-name new-dir-name))))
(delete-region (point) (match-end 1))
(insert new-dir-name))))
(setq count (1+ count))
(dired-alist-add-1 new-dir-name
;; Place a sub directory boundary between lines.
(save-excursion
(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-subdir-alist))
- directory names ending with a colon confuse dired, Chris Moore, 2006/09/21
- Re: directory names ending with a colon confuse dired, Chris Moore, 2006/09/21
- Re: directory names ending with a colon confuse dired, Chris Moore, 2006/09/21
- Re: directory names ending with a colon confuse dired, Chris Moore, 2006/09/21
- Re: directory names ending with a colon confuse dired,
Richard Stallman <=
- Re: directory names ending with a colon confuse dired, Chris Moore, 2006/09/22
- Re: directory names ending with a colon confuse dired, Johan Bockgård, 2006/09/23
- Re: directory names ending with a colon confuse dired, Richard Stallman, 2006/09/23
- Re: directory names ending with a colon confuse dired, Chris Moore, 2006/09/25