aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReuben Thomas2017-08-23 11:54:34 +0100
committerReuben Thomas2017-08-23 23:52:24 +0100
commitf8466812e2841ef37763a7c751ad753b669dff17 (patch)
tree1e7096a1952b2fa8fb76d516e55fa2109fb31053
parentc71162e0f186a8e50a48629410e17e873ef55938 (diff)
downloademacs-f8466812e2841ef37763a7c751ad753b669dff17.tar.gz
emacs-f8466812e2841ef37763a7c751ad753b669dff17.zip
Remove old commented code and obsolete comments
* lisp/files.el (locate-dominating-files): Remove old commented implementation from 9 years ago. Since the current version appears (at least to me) not just more efficient but clearer than the version removed, also delete a comment in the new version referring to the old version. Remove old commented heuristic code, and explanatory comments.
-rw-r--r--lisp/files.el50
1 files changed, 1 insertions, 49 deletions
diff --git a/lisp/files.el b/lisp/files.el
index be51c200e81..77ebd94836e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -937,38 +937,8 @@ The default regexp prevents fruitless and time-consuming attempts to find
937special files in directories in which filenames are interpreted as hostnames, 937special files in directories in which filenames are interpreted as hostnames,
938or mount points potentially requiring authentication as a different user.") 938or mount points potentially requiring authentication as a different user.")
939 939
940;; (defun locate-dominating-files (file regexp)
941;; "Look up the directory hierarchy from FILE for a file matching REGEXP.
942;; Stop at the first parent where a matching file is found and return the list
943;; of files that that match in this directory."
944;; (catch 'found
945;; ;; `user' is not initialized yet because `file' may not exist, so we may
946;; ;; have to walk up part of the hierarchy before we find the "initial UID".
947;; (let ((user nil)
948;; ;; Abbreviate, so as to stop when we cross ~/.
949;; (dir (abbreviate-file-name (file-name-as-directory file)))
950;; files)
951;; (while (and dir
952;; ;; As a heuristic, we stop looking up the hierarchy of
953;; ;; directories as soon as we find a directory belonging to
954;; ;; another user. This should save us from looking in
955;; ;; things like /net and /afs. This assumes that all the
956;; ;; files inside a project belong to the same user.
957;; (let ((prev-user user))
958;; (setq user (nth 2 (file-attributes dir)))
959;; (or (null prev-user) (equal user prev-user))))
960;; (if (setq files (condition-case nil
961;; (directory-files dir 'full regexp 'nosort)
962;; (error nil)))
963;; (throw 'found files)
964;; (if (equal dir
965;; (setq dir (file-name-directory
966;; (directory-file-name dir))))
967;; (setq dir nil))))
968;; nil)))
969
970(defun locate-dominating-file (file name) 940(defun locate-dominating-file (file name)
971 "Starting from FILE, look up directory hierarchy for directory containing NAME. 941 "Starting at FILE, look up directory hierarchy for directory containing NAME.
972FILE can be a file or a directory. If it's a file, its directory will 942FILE can be a file or a directory. If it's a file, its directory will
973serve as the starting point for searching the hierarchy of directories. 943serve as the starting point for searching the hierarchy of directories.
974Stop at the first parent directory containing a file NAME, 944Stop at the first parent directory containing a file NAME,
@@ -977,31 +947,13 @@ Instead of a string, NAME can also be a predicate taking one argument
977\(a directory) and returning a non-nil value if that directory is the one for 947\(a directory) and returning a non-nil value if that directory is the one for
978which we're looking. The predicate will be called with every file/directory 948which we're looking. The predicate will be called with every file/directory
979the function needs to examine, starting with FILE." 949the function needs to examine, starting with FILE."
980 ;; We used to use the above locate-dominating-files code, but the
981 ;; directory-files call is very costly, so we're much better off doing
982 ;; multiple calls using the code in here.
983 ;;
984 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for 950 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
985 ;; `name' in /home or in /. 951 ;; `name' in /home or in /.
986 (setq file (abbreviate-file-name (expand-file-name file))) 952 (setq file (abbreviate-file-name (expand-file-name file)))
987 (let ((root nil) 953 (let ((root nil)
988 ;; `user' is not initialized outside the loop because
989 ;; `file' may not exist, so we may have to walk up part of the
990 ;; hierarchy before we find the "initial UID". Note: currently unused
991 ;; (user nil)
992 try) 954 try)
993 (while (not (or root 955 (while (not (or root
994 (null file) 956 (null file)
995 ;; FIXME: Disabled this heuristic because it is sometimes
996 ;; inappropriate.
997 ;; As a heuristic, we stop looking up the hierarchy of
998 ;; directories as soon as we find a directory belonging
999 ;; to another user. This should save us from looking in
1000 ;; things like /net and /afs. This assumes that all the
1001 ;; files inside a project belong to the same user.
1002 ;; (let ((prev-user user))
1003 ;; (setq user (nth 2 (file-attributes file)))
1004 ;; (and prev-user (not (equal user prev-user))))
1005 (string-match locate-dominating-stop-dir-regexp file))) 957 (string-match locate-dominating-stop-dir-regexp file)))
1006 (setq try (if (stringp name) 958 (setq try (if (stringp name)
1007 (file-exists-p (expand-file-name name file)) 959 (file-exists-p (expand-file-name name file))