I'm walking a directory tree upwards from
default-directory in a loop, so I need a way to say "take the last component off this path that ends in a slash and return a result that ends in a slash". The closest built-in thing I found is
(file-name-directory) and it's not a great fit. I ended up writing this:
(defun pop-dir (dir) "Pops a trailing directory off DIR to return the remainder of the path." (concat "/" ;; there's probably some better way to do this but ¯\_(ツ)_/¯ (string-join (reverse (cdr (reverse (split-string dir "/" t)))) "/") "/"))
There has to be a better way; what is it?