如何使光标始终跳转到Emacs gdb的point-max?

时间:2013-07-04 09:44:08

标签: debugging emacs gdb elisp

使用gdb-mi在Emacs中进行调试时,*gud-xxx*窗口中的光标始终无法跳转到point-max,然后我会按照其他设置进行操作,并在下面进行一些advice:< / p>

(defun hack-gud-mode ()
  (when (string= major-mode "gud-mode")
    (goto-char (point-max))))

(defadvice switch-to-buffer (after switch-to-buffer-after activate)
  (hack-gud-mode))

(defadvice comint-send-input (after comint-send-input-after activate)
  (hack-gud-mode))

(defadvice windmove-do-window-select (after windmove-do-window-select-after activate)
  (hack-gud-mode))


(defadvice gud-call (after gud-call-select-after activate)
  (hack-gud-mode))

但问题仍然存在:当我点击一些gdb命令并按 Ret comint-send-input )时,仍无法保证光标会跳转。另外我觉得添加这么多建议功能太令人沮丧了。有没有更好的设置呢?

2 个答案:

答案 0 :(得分:1)

我无法百分百肯定(因为我的gdb工作正常),但我会通过添加类似

之类的东西来改变你的hack-gud模式进行实验
(run-with-timer 0.25 nil (lambda () (goto-char (point-max))))

由于emacs将内容发送到底层进程和emacs获得响应之间存在小的延迟。只有comint-send-input才需要建议,如果可行的话

(但是,我想知道你问题的根本原因)

答案 1 :(得分:1)

(严格来说,为了完成,我在这里写的是@assem在评论中提出的内容。)

每次输入内容时,

comint-scroll-to-bottom-on-input都会滚动comint缓冲区 comint-scroll-to-bottom-on-output滚动缓冲区和输出(这可能是最相关的)。

您应该使用以下内容将它们设置为t

(setq comint-scroll-to-bottom-on-input t)
(setq comint-scroll-to-bottom-on-output t)

您可能还想将comint-scroll-to-bottom-on-output设置为'others而不是t。这样,只有缓冲区当前没有被聚焦时才会滚动。