我正在寻找一种创建缓冲区并立即隐藏它的方法。它是技术信息的缓冲区,用户不感兴趣,它用于shell-command
处理输出。
kill-buffer
- 不是我需要的,因为我需要那个缓冲区才能生效。
delete-window
- 也不这样做,因为没有办法确定缓冲区的打开方式(它可能会创建一个新窗口或接管另一个窗口)。
如果我在将缓冲区提供给之前创建缓冲区并没有帮助shell-command
,无论它之前是否存在,它都会将它带到前面,如果在它执行此操作时只有一个窗口,它将创建一个额外的窗口,但是如果有更多的窗口,那么它基本上会做一些随机的事情。有时它会创建一个新窗口……有时它不会。
编辑:
下面的例子说明了这个问题:
(defun haxe-start-waiting-server (&optional compiler host port)
"Starts Haxe `haxe-compiler' on `haxe-server-host':`haxe-server-port'
with \"--wait\" for the future requests made by autocompletion
or flymake.
This function is bound to \\[haxe-start-waiting-server]"
(interactive
(let ((compiler-i
(read-string "Haxe compiler: "
haxe-compiler t haxe-compiler))
(host-i
(read-string "Haxe server host: "
haxe-server-host t haxe-server-host))
(port-i
(read-number "Haxe server port: " haxe-server-port)))
(list compiler-i host-i port-i)))
(unless (called-interactively-p 'interactive)
(unless compiler (setq compiler haxe-compiler))
(unless host (setq compiler haxe-server-host))
(unless port (setq compiler haxe-server-port)))
(save-excursion
(let ((new-buffer
(get-buffer-create
(generate-new-buffer-name
" *haxe-waiting-server*"))))
(async-shell-command
(concat compiler " --wait "
host ":" (number-to-string port))
new-buffer)
(bury-buffer new-buffer))))