如何最好地集成 Emacs 和 Cygwin?

发布于 2024-08-17 16:07:04 字数 654 浏览 5 评论 0原文

在 Windows 上将 Cygwin 与 Emacs 集成的方法有很多。 EmacsWiki 显示了一些想法。以下是我找到的选项:

  1. 使用 Cygwin 附带的 Emacs。 (然后如果需要,找到一种方法来访问 cmd.exe。)
  2. 使用 NTEmacs 和 Cygwin 作为“有时”的 shell。 (启动 Cygwin 的特殊命令)
  3. 使用 NTEmacs 和 Cygwin 作为“始终”shell。 (Mx shell 启动 cygwin)

为了澄清“为什么”。以下是我希望在 Emacs 中使用 Cygwin 的几个示例:

  1. Mx whois 不适用于 NTEmacs。
  2. Wanderlust 这样的包包含一个不适合 Windows 的 Makefile。
  3. 有时我只需要一个 bash shell 来做某事。

那么 Emacs/Cygwin 的哪个选项对其他人来说效果最好呢?另外,有人尝试过MSYS集成成功吗?

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:

  1. Use the Emacs that comes with Cygwin. (Then find a way to get to cmd.exe if you want it.)
  2. Use NTEmacs and Cygwin as a "sometimes" shell. (A special command to launch Cygwin)
  3. Use NTEmacs and Cygwin as the "always" shell. (M-x shell launches cygwin)

To give some clarity as to "why". Here are a couple of examples where I wish I had Cygwin with Emacs:

  1. M-x whois doesn't work on NTEmacs.
  2. Packages like Wanderlust include a Makefile that isn't Windows friendly.
  3. Sometimes I just need a bash shell for something.

So which option of Emacs/Cygwin works well for others? Also, has anyone tried MSYS integration successfully?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

浮生未歇 2024-08-24 16:07:04

在 Cygwin 中使用 Emacs。不是 XEmacs..Emacs。我只需安装 Cygwin 中的所有内容并输入以下内容即可运行 Emacs:

XWin -multiwindow
export DISPLAY=:0.0
emacs&

它也可能有助于创建指向 C 驱动器(或任何其他驱动器)的链接,如下所示:

ln -s /cygdrive/c /c

我已经使用这个几个月了,效果总是很好。我经常使用 TRAMP 和 subversion 等高级功能,没有任何问题。像 cedet 这样的所有高级软件包都可以工作。

如果你没注意到的话,我就是原发帖者。经过我所有的研究和尝试,这个成功了,我非常高兴。干得好西格温!

另外,我建议不要在 Emacs 中使用 shell。像 top 这样的实用程序似乎不起作用。相反,请使用 MinTTY 和屏幕。 Cygwin 直接在 MinTTY 中为您提供 ssh(不需要 putty)。最棒的是我的许多 Linux 知识可以在 Windows 中无缝运行。

Use the Emacs in Cygwin. Not XEmacs..Emacs. I just install everything from Cygwin and type the following to run 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:

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.

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!

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.

花之痕靓丽 2024-08-24 16:07:04

最好的解决方案一定是 cygwin emacs-w32。它使用win32本机gui,并使用cygswin POSIX系统。这意味着您有一个 Windows 本机 gui 程序和所有 cygwin 路径,shell 都可以工作。

安装非常简单:setup.exe --> emacs-w32。
现在版本号是:24.2.93.1

很好。

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.

Installation is very easy: setup.exe --> emacs-w32.
Now the version number is:24.2.93.1

So good.

梦在深巷 2024-08-24 16:07:04

第四种选择是在 Cygwin 的替代终端之一中运行 emacs:(u)rxvt、mintty、xterm。这些都提供了比控制台更好的终端模拟,这意味着 emacs 体验得到了极大的改善。

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.

甜味超标? 2024-08-24 16:07:04

我倾向于将 Windows 上的 emacs 与(也是本机) gnu utils 的端口,比 Cygwin 的端口快得多,但不太完整。

然后我只使用 cygwin 窗口来显示 bash shell 和缺少的东西。

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.

手长情犹 2024-08-24 16:07:04

我在根目录下安装了 cygwin。它明确警告您不要这样做,但我没有看到任何不良影响。 (我从 Steve Yegge 那里找到了这条建议)。

我还安装了 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)
)

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).

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:

;;;;;;;;;;;;;;;;;;;;;;
;;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)
)
娇俏 2024-08-24 16:07:04

我正在使用 wsl2 和 win32 27.1 发行版。我按照此处的说明进行操作: https://www.emacswiki.org/emacs/NTEmacsWithCygwin我所做的唯一更改是:

(let* ((cygwin-root "//wsl$/Ubuntu/")

Ubuntu 是你的发行版。

我还没有正确的 /mnt/c 工作。

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.

一生独一 2024-08-24 16:07:04

我喜欢从 Cygwin 安装程序获得的 xemacs 版本。开箱即用,Alt 键映射到 Meta 就很好,并且 bash shell 缓冲区在您需要时就在那里。

I like the xemacs version that you get from the Cygwin setup program. Works out of the box, the Alt key maps to Meta just fine, and the bash shell buffer is there whenever you need it.

淡写薰衣草的香 2024-08-24 16:07:04

第三个选项。我正在使用 NTEmacs + EmacsW32 + Cygwin。这样我就有了一个带有 Unix 实用程序和 bash shell 的本机 Windows 应用程序。 makefile 可以工作,但我从未使用过 Mx whois 。我想不出这种设置有什么直接的缺点。

以下是我的设置的有趣部分,基本上与 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")

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")
凯凯我们等你回来 2024-08-24 16:07:04

就像@justinhj一样,我在Windows上使用emacs的本机版本与gnu utils的(也是本机的)端口(例如用于“字符串”的binutils等)结合使用。

总是使用 cygwin 作为 shell,无论是在 Emacs 中还是独立于 Emacs。这样,我就可以保留外观和外观。当我切换回来时对我的工作环境的感觉从 Windows 到 Linux/AIX/Solaris。

然而不幸的是,当我将 Emacs 从 21.2 升级到 23.2 时,Emacs 失去了默认识别“/cygwin/c”的能力。我现在必须对此进行研究,看看为什么它不再起作用以及我可以采取什么措施来解决这个问题。我刚刚找到以下信息,我会检查一下是否有帮助。现在我需要一个外部包来存储默认情况下一直存在的东西,这似乎很奇怪:

然而,我更喜欢尽量减少额外软件包的使用。因此,我只是进一步检查了“新”Emacs + Cygwin 的行为,似乎我只需键入“/”即可访问 C: 驱动器。

这很酷 - 只有一个字符(斜杠)而不是 /cygdrive/c。然而,Emacs 中的 shell 会提示“/cygdrive/c”,这是一个有点令人困惑的区别。

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.).

And I always use 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.

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:

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 '/'.

That is cool - only one character (slash) instead of /cygdrive/c. However, the shell within Emacs prompts with '/cygdrive/c', a somewhat confusing difference.

初见 2024-08-24 16:07:04

我研究了三个选项,所有选项都使用窗口(但不是 X11)版本的 Emacs。 (终端对我来说太硬核了。) 这里是:

  1. Cygwin 附带的 XEmacs
  2. EmacsW32
  3. Windows 的标准 Emacs

Cygwin 人员希望引导您使用他们的 Emacs/XEmacs。在 http://cygwin.com/faq/faq-nochunks.html# faq.using.ntemacs,他们写道“请注意,如果您使用 Cygwin 安装程序中的 Emacs 或 XEmacs 的 Cygwin 端口,所有这些都‘正常工作’”。

除了xemacs之外,一定要安装xemacs-sumo包;否则 Mx shell 将无法工作。您可以在不使用 X11 的情况下启动 xemacs,但

DISPLAY= xemacs &

缺点是:1)天哪,这是一个 Emacs。当其他人都在使用 Emacs 23 时,我真的不想坚持下去。2)我发现有点烦人的是,即使您没有运行 X11,安装也需要一大堆 X11 库。 3)没有开箱即用的cua模式。

EmacsW32 (http://ourcomments.org/Emacs/EmacsW32.html) 具有一键安装程序、Mx cygwin-shell 命令和 CUA 模式。但 Cygwin shell 中的制表符补全使用 Windows 路径,这让我抓狂。自 2008 年以来,W32 端口似乎没有得到积极改进,但它们为安装程序提供了更新的 Emacs 版本。

适用于 Windows 的标准 Emacs 似乎是最好的选择。从 http://ftp.gnu.org/pub/gnu/emacs/windows/ 下载,解压并从 Cygwin 内部启动。然后它会选择主目录等。从 http: 粘贴 mumbo-jumbo: //cygwin.com/faq/faq-nochunks.html#faq.using.ntemacs 进入 ~/.emacs。重新启动 Emacs 并运行 Mx shell。一切都按预期进行。

I investigated three options, all with windowed (but not X11) versions of Emacs. (The terminal is too hardcore for me.) Here goes:

  1. The XEmacs that comes with Cygwin
  2. EmacsW32
  3. Standard Emacs for Windows

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.

记忆里有你的影子 2024-08-24 16:07:04

FWIW,我使用普通的 GNU Emacs Windows 版本,并且使用 Cygwin。我从来没有遇到过任何问题,但除了 Emacs 之外,我并没有太多使用 Cygwin 的事情。哦,我正在使用旧版本的 Cygwin(以及所有版本的 Emacs)。

对于设置,我按顺序加载这两个文件:

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).

For setup, I load these two files, in order:

歌枕肩 2024-08-24 16:07:04

从源代码构建 emacs:

-下载最新的稳定版本 (24.5截至撰写本文时)。

- 解压并 cd 到 emacs 文件夹

- 按顺序运行以下步骤:

$ ./autogen.sh
$ ./configure --with-w32
$ make
$ make install

- 手动将 emacs.exe 从“emacs 文件夹”/src 复制到 cygwin/bin

- 运行 emacs:

$ emacs&

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&

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文