问题描述
|
我已经开始通过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)))))
解决方法
我想我也许可以通过稍微多一点的挖掘就可以回答我自己的问题,但是第一个gdb解决方案宁可在旧的学习前沿将其从我身上剔除。我恢复了,所以..
-
C-s专业
经过一点滚动后,我们可以将\'comint-send-input \'识别为绑定到键''enter \'的函数。查看此函数的来源,comint.el:1765是对\'run-hook-with-args \'的调用。.这是我们意识到没有地方专门执行'pdb \'的地方我们想要的。
gud是通用包装程序,用于调用外部调试过程并返回结果。因此elisp中没有控件。与gdb相同,但是在外部调用周围有一个很好的(预先存在的)包装器,这使该函数的使用感觉“干净”。
因此,“ comint-send-input \”上方的hack ..“ 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))))
..并在调试缓冲区被杀死时写入历史文件
(add-hook \'kill-buffer-hook \'comint-write-input-ring)
干杯。