Skip to content

Commit

Permalink
feat(core): add +directory-root-containing-file
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jan 29, 2024
1 parent a0e5a3d commit 3ee9727
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,15 @@ that directory."
(+error! "Cannot create directory %s" parent-dir)))
path))

(defun +directory-root-containing-file (files &optional start-path)
"Return the path containing a file from FILES starting from START-PATH."
(let ((dir (or start-path (buffer-file-name))))
(catch 'root
(while dir
(when (cl-some #'file-exists-p (mapcar (+apply-partially-right #'expand-file-name dir) (ensure-list files)))
(throw 'root dir))
(setq dir (file-name-parent-directory dir))))))

(defun +delete-this-file (&optional path force-p)
"Delete PATH.
Expand Down

0 comments on commit 3ee9727

Please sign in to comment.