bug#81622: 32.0.50; dired-do-async-shell-command in Tramp sudo dired buffer substitutes Tramp file name
Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Michael Albinus <[email protected]> writes: Hi Filipp, >> - touch /tmp/1.txt >> >> - emacs -Q >> >> - Open sudo dired buffer: /sudo::/tmp >> >> - Go to 1.txt and type: & cat SPC RET >> >> - Observe error: "cat: /sudo:root@myhost:/tmp/1.txt: No such file or >> directory" > > Strange, I cannot reproduce. And reading the code, I don't understand > why it behaves like this. Finally, I could reproduce the problem. The scenario is more complex, 'tho. --8<---------------cut here---------------start------------->8--- - touch /tmp/1.txt - emacs -Q - Open dired buffer: /tmp - Type 'C-x x @'. This replaces the dired buffer with /sudo::/tmp - Go to 1.txt and type: '& cat SPC RET' - Observe error: "cat: /sudo:root@myhost:/tmp/1.txt: No such file or directory" --8<---------------cut here---------------end--------------->8--- The appended patch ought to fix it. Could you, pls, check? >> Thanks. Best regards, Michael.
(unnamed)
(text/x-patch, 2.8 KB)
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index e6ab0630d7a..af661770371 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -678,33 +678,35 @@ tramp-file-name-with-sudo "Convert FILENAME into a multi-hop file name with \"sudo\". An alternative method could be chosen with `tramp-file-name-with-method'." (setq filename (expand-file-name filename)) - (let ((default-method (tramp-get-file-name-with-method))) - (if (tramp-tramp-file-p filename) - (with-parsed-tramp-file-name filename nil - (cond - ;; Remote file with proper method. - ((string-equal method default-method) - filename) - ;; Remote file on the local host. - ((and - (stringp tramp-local-host-regexp) (stringp host) - (string-match-p tramp-local-host-regexp host)) - (tramp-make-tramp-file-name - (make-tramp-file-name - :method default-method :localname localname))) - ;; Remote file with multi-hop capable method. - ((tramp-multi-hop-p v) - (tramp-make-tramp-file-name - (make-tramp-file-name - :method (tramp-find-method default-method nil host) - :user (tramp-find-user default-method nil host) - :host (tramp-find-host default-method nil host) - :localname localname :hop (tramp-make-tramp-hop-name v)))) - ;; Other remote file. - (t (tramp-user-error v "Multi-hop with `%s' not applicable" method)))) - ;; Local file. - (tramp-make-tramp-file-name - (make-tramp-file-name :method default-method :localname filename))))) + (expand-file-name + (let ((default-method (tramp-get-file-name-with-method))) + (if (tramp-tramp-file-p filename) + (with-parsed-tramp-file-name filename nil + (cond + ;; Remote file with proper method. + ((string-equal method default-method) + filename) + ;; Remote file on the local host. + ((and + (stringp tramp-local-host-regexp) (stringp host) + (string-match-p tramp-local-host-regexp host)) + (tramp-make-tramp-file-name + (make-tramp-file-name + :method default-method :localname localname))) + ;; Remote file with multi-hop capable method. + ((tramp-multi-hop-p v) + (tramp-make-tramp-file-name + (make-tramp-file-name + :method (tramp-find-method default-method nil host) + :user (tramp-find-user default-method nil host) + :host (tramp-find-host default-method nil host) + :localname localname :hop (tramp-make-tramp-hop-name v)))) + ;; Other remote file. + (t + (tramp-user-error v "Multi-hop with `%s' not applicable" method)))) + ;; Local file. + (tramp-make-tramp-file-name + (make-tramp-file-name :method default-method :localname filename)))))) ;; FIXME: We would like to rename this for Emacs 31.1 to a name that ;; does not encode the default method. It is intended as a generic