rejeep / f.el

Modern API for working with files and directories in Emacs
GNU General Public License v3.0
685 stars 69 forks source link

f-up misbehaving for top-level directories #36

Closed phst closed 9 years ago

phst commented 9 years ago

There is a simple test for f-up:

(ert-deftest f-up-test/true ()
  (with-playground
   (should (equal f-test/playground-path (f-up (lambda (path) t))))))

This test seems to imply that dir and (f-up (lambda (path) t) dir) should always be equal, which seems reasonable. However, the current implementation of f-up doesn't have this invariant for top-level directories:

(mapcar
 (lambda (dir)
   (list dir (f-up (lambda (path) t) dir)))
 '("/usr/share" "/usr" "/"))
;; Result:
(("/usr/share" "/usr/share") ("/usr" "/") ("/" "/"))

This is version 20150113.24 of f.el on Emacs 25.0.50.1.

rejeep commented 9 years ago

The f-up function has been deprecated in favour of f-traverse-upwards. I will remove it when I release v0.18 (see https://github.com/rejeep/f.el/commit/b8ce29d0c4afac70172c7efe2de0ae211b8cb75e).

(mapcar
 (lambda (dir)
   (list dir (f-traverse-upwards (lambda (path) t) dir)))
 '("/usr/share" "/usr" "/"))
;; Result:
(("/usr/share" "/usr/share") ("/usr" "/usr") ("/" "/"))