4

When I give a new async command with an interactively called async-shell-command, it gives a message "A command is running in the default buffer. Use a new buffer? (y or n)". I think this behaviour is unnecessary, every time I'm giving a new command, I'll press y. Can I disable this behavior in some way?

1 Answers1

6

You may be interested in creating a new/modified function of shell-command that does not seek confirmation. You may also be interested in customizing the variable async-shell-command-buffer. For a listing of the options, type M-x describe-variable or C-h v.

To see how this variable works within the function shell-command, type M-x find-function RET shell-command RET.

How did I find this out? I typed M-x find-function RET async-shell-command-buffer RET and I did a word search in that library for "a command is running". There are other methods to find this stuff out, like reading the manual that probably discusses the above-variable ... however, I usually just examine the code to figure stuff out.

lawlist
  • 18,826
  • 5
  • 37
  • 118
  • I didn't know about find-function! answers like yours really help me do my research before coming here, so thank you for that. – mangelmentmanager Apr 22 '18 at 17:39
  • I had this issue, too, and customizing `async-shell-command-buffer` did exactly what I needed. Thanks. – Chris May 10 '18 at 14:47
  • You may want to mention that this user option is documented under [`(emacs) Single Shell`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Single-Shell.html). – Basil May 10 '18 at 14:54
  • Thans for adding the How bit. I suppose you did `M-x find-function RET shell-command RET` rather than `async-shell-command-buffer`. – AstroFloyd Oct 06 '19 at 08:22