Emacs Lisp:在函数返回之前使新创建的缓冲区可见?
在 emacs Lisp 的以下函数中,
(defun show-life ()
(interactive)
(switch-to-buffer "*Life-Window*") ; show how life goes on while living
(live)) ; it takes 70 years to finish and return!
我想创建缓冲区“Life-Window”,并在 live 进行时连续显示 (live) 生成的生命事件。
不幸的是,缓冲区仅在(实时)返回后才可见(当它结束时!)
我也尝试了弹出到缓冲区,行为是相同的。
In the following function in emacs Lisp,
(defun show-life ()
(interactive)
(switch-to-buffer "*Life-Window*") ; show how life goes on while living
(live)) ; it takes 70 years to finish and return!
I'd like to create the buffer "Life-Window", and have the life event generated by (live) displayed continuously while live goes on.
Unfortunately, the buffer only becomes visible after the (live) returns (when it's over!)
I also tried pop-to-buffer, the behavior is the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在调用
'live
之前添加对'sit-for
的调用,例如,如果您想查看
'live
的结果,它也应该定期调用'sit-for
。'sit-for
的文档字符串是:Add a call to
'sit-for
just before the call to'live
, e.g.And, if you want to see the results of
'live
, it should periodically call'sit-for
as well.The doc string for
'sit-for
is:我找到了解决办法。 我必须使用
(sit-for)
来获取缓冲区以显示生活事件的更新。因此代码段应该修改如下:
也许在
live
主体内部,应该定期调用sit-for
。I found out the solution. I have to use
(sit-for <time-to-wait>)
to get the buffer to show the update of life events.So the code segment should be modified as follows:
Maybe inside of the
live
body,sit-for
should be called periodically.