unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* insert-file-content on windows and WSL
@ 2024-01-20  6:30 samvid mistry
  2024-01-20 10:25 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: samvid mistry @ 2024-01-20  6:30 UTC (permalink / raw)
  To: help-gnu-emacs

Hey,

I was playing with some code and found an unusual behaviour of
insert-file-contents. I am running GNU Emacs 29.1 *on Windows*. When I am
in a file/buffer that is within WSL, accessed using
`//wsl.localhost/Ubuntu/...`, I can open WSL paths without the prefix,
i.e., I can write `(insert-file-contents "/home/samvid/davmail.log")`
instead of `(insert-file-contents
"//wsl.localhost/Ubuntu/home/samvid/davmail.log")` and it will open the
correct file. However, running `(insert-file-contents
"/home/samvid/davmail.log")` when I am in a buffer/file on windows
filesystem, it will run into this error

`(file-missing "Opening input file" "No such file or directory"
"c:/home/samvid/davmail.log")`

I tried looking at the C code implementation but it is completely beyond me
to comprehend. Was wondering if someone can give me a summary on how this
behaviour is implemented and if there is a chance to tweak it somehow to be
able to open WSL paths while being on windows filesystem without the
`//wsl...` prefix.

Thanks,
Samvid


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: insert-file-content on windows and WSL
  2024-01-20  6:30 insert-file-content on windows and WSL samvid mistry
@ 2024-01-20 10:25 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2024-01-20 10:25 UTC (permalink / raw)
  To: help-gnu-emacs

> From: samvid mistry <mistrysamvid@gmail.com>
> Date: Sat, 20 Jan 2024 12:00:46 +0530
> 
> I was playing with some code and found an unusual behaviour of
> insert-file-contents. I am running GNU Emacs 29.1 *on Windows*. When I am
> in a file/buffer that is within WSL, accessed using
> `//wsl.localhost/Ubuntu/...`, I can open WSL paths without the prefix,
> i.e., I can write `(insert-file-contents "/home/samvid/davmail.log")`
> instead of `(insert-file-contents
> "//wsl.localhost/Ubuntu/home/samvid/davmail.log")` and it will open the
> correct file. However, running `(insert-file-contents
> "/home/samvid/davmail.log")` when I am in a buffer/file on windows
> filesystem, it will run into this error
> 
> `(file-missing "Opening input file" "No such file or directory"
> "c:/home/samvid/davmail.log")`

Isn't this just normal prepending of the drive letter to a file name
that lacks it?  I'm guessing that when you are in a buffer whose name
begins with //wsl.localhost/Ubuntu/... Emacs prepends that to a file
name without a drive letter, whereas in a buffer on the C: drive, it
prepends C:/ instead.

Emacs on Windows doesn't consider file names that begin with a slash
as absolute file names, unless they have are in UNC format and begin
with two slashes.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-20 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-20  6:30 insert-file-content on windows and WSL samvid mistry
2024-01-20 10:25 ` Eli Zaretskii

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).