mirror of https://github.com/djcb/mu.git
Preserve single and double slashes while joining
This commit is contained in:
parent
a71b4f5e8d
commit
e4ac3f205d
|
@ -567,21 +567,25 @@ Or go to the top level if there is none."
|
||||||
|
|
||||||
;;; Misc
|
;;; Misc
|
||||||
(defun mu4e-join-paths (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.
|
||||||
|
|
||||||
This is mu4e's version of Emacs 28's `file-name-concat' with the
|
This is mu4e's version of Emacs 28's `file-name-concat' with the
|
||||||
difference it also handles slashes at the beginning of
|
difference it also handles slashes at the beginning of
|
||||||
COMPONENTS."
|
COMPONENTS."
|
||||||
(replace-regexp-in-string
|
(let ((double-slash (string-match "^//[^/]" directory))
|
||||||
"//+" "/"
|
(path (replace-regexp-in-string
|
||||||
(mapconcat (lambda (part) (if (stringp part) part ""))
|
"//+" "/"
|
||||||
(cons directory components) "/")))
|
(mapconcat (lambda (part) (if (stringp part) part ""))
|
||||||
|
(cons directory components) "/"))))
|
||||||
|
(if double-slash
|
||||||
|
(concat "/" path)
|
||||||
|
path)))
|
||||||
|
|
||||||
(defun mu4e-string-replace (from-string to-string in-string)
|
(defun mu4e-string-replace (from-string to-string in-string)
|
||||||
"Replace FROM-STRING with TO-STRING in IN-STRING each time it occurs.
|
"Replace FROM-STRING with TO-STRING in IN-STRING each time it occurs.
|
||||||
Mu4e version of emacs 28's string-replace."
|
Mu4e version of emacs 28's string-replace."
|
||||||
(replace-regexp-in-string (regexp-quote from-string)
|
(replace-regexp-in-string (regexp-quote from-string)
|
||||||
to-string in-string nil 'literal))
|
to-string in-string nil 'literal))
|
||||||
|
|
||||||
(defun mu4e-plistp (object)
|
(defun mu4e-plistp (object)
|
||||||
"Non-nil if and only if OBJECT is a valid plist.
|
"Non-nil if and only if OBJECT is a valid plist.
|
||||||
|
|
Loading…
Reference in New Issue