From 61677ac3e4685d8f81c3b90eb751d9b5e8a3732d Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sun, 8 Aug 2021 16:45:50 +0200 Subject: [PATCH] Un-obsolete dired-in-this-tree-p and use it again in certain places. This reverts parts of b425966b07, and 7b50ed553f, i.e. it reverts the obsoletion of dired-in-this-tree-p and switches some new callers of file-in-directory-p back to using dired-in-this-tree-p. It turned out that using file-in-directory-p can be a major performance regression in case you have a dired buffer of a remote directory which has become (almost) inaccessible. Any attempt to open a new dired buffer is checking if a buffer for that directory already exists (in terms of dired-buffers-for-dir) which meant that file-in-directory-p was called with the directory of any existing dired buffer including the inaccessible one where the file-truename call in file-in-directory-p could block for seconds or even minutes. * lisp/dired.el (dired-in-this-tree-p): Undo obsoletion. (dired-buffers-for-dir): Use dired-in-this-tree-p as before. * lisp/dired-aux.el (dired-kill-tree,dired-tree-down): Une dired-in-this-tree-p as before. --- lisp/dired-aux.el | 4 ++-- lisp/dired.el | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 72969dd96e2..5dbd55849e9 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2769,7 +2769,7 @@ of marked files. If KILL-ROOT is non-nil, kill DIRNAME as well." (setq dir (car (car s-alist)) s-alist (cdr s-alist)) (and (or kill-root (not (string-equal dir dirname))) - (file-in-directory-p dir dirname) + (dired-in-this-tree-p dir dirname) (dired-goto-subdir dir) (setq m-alist (nconc (dired-kill-subdir remember-marks) m-alist)))) m-alist)) @@ -3002,7 +3002,7 @@ Lower levels are unaffected." (while rest (setq elt (car rest) rest (cdr rest)) - (if (file-in-directory-p (directory-file-name (car elt)) dir) + (if (dired-in-this-tree-p (directory-file-name (car elt)) dir) (setq rest nil pos (dired-goto-subdir (car elt)))))) (if pos diff --git a/lisp/dired.el b/lisp/dired.el index e577df510ad..816b8b69881 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2872,7 +2872,7 @@ dired-buffers." ((null (buffer-name buf)) ;; Buffer is killed - clean up: (setq dired-buffers (delq elt dired-buffers))) - ((file-in-directory-p (car elt) dir) + ((dired-in-this-tree-p (car elt) dir) (with-current-buffer buf (when (and (or subdirs (assoc dir dired-subdir-alist)) @@ -2947,7 +2947,7 @@ dired-buffers." ;;"Is FILE part of the directory tree starting at DIR?" (let (case-fold-search) (string-match-p (concat "^" (regexp-quote dir)) file))) -(make-obsolete 'dired-in-this-tree-p 'file-in-directory-p "28.1") + (define-obsolete-function-alias 'dired-in-this-tree 'dired-in-this-tree-p "27.1") -- 2.39.5