mu4e: rework mu4e--file-name-concat into mu4e-join-paths

We also need to handle slashes at the *start*.
This commit is contained in:
Dirk-Jan C. Binnema 2023-01-27 09:24:08 +02:00
parent 83be800611
commit 491f9e91ff
1 changed files with 8 additions and 12 deletions

View File

@ -460,20 +460,16 @@ Or go to the top level if there is none."
;;; Misc ;;; Misc
(defun mu4e--file-name-concat (directory &rest components) (defun mu4e-join-paths (directory &rest components)
"Append COMPONENTS to DIRECTORY and return the resulting string. "Append COMPONENTS to DIRECTORY and return the resulting string.
Elements in COMPONENTS must be a string or nil. DIRECTORY or the
non-final elements in COMPONENTS may or may not end with a slash
-- if they dont end with a slash, a slash will be inserted
before concatenating.
Compatibility function for Emacs 28's `file-name-concat'." This is mu4e's version of Emacs 28's `file-name-concat' with the
(mapconcat difference it also handles slashes at the beginning of
(lambda (part) COMPONENTS."
(if (string= (substring part -1) "/") (replace-regexp-in-string
(substring part 0 -1) "//+" "/"
part)) (mapconcat (lambda (part) (if (stringp part) part ""))
(cons directory components) "/")) (cons directory components) "/")))
(provide 'mu4e-helpers) (provide 'mu4e-helpers)
;;; mu4e-helpers.el ends here ;;; mu4e-helpers.el ends here