问题描述
我正在编写几个辅助函数供我使用.他们首先调用 org-publish-project
,然后在该输出上调用外部脚本.我想在弹出的临时缓冲区中收集执行的所有输出.
I'm writing a couple of helper functions for my use. They first call up org-publish-project
and then call external scripts on that output. I'd like to collect all output from the execution in a temp buffer that pops up.
外部的东西比较容易.函数 shell-command
接受第二个关于将stdout发送到缓冲区的参数.但是 org-publish-project
仅将内容回显到minibuffer,并且在 * Messages *
上显示(如果有的话).我能以某种方式将所有回声重定向到给定的缓冲区吗?
The external stuff is easier. The function shell-command
accepts a second argument about a buffer where to send stdout. But org-publish-project
only echoes stuff to minibuffer and it shows on *Messages*
if anywhere. Could I somehow redirect all echoes to a given buffer?
推荐答案
不,遗憾的是没有这样的重定向.您可以尝试建议 message
功能,该功能将捕获许多这些消息,但不一定捕获所有这些消息.
No, there's no such redirect, sadly. You can try to advise the message
function, which will catch many of those messages, tho not necessarily all of them.
(defvar my-message-output-buffer nil)
(defadvice message (around my-redirect activate)
(if my-message-output-buffer
(with-current-buffer my-message-output-buffer
(insert (apply #'format (ad-get-args 0))))
ad-do-it))
这篇关于如何将消息/回显输出重定向到Emacs中的缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!