Skip to content

Instantly share code, notes, and snippets.

View ryzzn's full-sized avatar

Ryzn ryzzn

View GitHub Profile
(defun* get-closest-pathname (&optional (file "Makefile"))
"Determine the pathname of the first instance of FILE starting from the current directory towards root.
This may not do the correct thing in presence of links. If it does not find FILE, then it shall return the name
of FILE in the current directory, suitable for creation"
(let ((root (expand-file-name "/"))) ; the win32 builds should translate this correctly
(expand-file-name file
(loop
for d = default-directory then (expand-file-name ".." d)
if (file-exists-p (expand-file-name file d))
return d