There are a ton of ways to integrate Cygwin with Emacs on Windows. EmacsWiki shows a few ideas. Here are the options that I\'ve found:
Build emacs from source:
-Download the latest stable release (24.5 as of this writing).
-Unzip and cd into the emacs folder
-Run these steps in order:
$ ./autogen.sh
$ ./configure --with-w32
$ make
$ make install
-Copy emacs.exe, by hand, from the "emacs folder"/src to cygwin/bin
-Run emacs:
$ emacs&
I'm using wsl2 with the win32 27.1 distribution. I followed the instructions here: https://www.emacswiki.org/emacs/NTEmacsWithCygwin The only change I made was this:
(let* ((cygwin-root "//wsl$/Ubuntu/")
Where Ubuntu is your distribution.
I don't have the proper /mnt/c working yet.
I investigated three options, all with windowed (but not X11) versions of Emacs. (The terminal is too hardcore for me.) Here goes:
The Cygwin folks want to steer you to their Emacs/XEmacs. In http://cygwin.com/faq/faq-nochunks.html#faq.using.ntemacs, they write "Note that all of this ``just works'' if you use the Cygwin port of Emacs or XEmacs from Cygwin Setup".
Be sure to install the xemacs-sumo package in addition to xemacs; otherwise M-x shell won't work. You can launch xemacs without using X11 as
DISPLAY= xemacs &
Drawbacks: 1) Boy, this is an old Emacs. I didn't really want to soldier on with this when everyone else is using Emacs 23. 2) I found it mildly annoying that the install required a whole bunch of X11 libs even if you aren't running X11. 3) No cua-mode out of the box.
EmacsW32 (http://ourcomments.org/Emacs/EmacsW32.html) has a one-click installer, a M-x cygwin-shell command, and CUA mode. But tab completion in the Cygwin shell uses Windows paths, which drove me crazy. The W32 port doesn't seem to be actively improved since 2008, but they provide installers with more recent Emacs versions.
The standard Emacs for Windows seems to be the best bet. Download from http://ftp.gnu.org/pub/gnu/emacs/windows/, unzip, and launch from inside Cygwin. Then it picks up the home directory etc. Paste the mumbo-jumbo from http://cygwin.com/faq/faq-nochunks.html#faq.using.ntemacs into ~/.emacs. Restart Emacs and run M-x shell. All works as expected.
A fourth choice is to run emacs in one of Cygwin's alternative terminals: (u)rxvt, mintty, xterm. These all offer much better terminal emulation than the console, which means a much improved emacs experience.
I tend to use the native version of emacs on windows in conjunction with the (also native) ports of gnu utils, which are much faster, though less complete, than the Cygwin ones.
Then I just use a cygwin window for the bash shell and the things that are missing.
The third option. I am using NTEmacs + EmacsW32 + Cygwin. This way I have a native Windows application with Unix utilities and bash shell. The makefiles work, I have never used M-x whois
though. I cannot think of any immediate drawbacks of this setup.
Here are interesting bits of my setup, basically very similar to http://www.emacswiki.org/emacs/NTEmacsWithCygwin:
(setq cygwin-root "c:/cygwin/")
(setq private-bin (concat home-dir "/usr/bin"))
(setq exec-path (cons private-bin exec-path))
(setenv "PATH" (concat private-bin ";" (getenv "PATH")))
; Add Cygwin Emacs stuff
(add-to-load-path "/usr/share/emacs/site-lisp")
; Add Cygwin Info pages
(add-to-list 'Info-default-directory-list
(concat cygwin-root "usr/share/info/"))
(setq shell-file-name "bash")
(setenv "SHELL" shell-file-name)
(setq explicit-shell-file-name shell-file-name)
(setq w32shell-cygwin-bin "c:\\cygwin\\bin")
(require 'w32shell)
(w32shell-add-emacs)
(w32shell-set-shell "cygwin")