【问题标题】:Launch make and go to the error position by shortcuts within Emacs启动 make 并通过 Emacs 中的快捷方式转到错误位置
【发布时间】:2016-04-10 01:28:05
【问题描述】:

我使用 Emacs 编写代码。目前,要编译 OCaml 项目,我需要在终端中输入 make。如果出现错误,我必须按照错误指示返回 Emacs 找到错误的文件和位置。

现在,我想通过键盘快捷键在 Emacs 中启动make,这会打开一个缓冲区来显示编译,然后

1) 如果没有错误,则自动关闭缓冲区

2) 如果出现错误,另一个快捷方式会引导我进入 Emacs 中的错误文件和行。

有人知道如何写.emacs 来启用这个机制吗?

PS:这是我目前的.emacs。 我已经发布了question 来通过快捷方式(Ctrl + c + m + m)在 Emacs 中编译一个 .tex 文件,这很好用。但万一出现错误,我不要求它引导我到错误位置。

【问题讨论】:

标签: emacs makefile


【解决方案1】:

M-x compile RET

参见 Emacs 手册,节点 Compilation。 并查看节点Compilation Mode了解如何访问错误发生。

【讨论】:

    【解决方案2】:

    几年前,我也有同样的问题,这是我在#emacs irc 频道上得到的答案。

    ;; from enberg on #emacs
    (setq compilation-finish-function
      (lambda (buf str)
    (if (null (string-match ".*exited abnormally.*" str))
        ;;no errors, make the compilation window go away in a few seconds
        (progn
          (run-at-time
           "2 sec" nil 'delete-windows-on
           (get-buffer-create "*compilation*"))
          (message "No Compilation Errors!")))))
    ;; save the file when I press compile
    (setq mode-compile-always-save-buffer-p t)
    

    【讨论】:

      猜你喜欢
      • 2014-05-31
      • 2013-01-20
      • 1970-01-01
      • 2011-10-23
      • 1970-01-01
      • 2019-04-14
      • 1970-01-01
      • 2016-07-19
      • 2017-05-10
      相关资源
      最近更新 更多