diff options
| author | Richard M. Stallman | 1994-09-16 21:34:27 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-09-16 21:34:27 +0000 |
| commit | 38819778968105baefe0174a23a49a0273fc074d (patch) | |
| tree | e6567b87a95d4203a1b90e737ff899e3451eedaf | |
| parent | 7c70cfd377e681e37bde2f318518e147864a609d (diff) | |
| download | emacs-38819778968105baefe0174a23a49a0273fc074d.tar.gz emacs-38819778968105baefe0174a23a49a0273fc074d.zip | |
(dired-buffers-for-dir): Assume dirs are preexpanded.
(dired-in-this-tree): Likewise.
(dired-advertise, dired-unadvertise): Expand default-directory.
| -rw-r--r-- | lisp/dired.el | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 9f91da107a7..d89bfbb17d6 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -188,6 +188,7 @@ directory name and the cdr is the actual files to list.") | |||
| 188 | (defvar dired-re-perms "-[-r][-w].[-r][-w].[-r][-w].") | 188 | (defvar dired-re-perms "-[-r][-w].[-r][-w].[-r][-w].") |
| 189 | (defvar dired-re-dot "^.* \\.\\.?$") | 189 | (defvar dired-re-dot "^.* \\.\\.?$") |
| 190 | 190 | ||
| 191 | ;; The subdirectory names in this list are expanded. | ||
| 191 | (defvar dired-subdir-alist nil | 192 | (defvar dired-subdir-alist nil |
| 192 | "Association list of subdirectories and their buffer positions. | 193 | "Association list of subdirectories and their buffer positions. |
| 193 | Each subdirectory has an element: (DIRNAME . STARTMARKER). | 194 | Each subdirectory has an element: (DIRNAME . STARTMARKER). |
| @@ -1250,37 +1251,41 @@ Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on | |||
| 1250 | ;; Enlarged by dired-advertise | 1251 | ;; Enlarged by dired-advertise |
| 1251 | ;; Queried by function dired-buffers-for-dir. When this detects a | 1252 | ;; Queried by function dired-buffers-for-dir. When this detects a |
| 1252 | ;; killed buffer, it is removed from this list. | 1253 | ;; killed buffer, it is removed from this list. |
| 1253 | "Alist of directories and their associated dired buffers.") | 1254 | "Alist of expanded directories and their associated dired buffers.") |
| 1254 | 1255 | ||
| 1255 | (defun dired-buffers-for-dir (dir) | 1256 | (defun dired-buffers-for-dir (dir) |
| 1256 | ;; Return a list of buffers that dired DIR (top level or in-situ subdir). | 1257 | ;; Return a list of buffers that dired DIR (top level or in-situ subdir). |
| 1257 | ;; The list is in reverse order of buffer creation, most recent last. | 1258 | ;; The list is in reverse order of buffer creation, most recent last. |
| 1258 | ;; As a side effect, killed dired buffers for DIR are removed from | 1259 | ;; As a side effect, killed dired buffers for DIR are removed from |
| 1259 | ;; dired-buffers. | 1260 | ;; dired-buffers. |
| 1261 | ;; For testing. -MDE 8/21/94 | ||
| 1262 | (if (not (string-equal dir (expand-file-name dir))) | ||
| 1263 | (debug)) | ||
| 1260 | (setq dir (file-name-as-directory dir)) | 1264 | (setq dir (file-name-as-directory dir)) |
| 1261 | (let ((alist dired-buffers) result elt) | 1265 | (let ((alist dired-buffers) result elt buf) |
| 1262 | (while alist | 1266 | (while alist |
| 1263 | (setq elt (car alist)) | 1267 | (setq elt (car alist) |
| 1264 | (if (dired-in-this-tree dir (car elt)) | 1268 | buf (cdr elt)) |
| 1265 | (let ((buf (cdr elt))) | 1269 | (if (buffer-name buf) |
| 1266 | (if (buffer-name buf) | 1270 | (if (dired-in-this-tree dir (car elt)) |
| 1267 | (if (assoc dir (save-excursion | 1271 | (if (assoc dir (save-excursion |
| 1268 | (set-buffer buf) | 1272 | (set-buffer buf) |
| 1269 | dired-subdir-alist)) | 1273 | dired-subdir-alist)) |
| 1270 | (setq result (cons buf result))) | 1274 | (setq result (cons buf result)))) |
| 1271 | ;; else buffer is killed - clean up: | 1275 | ;; else buffer is killed - clean up: |
| 1272 | (setq dired-buffers (delq elt dired-buffers))))) | 1276 | (setq dired-buffers (delq elt dired-buffers))) |
| 1273 | (setq alist (cdr alist))) | 1277 | (setq alist (cdr alist))) |
| 1274 | result)) | 1278 | result)) |
| 1275 | 1279 | ||
| 1276 | (defun dired-advertise () | 1280 | (defun dired-advertise () |
| 1277 | ;;"Advertise in variable `dired-buffers' that we dired `default-directory'." | 1281 | ;;"Advertise in variable `dired-buffers' that we dired `default-directory'." |
| 1278 | ;; With wildcards we actually advertise too much. | 1282 | ;; With wildcards we actually advertise too much. |
| 1279 | (if (memq (current-buffer) (dired-buffers-for-dir default-directory)) | 1283 | (let ((expanded-default (expand-file-name default-directory))) |
| 1280 | t ; we have already advertised ourselves | 1284 | (if (memq (current-buffer) (dired-buffers-for-dir expanded-default)) |
| 1281 | (setq dired-buffers | 1285 | t ; we have already advertised ourselves |
| 1282 | (cons (cons default-directory (current-buffer)) | 1286 | (setq dired-buffers |
| 1283 | dired-buffers)))) | 1287 | (cons (cons expanded-default (current-buffer)) |
| 1288 | dired-buffers))))) | ||
| 1284 | 1289 | ||
| 1285 | (defun dired-unadvertise (dir) | 1290 | (defun dired-unadvertise (dir) |
| 1286 | ;; Remove DIR from the buffer alist in variable dired-buffers. | 1291 | ;; Remove DIR from the buffer alist in variable dired-buffers. |
| @@ -1288,7 +1293,7 @@ Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on | |||
| 1288 | ;; It does not affect buffers in which DIR is a subdir. | 1293 | ;; It does not affect buffers in which DIR is a subdir. |
| 1289 | ;; Removing is also done as a side-effect in dired-buffer-for-dir. | 1294 | ;; Removing is also done as a side-effect in dired-buffer-for-dir. |
| 1290 | (setq dired-buffers | 1295 | (setq dired-buffers |
| 1291 | (delq (assoc dir dired-buffers) dired-buffers))) | 1296 | (delq (assoc (expand-file-name dir) dired-buffers) dired-buffers))) |
| 1292 | 1297 | ||
| 1293 | ;; Tree Dired | 1298 | ;; Tree Dired |
| 1294 | 1299 | ||
| @@ -1296,8 +1301,11 @@ Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on | |||
| 1296 | 1301 | ||
| 1297 | (defun dired-in-this-tree (file dir) | 1302 | (defun dired-in-this-tree (file dir) |
| 1298 | ;;"Is FILE part of the directory tree starting at DIR?" | 1303 | ;;"Is FILE part of the directory tree starting at DIR?" |
| 1304 | ;; For testing. -MDE 8/21/94 | ||
| 1305 | (if (not (string-equal dir (expand-file-name dir))) | ||
| 1306 | (debug)) | ||
| 1299 | (let (case-fold-search) | 1307 | (let (case-fold-search) |
| 1300 | (string-match (concat "^" (regexp-quote (expand-file-name dir))) file))) | 1308 | (string-match (concat "^" (regexp-quote dir)) file))) |
| 1301 | 1309 | ||
| 1302 | (defun dired-normalize-subdir (dir) | 1310 | (defun dired-normalize-subdir (dir) |
| 1303 | ;; Prepend default-directory to DIR if relative path name. | 1311 | ;; Prepend default-directory to DIR if relative path name. |