From a77b655d874ebe7c40fe244d91e1e607e4fcfb25 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 22 May 2008 03:09:34 +0000 Subject: [PATCH] (locate-dominating-file): Accept non-existing argument. (project-find-settings-file): Rewrite, using locate-dominating-file. --- lisp/ChangeLog | 13 ++++++++----- lisp/files.el | 31 +++++++++++++++++-------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 00e503e2ad4..213cfd9b98a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,15 +1,18 @@ +2008-05-22 Stefan Monnier + + * files.el (locate-dominating-file): Accept non-existing argument. + (project-find-settings-file): Rewrite, using locate-dominating-file. + 2008-05-22 Kenichi Handa - * faces.el (font-weight-table, font-slant-table) - (font-width-table): Delete them. Don't call - internal-set-font-style-table. + * faces.el (font-weight-table, font-slant-table, font-width-table): + Delete them. Don't call internal-set-font-style-table. * international/mule-diag.el (font-show-log): New function. * international/fontset.el (script-representative-chars): Add more chars for latin. Add data for symbol. - (setup-default-fontset): Add entries for phonetic, armenian, and - symbol. + (setup-default-fontset): Add entries for phonetic, armenian, and symbol. 2008-05-21 Stefan Monnier diff --git a/lisp/files.el b/lisp/files.el index 2a00f1edb35..9802f903eeb 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -746,7 +746,8 @@ PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)." (let ((prev-user user)) (setq user (nth 2 (file-attributes file))) (or (null prev-user) (equal user prev-user)))) - (if (setq files (directory-files dir 'full regexp)) + (if (setq files (and (file-directory-p dir) + (directory-files dir 'full regexp))) (throw 'found (car files)) (if (equal dir (setq dir (file-name-directory @@ -3119,19 +3120,21 @@ If a settings file is found, the file name is returned. If the file is in a registered project, a cons from `project-directory-alist' is returned. Otherwise this returns nil." - (let ((dir (file-name-directory file)) - (result nil)) - (while (and (not (string= dir "/")) - (not result)) - (cond - ((setq result (assoc dir project-directory-alist)) - ;; Nothing else. - nil) - ((file-exists-p (expand-file-name ".dir-settings.el" dir)) - (setq result (expand-file-name ".dir-settings.el" dir))) - (t - (setq dir (file-name-directory (directory-file-name dir)))))) - result)) + (setq file (expand-file-name file)) + (let* ((settings (locate-dominating-file file "\\`\\.dir-settings\\.el\\'")) + (pda nil)) + ;; `locate-dominating-file' may have abbreviated the name. + (if settings (setq settings (expand-file-name settings))) + (dolist (x project-directory-alist) + (when (and (eq t (compare-strings file nil (length (car x)) + (car x) nil nil)) + (> (length (car x)) (length (car pda)))) + (setq pda x))) + (if (and settings pda) + (if (> (length (file-name-directory settings)) + (length (car pda))) + settings pda) + (or settings pda)))) (defun project-define-from-project-file (settings-file) "Load a settings file and register a new project class and instance. -- 2.39.2