2

I've been using MinGW compiled native windows 64-bit Emacs for a while, and I paired it with Cygwin to use especially Texlive, as well as other common linux and shell programs and commands.

I am considering switching to Windows Subsystem for Linux (WSL) as I am using Windows 10, and WSL allows me to install genuine linux distributions (esp. the case of WSL2).

I notice two important differences between Cygwin and WSL, which may make pairing up with them for my native windows Emacs different or potentially problematic:

  1. WSL uses linux native binary files for their executables. It can run downloaded linux binary executable files. I believe it is only their executables and they can edit and make changes to other files as usual.

  2. WSL sets the root directories and home directories in a hidden folder.

Does anyone have experience of making the switch to WSL and using Emacs with it?

menuhin
  • 315
  • 2
  • 11

1 Answers1

2

I am (almost exclusively) using Emacs on WSL1.

  • I've got X11 support by VcXsrv. It is very stable.
  • You can mount Windows paths as drvfs. No problem there! My $HOME is my %USERPROFILE%. You can even mount windows network paths and usb drives.
  • File access is much faster under WSL1. It is even possible to use magit under WSL. (Under Cygwin magit is deadly slow for the projects I am working on.)
    On Linux-native drives (EXT2) file system access in WSL2 is even faster than that of WSL1. But (at least for Windows10), accessing files of the Windows host (mounted with mount -t drvfs ... is much slower in WSL2 than in WSL1. So, if you need interoperability on file-system-level you should stick to WSL1.
  • You can call windows apps directly from Linux.
  • You can convert paths from/to windows with /bin/wslpath. (That is almost like cygpath.exe.)
  • I am using the Powershell to copy paste images from Windows to Emacs and direct HTML contents from Emacs to Web-applications working in the Windows browser. Export of Orgmode stuff (regions, subtrees, files) without immediate HTML files directly over the Windows-Clipboard.

I do not know much about WSL2, but some yt-video, I don't remember right now, showed that starting windows applications from WSL2 works too.

Having said all the good stuff I have also to mention that I keep my Cygwin environment alive because one never knows when M$ decides to start with compatibility breaking changes or with discontinuing support for WSL.

Tobias
  • 32,569
  • 1
  • 34
  • 75
  • Sounds great. Is your Emacs from the WSL (via apt-get install) or a Windows compiled Emacs? – menuhin Mar 18 '20 at 22:19
  • @menuhin It is the Ubuntu 18.04 version installed with `aptitude install emacs26` (when I remember right). I think that is what counts as "from the WSL". – Tobias Mar 18 '20 at 22:25
  • Now I know what you and quite a few other guides are talking about - using Emacs from within WSL. I am not ready to take this big step, and thinking of using WSL as my Cygwin replacement and pair it with my 64-bit Windows compiled Emacs 26.2. I can see that everything will run smooth in your case as both the linux system and Emacs are from the same (WSL) environment. – menuhin Mar 18 '20 at 22:42
  • @menuhin In my experience Windows Emacs is not worth the trouble. Emacs often works with the file system and everything related to the file system is slow in Windows compared to Linux. WSL1 stuff is faster in this aspect than Windows native (in spite of the fact that WSL1 is heavily based on Windows) and you get a factor of 10 again with WSL2. That is really a killing argument if you are working with magit. Also the tool support is better under Linux. E.g., `pdftools` works out of the box. – Tobias Mar 18 '20 at 23:03
  • I should bite the bullet and give it a try then, given `drvfs` makes working on both filesystems not a problem. One last concern: when I call programs from within native Windows Emacs, e.g. a windows version of python or lisp, there won't be any problem. I will have to switch all these programs to linux (WSL) based then? – menuhin Mar 18 '20 at 23:42
  • @menuhin You do not need to switch to the WSL versions of all programs. The only difference is that the file extension of the executables is part of the file name, i.e., you call `(call-process "powershell.exe" ...)` instead of `(call-process "powershell" ...)`. But, if I was you, I would keep both versions and experiment a bit. Maybe, there are features of the Windows version that you use a lot and I don't. – Tobias Mar 18 '20 at 23:54
  • I found the answer to running windows exe: [https://docs.microsoft.com/en-us/windows/wsl/interop](https://docs.microsoft.com/en-us/windows/wsl/interop) Now it is a no-brainer to switch. All left is for me to nicely clean up my dot-emacs file for migration. Thanks! – menuhin Mar 18 '20 at 23:56
  • Note, that I didn't care much about the drag-and-drop possibilities of Emacs under WSL. Drag and drop does not work out of the box. But, maybe, that could be tweaked using the registry. – Tobias Mar 19 '20 at 00:02