reddit / emacs

A summary and rant on the state of Emacs on Windows NT in 2022

MitchellMarquez42 · 2022-07-22 04:42
(:warning ("long post")) GNU Emacs is a wholly remarkable existence. It is not only ancient, but sharp: a wise master that has seen others fall and learned from their mistakes. It exists as a sort of second user land, integrating the underlying OS's built in libraries and utilities into a rich-text interface powered by thousands of lines of tried and true lisp code. Microsoft Windows is also a wholly remarkable existence. It, too, has quite the history; yet the Windows OS itself (and DOS before it) has largely served as a mcguffin in its own tale. Indeed, the rise of Microsoft and the personal computer seem to have taken place in _spite_ of their OS's glaring deficiencies rather than because of any particular merit. And still, somehow, Windows 10 is ... Dare I say ... Kinda good? The move into the .net api has allowed greater interoperability and extensibility, culminating in PowerShell (which is about as close as you can get to lisp while looking like perl). NTFS is aging, but caching is catching up. The directory structure is awful, but M$ provides a first-party solution to everything: just use WSL and pretend you're on linux. In the wider free software community, there has never been better compatibility between Windows and the hot new languages and development libraries. We have git. We have package managers. And sometimes, they even work. With that recap out of the way, let's go over all the ways of running and using emacs on Windows, and the benefits and drawbacks of each. 1. Stock build of Emacs This is the one you get from `scoop install emacs` or choco. It can be used like any other app in Windows, with the gotcha that running the `emacs` command directly from a gui will spawn an empty and unsightly console window. The command to run is `runemacs`, which instantly forks. This is aware of the Windows file hierarchy, but still uses `/` as the directory separator. Paths starting with / are implied to be on the C drive, but others can be specified no problem. Xwidget-webkit is not compiled in. The current version is 28.1. 2. Emacs 29 unofficial builds For example, `emacs-k` on scoop. Essentially the same as (1) except the current version is (last I checked) 29.0.5. Emacs 29 supposedly adds features such as pixel-scroll-precision and the `alpha-background` frame parameter, but I have been unable to get these features working on Windows. 3. Building it yourself on native Windows Basically, a royal pain. You will fail to track down half of the dependencies and ruin an afternoon trying. 4. Cygwin Emacs Cygwin is a Unix environment, compiled and running natively in Windows. They have an installer and are also available via Scoop (which basically just runs the installer for you, but whatever). When selecting packages in the cygwin installer, you can ask for emacs. They have multiple versions built with different gui toolkits: terminal-only, GTK, Motif, and NT (the Win32 look). I have not done extensive testing on these distributions, but there appear to be problems displaying a graphical window even with the native UI. 5. Building it yourself on Cygwin This is actually possible. You just need to find a guide on which libraries to select when running the cygwin installer (you can re-run it and it will add new packages to your existing sub-system), grab the emacs source from GNU (I recommend a depth=1 clone because time and internet), fix all the files with `dos2unix` and `find` because you understandably used the windows version of git, and ./autogen.sh, oops missed a lib, re-run cyg installer, restart terminal, go back in, try again, then ./configure && make && sudo make install. This also seems to have issues with displaying a gui, but further testing is needed. 6. Windows Subsystem for Linux (WSL) WSL is an integrated virtual machine and shim that brute-force compensates for windows by not being windows. It has support for a few distros: Debian, Ubuntu, and Alpine. You can do whatever to this system, as it is an isolated vm. However, this takes effort and is rarely necessary. Anyway, installing emacs can be done just as on the Linux distro itself. However, WSL's solution for GUI apps is only on windows 11. To use on windows 10, install an x server. I found one on the windows store (persecute me) that has a tray icon and a button to make itself the default on whichever WSL distro. It works, and displays an emacs. However, there are some X errors shown. See below. 7. Build it yourself on WSL You can follow any working guide for the Linux distro trapped in your WSL. I built mine with xwidgets because I'm in the middle of hacking up a system to display PDFs by converting them to html with mupdf, but the context isn't important. Anyway: trying to launch xwidget-webkit-browse-url URL dumps an emacs error, an X error, and a frozen-display emacs. The window will close just fine, or you can open a new buffer like `tetris`, but webkit just doesn't load. --- Please correct me if I got anything wrong here, and feel free to share your woes of trying to get stuff to compile.
ShillyShallyTypist · 2022-07-22 05:46
I've been using Cygwin Emacs (Windows native GUI) for years, and have no idea what those "problems displaying a graphical window" are.
7890yuiop · 2022-07-22 06:48
My recollection (from many, many years ago) is that I installed an X11 server for windows, and Cygwin Emacs was happy. I imagine it was the Cygwin X11 server, and IIRC you could either start it with one giant Windows window comprising an X display for any X windows; or else (what you probably want) start it in a 'headless' form, with each X window then appearing more or less like a native Windows window.
SequentialDesign · 2022-07-22 06:48
never used Windows NT, but i use Windows 10 a lot. another possibility is downloading the exe from the GNU ftp site: https://ftp.gnu.org/gnu/emacs/windows/ it's more than fine. you have access to the `alt`, `hyper`, and `super` modifiers. just read the manual. Emacs is wonderful everywhere. if you use WSL, you can use bash in Emacs's shell. Emacs in WSL is also nice.
SickMoonDoe · 2022-07-22 07:15
🤣 Wait. Please give me a minute I can't breath. "Microsoft Windows is also a wholly remarkable existence." 🤣 An OS so good that even their own developers are fighting to scrap it and make a Linux fork instead.
n-i-c-l-a-s · 2022-07-22 07:50
I just use the noX version of emacs in the WSL command line. That works quite well, but you can not use some of the emacs features that need an xserver, of course (like showing in line images or in line latex). I am pretty happy with this solution though (using emacs mostly for coding and org mode) and it is extremely simple to set up
Danboil · 2022-07-22 11:31
I just download the zip, extract it somewhere, and pin runemacs.exe to taskbar. Easy.
superbottles · 2022-07-22 13:39
I only used an x server for a brief time but I found the setup and usage very simple at the time and everything seemed to just work.
Mamonimoni · 2022-07-22 17:56
magit is painfully slow on windows!
MitchellMarquez42 · 2022-07-22 18:06
I meant remarkably bad
danebalia · 2022-07-22 20:28
I did a similar post a while back. Even if it's in WSL it's still in a container inside another OS and you feel it. Either you need to share things, copy things, copy and paste, networking, debugging blah blah blah. Its painful. You could potentially get by if you have limited requirements however. As a C# developer, needing to push up to remote repositories (non github), self-signed certificate based security, corporate VPN usage and languages like C#, it broke the camels back. Emacs only on *Nix for me. https://www.reddit.com/r/emacs/comments/ufc4t8/emacs_binary_or_msys2_or_wsl2/
SnooBeans2851 · 2022-07-22 22:56
I tried getting emacs on wsl to work, and no matter how I tried, the moment I tried to actually make edits, emacs would take 5-7 seconds to display the actual text edits. No thanks. Back to emacs on a real linux VM. (Gui emacs, both the wsl and x410 approaches had the same terrible results. Ymmv)
ShillyShallyTypist · 2022-07-23 16:26
Considering the last Windows version with "NT" in its product name is NT 4 from 1996, I don't think OP is referring to NT in that sense. Rather any Windows from the NT family, i.e. any version relevant in the last two decades. I don't know why, but Emacs people seem to like that wording. "NTEmacs is commonly used to denote Emacs compiled as a native w32 application." ([Emacs Wiki](https://www.emacswiki.org/emacs/NTEmacsWithCygwin))
s3r3ng · 2022-07-24 07:21
I simply installed a stock linux emacs under WSL and brought up X on windows for when I wanted a GUI. Why would anyone be using windows NT in 2022 though?
bitwize · 2022-07-24 21:01
I did a MinGW Emacs build under MSYS64 and it works fine. Had to hunt down a few libraries, but no more than I have to do with a typical Linux install. There *is* the small matter that Emacs handles paths differently than does the MSYS64 shell, so you have to be a bit careful and autocomplete when typing in shell commands won't work right. But the program itself is fine, and it wasn't any more difficult to build than an Emacs under Linux. I don't use XWidgets because it's a hacky hack -- if I wanted WebKit browsers inside Emacs frames I'd just use EXWM with Chromium -- so I really don't know the feasibility of achieving what you want that way. Probably low to none.
[deleted] · 2022-07-25 21:54
[removed]
emoarmy · 2022-07-27 03:47
Arch and Ubuntu works wonderfully for me with x410 ¯\\\_(ツ)\_/¯ I did have to add a rule in my firewall for WSL (but I I needed that anyways for development 🤷)
pushqrex · 2022-12-17 14:27
to fix that install \`git for windows\` not the default git client.