From 491f9e91ff20f1e7a0a1c8e52fde93067f4ea1d1 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Fri, 27 Jan 2023 09:24:08 +0200 Subject: [PATCH] mu4e: rework mu4e--file-name-concat into mu4e-join-paths We also need to handle slashes at the *start*. --- mu4e/mu4e-helpers.el | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/mu4e/mu4e-helpers.el b/mu4e/mu4e-helpers.el index 2889acb0..80501255 100644 --- a/mu4e/mu4e-helpers.el +++ b/mu4e/mu4e-helpers.el @@ -460,20 +460,16 @@ Or go to the top level if there is none." ;;; 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. -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 don’t end with a slash, a slash will be inserted -before concatenating. -Compatibility function for Emacs 28's `file-name-concat'." - (mapconcat - (lambda (part) - (if (string= (substring part -1) "/") - (substring part 0 -1) - part)) - (cons directory components) "/")) +This is mu4e's version of Emacs 28's `file-name-concat' with the +difference it also handles slashes at the beginning of +COMPONENTS." + (replace-regexp-in-string + "//+" "/" + (mapconcat (lambda (part) (if (stringp part) part "")) + (cons directory components) "/"))) (provide 'mu4e-helpers) ;;; mu4e-helpers.el ends here