Implement another fix for bug#49229

* lisp/minibuffer.el (read-file-name-default): Respect remote files.
(Bug#49229)

* lisp/net/tramp-sh.el (tramp-sh-handle-expand-file-name):
Handle special file names on MS Windows.

* lisp/net/tramp.el (tramp-file-name-handler): Revert patch.
(Bug#49229)
This commit is contained in:
Michael Albinus 2021-07-02 14:51:23 +02:00
parent 38aa2074f8
commit 225ca617b7
3 changed files with 59 additions and 58 deletions

View file

@ -3161,6 +3161,7 @@ See `read-file-name' for the meaning of the arguments."
(unless val (error "No file name specified"))
(if (and default-filename
(not (file-remote-p dir))
(string-equal val (if (consp insdef) (car insdef) insdef)))
(setq val default-filename))
(setq val (substitute-in-file-name val))

View file

@ -2667,6 +2667,12 @@ the result will be a local, non-Tramp, file name."
(setq dir (or dir default-directory "/"))
;; Handle empty NAME.
(when (zerop (length name)) (setq name "."))
;; On MS Windows, some special file names are not returned properly
;; by `file-name-absolute-p'.
(if (and (eq system-type 'windows-nt)
(string-match-p
(concat "^\\([[:alpha:]]:\\|" null-device "$\\)") name))
(tramp-run-real-handler #'expand-file-name (list name dir))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (concat (file-name-as-directory dir) name)))
@ -2696,7 +2702,8 @@ the result will be a local, non-Tramp, file name."
(setq uname
(with-tramp-connection-property v uname
(tramp-send-command
v (format "cd %s && pwd" (tramp-shell-quote-argument uname)))
v
(format "cd %s && pwd" (tramp-shell-quote-argument uname)))
(with-current-buffer (tramp-get-buffer v)
(goto-char (point-min))
(buffer-substring (point) (point-at-eol)))))
@ -2710,13 +2717,13 @@ the result will be a local, non-Tramp, file name."
(setq localname "/"))
;; No tilde characters in file name, do normal
;; `expand-file-name' (this does "/./" and "/../").
;; `default-directory' is bound, because on Windows there would
;; be problems with UNC shares or Cygwin mounts.
;; `default-directory' is bound, because on Windows there
;; would be problems with UNC shares or Cygwin mounts.
(let ((default-directory (tramp-compat-temporary-file-directory)))
(tramp-make-tramp-file-name
v (tramp-drop-volume-letter
(tramp-run-real-handler
#'expand-file-name (list localname))))))))
#'expand-file-name (list localname)))))))))
;;; Remote commands:

View file

@ -2610,14 +2610,7 @@ Fall back to normal file name handler if no Tramp file name handler exists."
;; When `tramp-mode' is not enabled, or the file name is quoted,
;; we don't do anything.
;; When operation is `expand-file-name', and the first argument
;; is a local absolute file name, we end also here. Handle the
;; MS Windows case.
(funcall
(if (and (eq operation 'expand-file-name)
(not (string-match-p "\\`[[:alpha:]]:/" (car args))))
#'tramp-drop-volume-letter #'identity)
(tramp-run-real-handler operation args)))))
(tramp-run-real-handler operation args))))
(defun tramp-completion-file-name-handler (operation &rest args)
"Invoke Tramp file name completion handler for OPERATION and ARGS.