我已经开始在emacs 23.3中通过gud使用pdb了,我怎样才能钩住从缓冲区发送到调试器的命令消息呢?我写了下面的建议用于gdb,以便持久化comint的环,但找不到一个等效的函数来挂钩pdb。我使用python-mode.el作为我的主要模式。
谢谢。
(defadvice gdb-send-item (before gdb-save-history first nil activate)
"write input ring on quit"
(if (equal (type-of item) 'string) ; avoid problems with 'unprintable' structures sent to this function..
(if (string-match "^q\\(u\\|ui\\|uit\\)?$" item)
(progn (comint-write-input-ring)
(message "history file '%s' written" comint-input-ring-file-name)))))发布于 2011-07-18 01:59:09
我想我当时可能只需要再深入一点就可以回答我自己的问题,但是第一个gdb解决方案让我在旧的学习战线上失去了它。我恢复了,所以..。
C-h b C-s大调
经过一些滚动,我们可以确定'comint-send-input‘是绑定到'enter’键的函数。看一下这个函数的源代码,comint.el:1765是对'run-hook-with-args‘的调用,而..this是我们意识到没有地方特别'pdb’来做我们想要做的事情。
gud是一个通用的包装器,用于调用外部调试进程并返回结果。..hence控件在elisp中是不存在的。gdb也是一样,但是外部调用有一个很好的(预先存在的)包装器,这使得通知函数感觉很“干净”。
所以黑客..。就在'comint-send-input‘的上方是'comint-add-to-input-history'..非常简单。
;;save command history
(defadvice comint-add-to-input-history (before pdb-save-history activate compile)
"write input ring on exit"
(message "%s" cmd)
(if (string-match "^e\\(x\\|xi\\|xit\\)?$" cmd)
(progn (comint-write-input-ring)
(message "history file '%s' written" comint-input-ring-file-name)))
)仅供参考,我用它们来启动调试会话的输入环
;#debugger history
(defun debug-history-ring (file)
(comint-read-input-ring t)
(setq comint-input-ring-file-name file)
(setq comint-input-ring-size 1000)
(setq comint-input-ignoredups t))
(let ((hooks '((gdb-mode-hook . (lambda () (debug-history-ring "~/.gdbhist")))
(pdb-mode-hook . (lambda () (debug-history-ring "~/.pythonhist"))))))
(dolist (hook hooks) (print (cdr hook)) (add-hook (car hook) (cdr hook))))在取消调试缓冲区时写入历史文件的..and
(add-hook 'kill-buffer-hook 'comint-write-input-ring)干杯。
https://stackoverflow.com/questions/6257758
复制相似问题