如何设置emacs,以便在新编译期间浏览以前的编译错误?在新编译期间浏览以前的编译错误?
两件事情不为我工作:
-
当第二编译正在进行
M-克间克(下一个错误)功能无法正常工作。
我有我的emacs分成5个不平坦的窗口(拆分窗口水平),编译“窗口”是两倍的大小(dbl显示器设置)。当我启动编译时,它总是出现在最后一个双编译窗口中。现在它为自己打开一个新窗口。
如何设置emacs,以便在新编译期间浏览以前的编译错误?在新编译期间浏览以前的编译错误?
两件事情不为我工作:
M-克间克(下一个错误)功能无法正常工作。
我有我的emacs分成5个不平坦的窗口(拆分窗口水平),编译“窗口”是两倍的大小(dbl显示器设置)。当我启动编译时,它总是出现在最后一个双编译窗口中。现在它为自己打开一个新窗口。
这是一个有点的未完善,但试试这个:
开始新的编译之前,请保存(写,C-X C-W)当前编译缓冲区中的文件。如果新文件的缓冲区放弃了“编译模式”设置,只需重新打开编译模式(M-x编译模式)即可。
这听起来像一个合理的方法。但我无法手动完成。而且,当新的编译完成时,我希望它覆盖旧的错误列表。也许我们可以修改编译命令以编译到某个临时缓冲区,并在完成后将它移动到\ * compilation \ *中。 –
这里是一个解决方案,这似乎满足您的所有需求:
*compilation-old*
缓冲区始终保持在同一个窗口next-error
不破*compilation-old*
当编译过程终止时(defun my-compilation-finish-function (buffer msg)
;; Don't do anything if we are in a derived mode
(when (with-current-buffer buffer (eq major-mode 'compilation-mode))
;; Insert the last compilation output at the end of *compilation-old*
(if (get-buffer "*compilation-old*")
(with-current-buffer "*compilation-old*"
(save-excursion
(goto-char (point-max))
(insert-buffer buffer)))
(with-current-buffer buffer
(rename-buffer "*compilation-old*")))))
(add-hook 'compilation-finish-functions 'my-compilation-finish-function)
(defadvice compile (around my-compile-show-old activate)
"Show the *compilation-old* buffer after starting the compilation"
(let ((buffer (current-buffer)))
(when (get-buffer "*compilation-old*")
(pop-to-buffer "*compilation-old*")
(switch-to-buffer "*compilation*"))
ad-do-it
(when (get-buffer "*compilation-old*")
(switch-to-buffer "*compilation-old*")
(pop-to-buffer buffer))))
2件事对我不起作用:1.当第二次编译正在进行时,M-g M-g(nex-error)函数不起作用。 2.我将emacs分成5个不平坦窗口(水平分割窗口),编译窗口的大小是双倍大小(dbl moniotr设置)。当我启动编译时,它总是出现在最后一个双编译窗口中。现在它为自己开辟了一扇新窗口。 –
至于问题1,你是否按照内联帮助中描述的方式尝试使用'next-error'?首先在要用作源代码的编译缓冲区中运行'next-error'(在您的情况下为'* compilation-old *'),然后所有连续的'next-error'调用将使用此缓冲区。 – Francesco
对于问题2,我不明白你想在双倍窗口中看到哪个缓冲区;旧的还是跑步的? – Francesco
在编译命令终止时,将以下内容放入init文件中将会将编译缓冲区重命名为*compilation-old*
。
请注意,如果您从旧编译缓冲区中的新编译过程(将在这种情况下,再利用,而不是创建一个新的缓冲,因为compile
)
(defun my-rename-compilation-buffer (buffer message)
;; Don't do anything if we are in a derived mode
(when (with-current-buffer buffer (eq major-mode 'compilation-mode))
(let* ((old-compilation-buffer-name "*compilation-old*")
(old-compilation-buffer (get-buffer old-compilation-buffer-name)))
;; Kill old compilation buffer if necessary
(when old-compilation-buffer
(kill-buffer old-compilation-buffer))
;; Rename the current compilation buffer
(with-current-buffer buffer
(rename-buffer old-compilation-buffer-name)))))
(add-hook 'compilation-finish-functions 'my-rename-compilation-buffer)
仍然是同样的问题:1.(next-error)仅在新窗口中使用编译错误。即使我从第二个旧编译缓冲区执行(下一个错误)。 –
考虑它的可编程的,这是行不通的,答案是肯定的。 –
你能否详细解释一下目前的答案缺乏哪些细节? – Francesco
@Francesco - 忘记添加解释什么不工作 - 在评论中添加到您的答案。 –