Every programmer—at least every programmer who actually programs—is familiar with the concept of flow. It’s a well established concept with lots of research to back it up even if some don’t believe in it.
The trouble is, there are lots of people who are completely unfamiliar with the idea and think nothing of interrupting a programmer for the most trivial of reasons. What to do? Some programmers have the convention that they’re not to be interrupted if they have earphones on. Others put up signs or other indications that they’re working and should not be bothered. The problem with these schemes is that the programmer has to remember to invoke them and then disable them when done.
Enter Shae Erisson. He’s developed an automatic signaling system that turns on a “Busy” sign when he’s typing into Emacs. When he stops typing, the sign changes to “Free”. It’s not foolproof, of course, because some psychopaths just won’t care and will interrupt you anyway believing that their needs, however inconsequential, take precedence over your need for focus. Still, it’s a good beginning.
The only special part of this is a magtag from Adafruit. It’s a cheap bit of kit that’s easy to program. You can see the code that Erisson used at his post. There’s code for Emacs—to detect typing—and code for the magtag to display the results.
If you work in an environment where people feel free to interrupt you for the most trivial of reasons, perhaps this will help. Take a look at Erisson’s post to see if his ideas will help you.