bash 如何最好地集成 Emacs 和 Cygwin?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2075504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to best integrate Emacs and Cygwin?
提问by User1
There are a ton of ways to integrate Cygwin with Emacs on Windows. EmacsWikishows a few ideas. Here are the options that I've found:
有很多方法可以将 Cygwin 与 Windows 上的 Emacs 集成。 EmacsWiki展示了一些想法。以下是我找到的选项:
- Use the Emacs that comes with Cygwin. (Then find a way to get to cmd.exe if you want it.)
- Use NTEmacs and Cygwin as a "sometimes" shell. (A special command to launch Cygwin)
- Use NTEmacs and Cygwin as the "always" shell. (M-x shell launches cygwin)
- 使用 Cygwin 附带的 Emacs。(然后找到一种方法来访问 cmd.exe,如果需要的话。)
- 使用 NTEmacs 和 Cygwin 作为“有时”外壳。(启动 Cygwin 的特殊命令)
- 使用 NTEmacs 和 Cygwin 作为“始终”外壳。(Mx shell 启动 cygwin)
To give some clarity as to "why". Here are a couple of examples where I wish I had Cygwin with Emacs:
明确说明“为什么”。下面是一些我希望 Cygwin 和 Emacs 一起使用的示例:
- M-x whois doesn't work on NTEmacs.
- Packages like Wanderlustinclude a Makefile that isn't Windows friendly.
- Sometimes I just need a bash shell for something.
- Mx whois 不适用于 NTEmacs。
- 像Wanderlust这样的软件包包含一个对 Windows 不友好的 Makefile。
- 有时我只需要一个 bash shell 来做某事。
So which option of Emacs/Cygwin works well for others? Also, has anyone tried MSYS integration successfully?
那么 Emacs/Cygwin 的哪个选项对其他人来说效果很好?另外,有没有人成功尝试过 MSYS 集成?
采纳答案by User1
Use the Emacs in Cygwin. Not XEmacs..Emacs. I just install everything from Cygwin and type the following to run Emacs:
在 Cygwin 中使用 Emacs。不是 XEmacs..Emacs。我只是从 Cygwin 安装所有东西并输入以下内容来运行 Emacs:
XWin -multiwindow export DISPLAY=:0.0 emacs&
It may also help to create a link to your C drive (or any other drive) like so:
创建指向 C 驱动器(或任何其他驱动器)的链接也可能会有所帮助,如下所示:
ln -s /cygdrive/c /c
ln -s /cygdrive/c /c
I've been using this for several months and it always works well. I constantly use advanced features like TRAMP and subversion without any issues. All advanced packages like cedet just work.
我已经使用它几个月了,它总是很好用。我经常使用 TRAMP 和 subversion 等高级功能,没有任何问题。所有像 cedet 这样的高级软件包都可以工作。
If you hadn't noticed, I am the original poster. After all of my research and attempts, this one worked and I am VERY PLEASED. Good job Cygwin!
如果你没有注意到,我是原始海报。经过我所有的研究和尝试,这个成功了,我很高兴。Cygwin 干得好!
Also, I recommend not using shell within Emacs. Utilities like top
just don't seem to work. Instead, use MinTTY and screen. Cygwin gives you ssh directly in MinTTY (you don't need putty). The best part is that a lot of my Linux knowledge works seamlessly in Windows.
另外,我建议不要在 Emacs 中使用 shell。像top
这样的实用程序似乎不起作用。相反,使用 MinTTY 和屏幕。Cygwin 直接在 MinTTY 中为您提供 ssh(您不需要腻子)。最好的部分是我的很多 Linux 知识可以在 Windows 中无缝运行。
回答by Mingo
The best solution must be cygwin emacs-w32. It using win32 native gui, and using cygswin POSIX system. That means you have a windows native gui program and all the cygwin path, shell working.
最佳解决方案必须是 cygwin emacs-w32。它使用win32本机gui,并使用cygswin POSIX系统。这意味着您有一个 Windows 本机 gui 程序和所有 cygwin 路径,shell 工作。
Installation is very easy: setup.exe --> emacs-w32. Now the version number is:24.2.93.1
安装非常简单:setup.exe --> emacs-w32。现在版本号是:24.2.93.1
So good.
超好的。
回答by ak.
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.
第四种选择是在 Cygwin 的替代终端之一中运行 emacs:(u)rxvt、mintty、xterm。这些都提供了比控制台更好的终端仿真,这意味着 emacs 体验大大改善。
回答by justinhj
I tend to use the native version of emacs on windowsin conjunction with the (also native) ports of gnu utils, which are much faster, though less complete, than the Cygwin ones.
我倾向于在 windows 上使用原生版本的emacs和gnu utils的(也是原生的)端口,它们比 Cygwin 快得多,但不完整。
Then I just use a cygwin window for the bash shell and the things that are missing.
然后我只为 bash shell 和缺少的东西使用 cygwin 窗口。
回答by Jonathan Arkell
I installed cygwin on the root. It explicitly warns you against it, but I saw no ill effects. (I found that piece of advice from Steve Yegge).
我在根目录上安装了 cygwin。它明确警告您不要这样做,但我没有看到任何不良影响。(我从 Steve Yegge 那里找到了这条建议)。
I also installed cygwin-mount, which helps a bunch. Also, I had to switch from ispell to aspell. Finally, a little bit of .emacs tweaking, and I was good to go:
我还安装了cygwin-mount,这对很多人都有帮助。另外,我不得不从 ispell 切换到 aspell。最后,对 .emacs 进行了一些调整,我很高兴:
;;;;;;;;;;;;;;;;;;;;;;
;;CygForTheWin
;;*cygwin
(when (equal system-type 'windows-nt)
(message "Setting up Cygwin...")
(let* ((cygwin-root "c:")
(cygwin-bin (concat cygwin-root "/bin"))
(gambit-bin "/usr/local/Gambit-C/4.0b22/bin/")
(snow-bin "/usr/local/snow/current/bin")
(mysql-bin "/wamp/bin/mysql/mysql5.0.51a/bin/"))
(setenv "PATH" (concat cygwin-bin ";" ;
snow-bin ";"
gambit-bin ";"
mysql-bin ";"
"c:/usr/local/jdk1.60_03/bin/"
".;")
(getenv "PATH"))
(setq exec-path (cons cygwin-bin exec-path)))
(require 'cygwin-mount)
(cygwin-mount-activate)
(setq shell-file-name "bash")
(setq explicit-shell-file-name "bash")
(defun jonnay-cygwin-shell ()
"Wrapper around cygwin-shell so that it doesn't throw an error"
(interactive)
(condition-case e
(cygwin-shell)
(message "There was an error trying to launch the shell: %s" e)))
(message "Setting up Cygwin...Done")
;; found from the manual, check, use and make go?
(defun my-shell-setup ()
"For Cygwin bash under Emacs 20"
(setq comint-scroll-show-maximum-output 'this)
(setq comint-completion-addsuffix t)
(setq comint-eol-on-send t)
(setq w32-quote-process-args ?\")
(make-variable-buffer-local 'comint-completion-addsuffix))
(setq shell-mode-hook 'my-shell-setup)
(add-hook 'emacs-startup-hook 'jonnay-cygwin-shell)
)
回答by Android Eve
Just like @justinhj, I use the native version of emacs on windows in conjunction with the (also native) ports of gnu utils (e.g. binutils for 'strings', etc.).
就像@justinhj 一样,我在 Windows 上使用本机版本的 emacs 与 gnu utils 的(也是本机)端口(例如用于“字符串”等的 binutils)。
And I alwaysuse cygwin as the shell, within Emacs or independently of Emacs. That way, I retain the look & feel of my work environment when I switch back & forth from Windows to/from Linux/AIX/Solaris.
我总是在 Emacs 中或独立于 Emacs 使用 cygwin 作为 shell。这样,当我在 Windows 和 Linux/AIX/Solaris 之间来回切换时,我会保留工作环境的外观和感觉。
Unfortunately however, when I upgraded my Emacs from 21.2 to 23.2, Emacs lost its ability to recognize '/cygwin/c' by default. I have to research this now to see why it isn't working anymore and what I can do to fix that. I just found the following information and I'll check it out to see whether this is helpful. It seems odd that now that I need an external package for something that used to be always there by default:
然而不幸的是,当我将 Emacs 从 21.2 升级到 23.2 时,Emacs 在默认情况下失去了识别“/cygwin/c”的能力。我现在必须研究这个,看看为什么它不再起作用,以及我能做些什么来解决这个问题。我刚刚找到了以下信息,我会检查一下,看看这是否有帮助。现在我需要一个外部包来处理过去默认情况下总是存在的东西,这似乎很奇怪:
I prefer, however, to minimize the use of additional packages. So, I just checked further the behavior of my "new" Emacs + Cygwin and it seems that I can access the C: drive by simply typing '/'.
然而,我更喜欢尽量减少使用额外的包。所以,我只是进一步检查了我的“新”Emacs + Cygwin 的行为,似乎我可以通过简单地输入“/”来访问 C: 驱动器。
That is cool - only one character (slash) instead of /cygdrive/c. However, the shell within Emacs prompts with '/cygdrive/c', a somewhat confusing difference.
这很酷 - 只有一个字符(斜杠)而不是 /cygdrive/c。然而,Emacs 中的 shell 提示'/cygdrive/c',这是一个有点令人困惑的区别。
回答by mob
I like the xemacs
version that you get from the Cygwin setup program. Works out of the box, the Altkey maps to Metajust fine, and the bash shell buffer is there whenever you need it.
我喜欢xemacs
您从 Cygwin 安装程序获得的版本。开箱即用,Alt键映射得Meta很好,bash shell 缓冲区在您需要时随时可用。
回答by Laurynas Biveinis
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.
第三种选择。我正在使用 NTEmacs + EmacsW32 + Cygwin。这样我就有了一个带有 Unix 实用程序和 bash shell 的本机 Windows 应用程序。生成文件有效,但我从未使用过M-x whois
。我想不出这种设置有任何直接的缺点。
Here are interesting bits of my setup, basically very similar to http://www.emacswiki.org/emacs/NTEmacsWithCygwin:
这是我的设置中有趣的部分,基本上与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")
回答by Drew
FWIW, I use the normal GNU Emacs Windows releases, and I use Cygwin. I've never had any problems, but I don't do much with Cygwin outside Emacs. Oh, and I'm using an old version of Cygwin (with all versions of Emacs).
FWIW,我使用普通的 GNU Emacs Windows 版本,我使用 Cygwin。我从来没有遇到过任何问题,但我在 Emacs 之外对 Cygwin 没有做太多事情。哦,我使用的是旧版本的 Cygwin(所有版本的 Emacs)。
For setup, I load these two files, in order:
对于设置,我按顺序加载这两个文件:
回答by cayhorstmann
I investigated three options, all with windowed (but not X11) versions of Emacs. (The terminal is too hardcore for me.) Here goes:
我研究了三个选项,所有选项都使用窗口化(但不是 X11)版本的 Emacs。(终端对我来说太硬核了。)这里是:
- The XEmacs that comes with Cygwin
- EmacsW32
- Standard Emacs for Windows
- Cygwin 附带的 XEmacs
- EmacsW32
- 适用于 Windows 的标准 Emacs
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".
Cygwin 人员希望引导您使用他们的 Emacs/XEmacs。在http://cygwin.com/faq/faq-nochunks.html#faq.using.ntemacs 中,他们写道“请注意,如果您使用 Cygwin 安装程序中的 Emacs 或 XEmacs 的 Cygwin 端口,所有这些都可以正常工作” ”。
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
除了 xemacs 外,一定要安装 xemacs-sumo 包;否则 Mx shell 将无法工作。您可以在不使用 X11 的情况下启动 xemacs
DISPLAY= xemacs &
Drawbacks: 1) Boy, this is an oldEmacs. 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.
缺点: 1)男孩,这是一个旧的Emacs。当其他人都在使用 Emacs 23 时,我真的不想坚持下去。 2) 我发现即使您没有运行 X11,安装也需要一大堆 X11 库,这有点烦人。3) 没有开箱即用的 cua 模式。
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.
EmacsW32 (http://ourcomments.org/Emacs/EmacsW32.html) 具有一键安装程序、Mx cygwin-shell 命令和 CUA 模式。但是 Cygwin shell 中的选项卡完成使用 Windows 路径,这让我发疯了。自 2008 年以来,W32 端口似乎没有得到积极改进,但它们为安装程序提供了更新的 Emacs 版本。
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.ntemacsinto ~/.emacs. Restart Emacs and run M-x shell. All works as expected.
Windows 的标准 Emacs 似乎是最好的选择。从http://ftp.gnu.org/pub/gnu/emacs/windows/下载,解压缩,然后从 Cygwin 内部启动。然后它选择主目录等。将来自http://cygwin.com/faq/faq-nochunks.html#faq.using.ntemacs的 mumbo-jumbo 粘贴到 ~/.emacs 中。重新启动 Emacs 并运行 Mx shell。一切都按预期工作。