简体   繁体   中英

Emacs + Cygwin setup under windows !

I just downloaded Emacs and Cygwin for Windows(Vista in my case). Have no idea how to set them up.

Any help would be appreciated ! Thanks !

Step 1: Install libraries

http://www.emacswiki.org/emacs/cygwin-mount.el

http://www.emacswiki.org/emacs/setup-cygwin.el

Step 2: Install cygwin to C:\cygwin (This requirement is hardcoded in setup-cygwin.el, so just do it unless you are willing to modify setup-cygwin.el).

Step 3: Add following code into your .emacs or .emacs.d/init.el . Please note the variable cygwin-mount-cygwin-bin-directory is not set by default in cygwin-mount.el, I suggest using hard coded path (I mean "c:/cygwin/bin" actually) since the cygwin install path is already hardcoded by setup-cygwin.el.

(setq *win32* (eq system-type 'windows-nt) )
;; win32 auto configuration, assuming that cygwin is installed at "c:/cygwin"
(if *win32*
(progn
    (setq cygwin-mount-cygwin-bin-directory "c:/cygwin/bin")
    (require 'setup-cygwin)
    ;(setenv "HOME" "c:/cygwin/home/someuser") ;; better to set HOME env in GUI
    ))

I use these libraries, in this order:

(require 'cygwin-mount)
(require 'setup-cygwin)

They are both available on EmacsWiki:

http://www.emacswiki.org/emacs/cygwin-mount.el

http://www.emacswiki.org/emacs/setup-cygwin.el

您可以在此处找到说明。

Use cygwin-mount.el to integrate Cygwin with Emacs:

You might also want to replace the DOS Shell with the Cygwin bash, that's also covered.

There're several way to integrate emacs with cygwin as follows:

  1. emacs-nox under cygwin. Not attractive!
  2. emacs-X11 under cygwin. An X server is needed like XMing or Cygwin/X. A bit slow and heavy.
  3. emacs-w32 under cygwin.
  4. emacs under windows. You need some configuration to make emacs recognize the cygwin environment. Difficult for beginners.

I'd recommend using emacs-w32 with cygwin, which uses native Windows GUI so that you don't have to start an xserver just to run emacs and you don't need to write/download any tricky code to make emacs aware of cygwin env as other answers do.

Just install emacs-w32 and run it from mintty and here you go. FYI, if you want to start emacs "independently", write a .bat file with D:\cygwin\bin\run.exe /usr/bin/bash.exe --login -i -c /usr/bin/emacs-w32.exe inside or, as I do, write a .ahk script to start emacs with hotkey F12 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM