简体   繁体   English

windows下的Emacs+Cygwin设置!

[英]Emacs + Cygwin setup under windows !

I just downloaded Emacs and Cygwin for Windows(Vista in my case).我刚刚下载了适用于 Windows 的 Emacs 和 Cygwin(在我的例子中是 Vista)。 Have no idea how to set them up.不知道如何设置它们。

Any help would be appreciated !任何帮助,将不胜感激 ! Thanks !谢谢 !

Step 1: Install libraries第 1 步:安装库

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

http://www.emacswiki.org/emacs/setup-cygwin.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).第 2 步:将 cygwin 安装到C:\cygwin (此要求在 setup-cygwin.el 中进行了硬编码,因此除非您愿意修改 setup-cygwin.el,否则请执行此操作)。

Step 3: Add following code into your .emacs or .emacs.d/init.el .第 3 步:将以下代码添加到您的.emacs.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.请注意,cygwin-mount.el 中默认未设置变量cygwin-mount-cygwin-bin-directory ,我建议使用硬编码路径(实际上是“c:/cygwin/bin”),因为 cygwin 安装路径是已由 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:它们都可以在 EmacsWiki 上找到:

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

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

您可以在此处找到说明。

Use cygwin-mount.el to integrate Cygwin with Emacs:使用 cygwin-mount.el 将 Cygwin 与 Emacs 集成:

You might also want to replace the DOS Shell with the Cygwin bash, that's also covered.您可能还想用 Cygwin bash 替换 DOS Shell,这也包括在内。

There're several way to integrate emacs with cygwin as follows:有几种方法可以将 emacs 与 cygwin 集成,如下所示:

  1. emacs-nox under cygwin. cygwin下的emacs-nox。 Not attractive!没有吸引力!
  2. emacs-X11 under cygwin. cygwin下的emacs-X11。 An X server is needed like XMing or Cygwin/X.需要 X 服务器,例如 XMing 或 Cygwin/X。 A bit slow and heavy.有点慢和沉重。
  3. emacs-w32 under cygwin. cygwin下的emacs-w32。
  4. emacs under windows. windows下的emacs。 You need some configuration to make emacs recognize the cygwin environment.您需要一些配置才能使 emacs 识别 cygwin 环境。 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.我建议将 emacs-w32 与 cygwin 一起使用,它使用本机 Windows GUI,这样您就不必启动 xserver 来运行 emacs,也不需要编写/下载任何棘手的代码来让 emacs 了解 cygwin env 就像其他答案一样。

Just install emacs-w32 and run it from mintty and here you go.只需安装 emacs-w32 并从 mintty 运行它,就可以了。 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 .仅供参考,如果您想“独立”启动 emacs,请使用D:\cygwin\bin\run.exe /usr/bin/bash.exe --login -i -c /usr/bin/emacs-w32.exe编写一个 .bat 文件D:\cygwin\bin\run.exe /usr/bin/bash.exe --login -i -c /usr/bin/emacs-w32.exe在里面,或者像我一样,编写一个 .ahk 脚本以使用热键F12启动 emacs。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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