Search code examples
bashemacscompile-mode

emacs compilation: call a script in background


I have a script (let's call it ding) which plays a sound in the background (essentially just calls paplay <file> &). I wish to call this from emacs after I finish compiling something, like so:

M-x compile, make && ding

Unfortunately because paplay is called in the background, nothing happens (no sound is played). If I remove the & from ding, the sound is played just fine.

Why does this happen, and is there a way to get a script to execute in the background in compilation mode (without making it a foreground job)?


Solution

  • Emacs will close the commands' output when the commands finish, and chances are paplay doesn't like that. Try nohup paplay ... &