【发布时间】:2015-04-22 21:33:16
【问题描述】:
在 Emacs 中,有没有办法捕获 dired-do-shell-command 的标准输出,比如 kill-ring?
不知道怎么做,我最终去了 Messages 缓冲区并从那里手动获取标准输出。
【问题讨论】:
在 Emacs 中,有没有办法捕获 dired-do-shell-command 的标准输出,比如 kill-ring?
不知道怎么做,我最终去了 Messages 缓冲区并从那里手动获取标准输出。
【问题讨论】:
该命令的帮助说明输出到名为*Shell Command Output* 的缓冲区,假设命令没有&。如果是这种情况,这段代码会做你想做的事:
(defun do-shell-and-copy-to-kill-ring (command &optional arg file-list)
(interactive
(let ((files (dired-get-marked-files t current-prefix-arg)))
(list
(dired-read-shell-command "! on %s: " current-prefix-arg files)
current-prefix-arg
files)))
(dired-do-shell-command command arg file-list)
(with-current-buffer "*Shell Command Output*"
(copy-region-as-kill (point-min) (point-max))))
对于异步命令,您需要等待它们并查看*Async Shell Command* 缓冲区。
【讨论】: