* Saving a remote buffer into a local file @ 2017-01-24 9:07 Dani Moncayo 2017-01-24 9:37 ` Dani Moncayo 2017-01-24 16:10 ` Stefan Monnier 0 siblings, 2 replies; 6+ messages in thread From: Dani Moncayo @ 2017-01-24 9:07 UTC (permalink / raw) To: help-gnu-emacs@gnu.org list Hi all, Yesterday, I wanted to do something with Emacs, and failed. I did a quick search in the Tramp manual and Google, and found no solution. So I'm asking here for help. Suppose I visit some remote file: C-x C-f /ssh:user1@host1:/path1/file1 Now, I want to save the resulting buffer into a local file. Doing: C-x C-w ~/file2 does not work, since in will create a file in the remote host (host1). I think it would be nice to have some special syntax, so that I can specify a path in my local host (and avoid the cumbersome "/localuser@localhost:/localpath"). Is there such a syntax? If not, which do you think is the easiest way to save the buffer in my local host? TIA -- Dani Moncayo ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Saving a remote buffer into a local file 2017-01-24 9:07 Saving a remote buffer into a local file Dani Moncayo @ 2017-01-24 9:37 ` Dani Moncayo 2017-01-24 16:00 ` Eli Zaretskii 2017-01-24 16:10 ` Stefan Monnier 1 sibling, 1 reply; 6+ messages in thread From: Dani Moncayo @ 2017-01-24 9:37 UTC (permalink / raw) To: help-gnu-emacs@gnu.org list > I think it would be nice to have some special syntax, so that I can > specify a path in my local host (and avoid the cumbersome > "/localuser@localhost:/localpath"). > > Is there such a syntax? Answering myself: Yes, it seems so: Just quote the local path with "/:": C-x C-w /:~/file2 This feature is documented in the Emacs manual. Node "Quoted File Names". Thanks. -- Dani Moncayo ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Saving a remote buffer into a local file 2017-01-24 9:37 ` Dani Moncayo @ 2017-01-24 16:00 ` Eli Zaretskii 0 siblings, 0 replies; 6+ messages in thread From: Eli Zaretskii @ 2017-01-24 16:00 UTC (permalink / raw) To: help-gnu-emacs > From: Dani Moncayo <dmoncayo@gmail.com> > Date: Tue, 24 Jan 2017 10:37:23 +0100 > > > I think it would be nice to have some special syntax, so that I can > > specify a path in my local host (and avoid the cumbersome > > "/localuser@localhost:/localpath"). > > > > Is there such a syntax? > > Answering myself: Yes, it seems so: Just quote the local path with "/:": > > C-x C-w /:~/file2 Yes. However, don't expect this to resolve to a file in your local home directory. That's what currently happens on MS-Windows (not on Unix), but it will go away in Emacs 26, where "~/" will no longer expand to HOME in quoted file names. Instead, you will get DEFDIR/~/file2, where DEFDIR is the default-directory of the buffer from which you invoke the command. That's because "/:" is supposed to quote the tilde as well, allowing to use it as a literal character in a file name. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Saving a remote buffer into a local file 2017-01-24 9:07 Saving a remote buffer into a local file Dani Moncayo 2017-01-24 9:37 ` Dani Moncayo @ 2017-01-24 16:10 ` Stefan Monnier 2017-01-25 8:42 ` Dani Moncayo 2017-01-25 9:51 ` Michael Albinus 1 sibling, 2 replies; 6+ messages in thread From: Stefan Monnier @ 2017-01-24 16:10 UTC (permalink / raw) To: help-gnu-emacs > Suppose I visit some remote file: > C-x C-f /ssh:user1@host1:/path1/file1 > Now, I want to save the resulting buffer into a local file. Doing: > C-x C-w ~/file2 > does not work, since in will create a file in the remote host (host1). It works for me if I add a "C-a C-k": C-x C-w C-a C-k ~/file2 Yet, if I do like you suggest, I see a bug: while typing "~/file2" the leading "/ssh:user1@host1:/path1/" text is greyed out, giving the incorrect impression that it won't be used. Stefan ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Saving a remote buffer into a local file 2017-01-24 16:10 ` Stefan Monnier @ 2017-01-25 8:42 ` Dani Moncayo 2017-01-25 9:51 ` Michael Albinus 1 sibling, 0 replies; 6+ messages in thread From: Dani Moncayo @ 2017-01-25 8:42 UTC (permalink / raw) To: help-gnu-emacs@gnu.org list Hi Stefan and Eli, On Tue, Jan 24, 2017 at 5:10 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote: >> Suppose I visit some remote file: >> C-x C-f /ssh:user1@host1:/path1/file1 >> Now, I want to save the resulting buffer into a local file. Doing: >> C-x C-w ~/file2 >> does not work, since in will create a file in the remote host (host1). > > It works for me if I add a "C-a C-k": > > C-x C-w C-a C-k ~/file2 That works here[1] too. That's an easier way of creating the local file. Thank you! On Tue, Jan 24, 2017 at 5:00 PM, Eli Zaretskii <eliz@gnu.org> wrote: >> [...] >> Answering myself: Yes, it seems so: Just quote the local path with "/:": >> >> C-x C-w /:~/file2 Actually, what I did was C-x C-w C-a C-k /:~/file2 > Yes. However, don't expect this to resolve to a file in your local > home directory. That's what currently happens on MS-Windows (not on > Unix), For the record: this ("/:~" resolving to my local home directory) does happen here[1]. > but it will go away in Emacs 26, where "~/" will no longer > expand to HOME in quoted file names. Instead, you will get > DEFDIR/~/file2, where DEFDIR is the default-directory of the buffer > from which you invoke the command. That's because "/:" is supposed to > quote the tilde as well, allowing to use it as a literal character in > a file name. Ok, so IIUC, from Emacs 26 onwards, if I want to save the remote buffer into a local file, I will have to specify an explicit, absolute quoted path like "/:/home/dani/foo" (or follow Stefan's suggestion, which is easier actually). Thanks. -- Dani Moncayo Footnotes: [1] My environment: Cygwin + Emacs 25.1 (distributed with cygwin). ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Saving a remote buffer into a local file 2017-01-24 16:10 ` Stefan Monnier 2017-01-25 8:42 ` Dani Moncayo @ 2017-01-25 9:51 ` Michael Albinus 1 sibling, 0 replies; 6+ messages in thread From: Michael Albinus @ 2017-01-25 9:51 UTC (permalink / raw) To: Stefan Monnier; +Cc: help-gnu-emacs Stefan Monnier <monnier@iro.umontreal.ca> writes: >> Suppose I visit some remote file: >> C-x C-f /ssh:user1@host1:/path1/file1 >> Now, I want to save the resulting buffer into a local file. Doing: >> C-x C-w ~/file2 >> does not work, since in will create a file in the remote host (host1). > > It works for me if I add a "C-a C-k": > > C-x C-w C-a C-k ~/file2 > > Yet, if I do like you suggest, I see a bug: while typing "~/file2" the > leading "/ssh:user1@host1:/path1/" text is greyed out, giving the > incorrect impression that it won't be used. No. Only "/path1/" is greyed out, telling you that *this* part won't be used. Remote file names have a special meaning of double slash and slash tilde in file name completion. It removes the leading part of the remote file name's local part. You need another slash for removing the whole file name in the minibuffer. Therefore, doing C-x C-w /~/file2 would suffice. You will see also the grey part of the minibuffer being changed to the whole line. Personally, when I want to save a remote file locally, I have the attitude typing three slashes first. Meanwhile, I do this even w/o thinking about :-) See (info "(tramp) File name completion") for discussion. > Stefan Best regards, Michael. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-25 9:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-01-24 9:07 Saving a remote buffer into a local file Dani Moncayo 2017-01-24 9:37 ` Dani Moncayo 2017-01-24 16:00 ` Eli Zaretskii 2017-01-24 16:10 ` Stefan Monnier 2017-01-25 8:42 ` Dani Moncayo 2017-01-25 9:51 ` Michael Albinus
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).