您如何控制 Emacs Lisp shell 命令的输出 window?

How do you control the output window of an Emacs Lisp shell command?

给出这样的东西:

(global-set-key (kbd "<f4>") (lambda () (interactive) (shell-command "gcc --version")))

有没有办法让输出始终进入 "new or existing window on the right" 而不是有时这样做,有时将输出放在状态和命令区域下方 window 一点(两个不同的可能性如下所示)?

以下对于一行输出也可靠(例如 "echo hello" 而不是 "gcc --version"):

(global-set-key (kbd "<f4>")
                (lambda () (interactive)
                   (with-current-buffer (get-buffer-create "*Shell Command Output*")
                     (erase-buffer)
                     (insert (shell-command-to-string "gcc --version"))
                     (display-buffer (current-buffer)))))