创建 Cygwin emacs 宏

发布于 2024-08-09 07:39:42 字数 721 浏览 5 评论 0原文

我一直在研究如何让 Cygwin 在 emacs 下工作。我已经让它工作了,但现在我想编写一个宏来执行以下操作:

  • 通过键入 Mx cygwin 启动
  • 将脚本存储在某个明显的位置(可能是我的 .emacs 文件)
  • Mx shell
  • 将缓冲区重命名为 cygwin (或 cygwin1, cygwin2,cygwin3,...如果 cygwin 存在)可能使用 Mx rename-buffer
  • M-x ansi-color-for-comint-mode-on
  • M-x set-buffer-process-coding-system 'undecided-unix 'undecided-unix
  • 打开并运行cygwin

基本上会完成以上所有步骤。我认为这个小项目的大部分组织工作已经完成。我如何将它们结合在一起,以便我只需输入 Mx cygwin 就可以看到一个令人愉快的新 cygwin 缓冲区?到底需要将什么添加到 .emacs 中?另外,Windows 中的 .emacs 到底在哪里?

我现在仍然希望能够为 Windows shell 运行 Mx shell。我还可以为 MSYS 和 ssh 到我的 Linux 机器制作类似的宏。我该如何开始?

I have been researching how to get Cygwin to work under emacs. I have it working, but now I want to write a macro that will do the following:

  • Launch by typing M-x cygwin
  • Have the script stored in some obvious place (probably my .emacs file)
  • M-x shell
  • Rename the buffer to cygwin (or cygwin1, cygwin2, cygwin3, ... if cygwin exists) probably using M-x rename-buffer
  • M-x ansi-color-for-comint-mode-on
  • M-x set-buffer-process-coding-system 'undecided-unix 'undecided-unix
  • Open and run cygwin

It will basically do all of the above steps. I think most of the organization for this little project is done. How do I tie it all together so I can just type M-x cygwin and see a happy new cygwin buffer? What exactly needs to be added to .emacs? Also, where exactly is .emacs in Windows?

I still want the ability to run M-x shell for the windows shell for now. I may also make similar macros for MSYS and ssh'ing to my Linux boxes. How do I get started?

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

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

发布评论

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

评论(1

瞎闹 2024-08-16 07:39:42

很多问题,这里有一些答案:

您的 .emacs 可以存在很多地方,这取决于情况,请阅读此处。简而言之,尝试 Cx Cf .emacs,或检查变量 'user-init-file 的值 (Ch v user-init-file )。

我认为您想要的命令大致如下:

(require 'comint) ; this does require comint
(defun cygwin ()
  "do what i want for cygwin"
  (interactive)
  (let ((buffer (get-buffer-create (generate-new-buffer-name "cygwin"))))
    (pop-to-buffer buffer)
    (unless (comint-check-proc buffer)
      (apply 'make-comint-in-buffer (buffer-name buffer) buffer "c:/cygwin/Cygwin.bat"
             nil
             nil)
      (ansi-color-for-comint-mode-on)
      (set-buffer-process-coding-system 'undecided-unix 'undecided-unix))))

注意:我直接运行了进程Cygwin.bat,而不是运行 shell 然后启动该批处理程序。我相信效果是一样的,而且更直接。我确实选择了命名缓冲区的简单方法(使用'generate-new-buffer-name) - 您需要自定义您想要的内容。

您可以通过执行 Cx Cf .emacs 并将其粘贴到打开的缓冲区中,最简单地将上述命令转储到 .emacs 中。保存并重新启动(或者当光标位于该命令正文时执行 Mx eval-defun 。然后 Mx cygwin 将运行该命令。

Many questions, here are some answers:

Your .emacs can exist many places, it depends, read here. In short try C-x C-f .emacs, or check the value of the variable 'user-init-file (C-h v user-init-file).

I think the command you want is something along the lines of this:

(require 'comint) ; this does require comint
(defun cygwin ()
  "do what i want for cygwin"
  (interactive)
  (let ((buffer (get-buffer-create (generate-new-buffer-name "cygwin"))))
    (pop-to-buffer buffer)
    (unless (comint-check-proc buffer)
      (apply 'make-comint-in-buffer (buffer-name buffer) buffer "c:/cygwin/Cygwin.bat"
             nil
             nil)
      (ansi-color-for-comint-mode-on)
      (set-buffer-process-coding-system 'undecided-unix 'undecided-unix))))

Note: I directly ran the process Cygwin.bat instead of running shell and then starting that batch program. I believe the effect is the same, and more straight forward. I did choose the easy way out for naming the buffer (using 'generate-new-buffer-name) - you'll want to customize to what you want.

You can dump the above command in your .emacs easiest by doing the C-x C-f .emacs and pasting it in the buffer that gets opened up. Save it and restart (or do M-x eval-defun when your cursor is in the body of that command. Then M-x cygwin will run the command.

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