From cb3f3cde405e53015f380f7025ec55aee72cd9f0 Mon Sep 17 00:00:00 2001 From: Katsumi Yamaoka Date: Tue, 16 Dec 2003 09:54:15 +0000 Subject: [PATCH] (nnheader-find-etc-directory): Find the newest one. --- lisp/ChangeLog | 4 ++++ lisp/nnheader.el | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a96e6c954..42ae13474 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2003-12-16 Katsumi Yamaoka + + * nnheader.el (nnheader-find-etc-directory): Find the newest one. + 2003-12-16 Simon Josefsson * sha1-el.el (autoload): Don't use ignore-errors. diff --git a/lisp/nnheader.el b/lisp/nnheader.el index b4759056b..01b573c55 100644 --- a/lisp/nnheader.el +++ b/lisp/nnheader.el @@ -869,13 +869,15 @@ without formatting." "Return the file size of FILE or 0." (or (nth 7 (file-attributes file)) 0)) -(defun nnheader-find-etc-directory (package &optional file) +(defun nnheader-find-etc-directory (package &optional file first) "Go through `load-path' and find the \"../etc/PACKAGE\" directory. This function will look in the parent directory of each `load-path' entry, and look for the \"etc\" directory there. -If FILE, find the \".../etc/PACKAGE\" file instead." +If FILE, find the \".../etc/PACKAGE\" file instead. +If FIRST is non-nil, return the directory or the file found at the +first. Otherwise, find the newest one, though it may take a time." (let ((path load-path) - dir result) + dir results) ;; We try to find the dir by looking at the load path, ;; stripping away the last component and adding "etc/". (while path @@ -887,10 +889,14 @@ If FILE, find the \".../etc/PACKAGE\" file instead." "etc/" package (if file "" "/")))) (or file (file-directory-p dir))) - (setq result dir - path nil) + (progn + (or (member dir results) + (push dir results)) + (setq path (if first nil (cdr path)))) (setq path (cdr path)))) - result)) + (if (or first (not (cdr results))) + (car results) + (car (sort results 'file-newer-than-file-p))))) (eval-when-compile (defvar ange-ftp-path-format) -- 2.34.1