我一直在尝试调用绑定到shell-command-on-region
的交互式lisp函数M-|
。我想知道如果我想重定向命令的输出,我应该如何指定名为OUTPUT-BUFFER
的第4个参数?
我的环境:MS Windows中的'Emacs25.2 + spacemacs'。
答案 0 :(得分:0)
试试这个。我所做的就是从interactive
复制shell-command-on-region
规范,并将参数OUTPUT-BUFFER
的前缀arg替换为您输入的缓冲区名称。
(defun foo (start end command
&optional output-buffer replace error-buffer display-error-buffer)
(interactive
(let (string buffer)
(unless (mark)
(error "The mark is not set now, so there is no region"))
(setq string (read-shell-command "Shell command on region: ")
buffer (read-buffer "Output buffer: "))
(list (region-beginning) (region-end) string buffer
current-prefix-arg shell-command-default-error-buffer t)))
(shell-command-on-region start end command output-buffer
replace error-buffer display-error-buffer))