diff options
author | Matus Goljer <dota.keys@gmail.com> | 2014-08-28 14:18:22 +0200 |
---|---|---|
committer | Matus Goljer <dota.keys@gmail.com> | 2014-08-28 15:49:28 +0200 |
commit | 2e85dede0b7bebe34e0d079c1e58d32f2a139d2a (patch) | |
tree | 8619385ebc001a56613386bc82ce258944305a9b /f.el | |
parent | f9238c3bfd8ce29edc8f42d4949e8630916ef05b (diff) |
Fix f-common-parent if input list has just one element
Diffstat (limited to 'f.el')
-rw-r--r-- | f.el | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -93,14 +93,18 @@ If PATH is not allowed to be modified, throw error." (defun f-common-parent (paths) "Return the deepest common parent directory of PATHS." - (let* ((paths (-map 'f-split paths)) - (common (caar paths)) - (re nil)) - (while (--all? (equal (car it) common) paths) - (setq paths (-map 'cdr paths)) - (push common re) - (setq common (caar paths))) - (if re (concat (apply 'f-join (nreverse re)) "/") ""))) + (cond + ((not paths) nil) + ((not (cdr paths)) (f-parent (car paths))) + (:otherwise + (let* ((paths (-map 'f-split paths)) + (common (caar paths)) + (re nil)) + (while (--all? (equal (car it) common) paths) + (setq paths (-map 'cdr paths)) + (push common re) + (setq common (caar paths))) + (if re (concat (apply 'f-join (nreverse re)) "/") ""))))) (defun f-ext (path) "Return the file extension of PATH." |