我想知道一个善良的elisp专家是否可以写出这个gdb-pounce
fn
将使emacs等待进程启动,获取它的pid,并告诉正在运行
gdb附加到它。该命令应显示“等待'过程'开始......”
并按任意键应该退出该功能。
获取pid是更容易的部分之一:
;; The command which will get the PID
(setq cmd ( format "ps -u %s -o pid,fname | awk '{ if ( \"%s\" == $2 ) print($1)}"
(user-login-name)
binary))
(set maybe_pid (shell-command-to-string cmd) )
需要elisp专家的地方是如何每1秒调用一次,或直到 用户按一个键退出。
提前致谢。
更新: 脚本在这里:https://bitbucket.org/vrdhn/gdb-pounce/raw/master/gdb-pounce.el
答案 0 :(得分:1)
你可以这样做:
(let ((done nil))
(while (and (not done) (not (input-pending-p)))
(if (> (random 10) 7)
(setq done t)
(message "Waiting...")
(sleep-for 1))))
我在这里作为例子进行了random
检查;那是你检查过程的地方。关键部分是input-pending-p
和sleep-for
。