启动make并通过Emacs中的快捷方式转到错误位置

问题描述 投票:1回答:2

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

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

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

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

有谁知道如何编写.emacs来启用此机制?

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

emacs makefile
2个回答
1
投票

M-x compile RET

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


0
投票

几年前,我有同样的问题,这是我在#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)
© www.soinside.com 2019 - 2024. All rights reserved.