diff --git a/lisp/files.el b/lisp/files.el index d98d09bb1e..2478a22046 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -7056,7 +7056,8 @@ file-name-non-special '(nil 0)))) method ;; Copy ARGUMENTS so we can replace elements in it. - (arguments (copy-sequence arguments))) + (arguments (copy-sequence arguments)) + file-name-handler-alist) (if (symbolp (car file-arg-indices)) (setq method (pop file-arg-indices))) ;; Strip off the /: from the file names that have it. @@ -7064,27 +7065,20 @@ file-name-non-special (while (consp file-arg-indices) (let ((pair (nthcdr (car file-arg-indices) arguments))) (and (car pair) - (string-match "\\`/:" (car pair)) - (setcar pair - (if (= (length (car pair)) 2) - "/" - (substring (car pair) 2))))) + (setcar pair (file-name-unquote (car pair))))) (setq file-arg-indices (cdr file-arg-indices)))) (pcase method (`identity (car arguments)) (`add (file-name-quote (apply operation arguments))) (`buffer-file-name - (let ((buffer-file-name - (if (string-match "\\`/:" buffer-file-name) - (substring buffer-file-name (match-end 0)) - buffer-file-name))) + (let ((buffer-file-name (file-name-unquote buffer-file-name))) (apply operation arguments))) (`insert-file-contents (let ((visit (nth 1 arguments))) (unwind-protect (apply operation arguments) (when (and visit buffer-file-name) - (setq buffer-file-name (concat "/:" buffer-file-name)))))) + (setq buffer-file-name (file-name-quote buffer-file-name)))))) (`unquote-then-quote ;; We can't use `cl-letf' with `(buffer-local-value)' here ;; because it wouldn't work during bootstrapping. @@ -7093,7 +7087,7 @@ file-name-non-special ;; `verify-visited-file-modtime' action, which takes a buffer ;; as only optional argument. (with-current-buffer (or (car arguments) buffer) - (let ((buffer-file-name (substring buffer-file-name 2))) + (let ((buffer-file-name (file-name-unquote buffer-file-name))) ;; Make sure to hide the temporary buffer change from the ;; underlying operation. (with-current-buffer buffer