Next: , Previous: , Up: Minibuffers   [Contents][Index]

21.14 Inhibiting Interaction

It’s sometimes useful to be able to run Emacs as a headless server process that responds to commands given over a network connection. However, Emacs is primarily a platform for interactive usage, so many commands prompt the user for feedback in certain anomalous situations. This makes this use case more difficult, since the server process will just hang waiting for user input.

Binding the inhibit-interaction variable to something non-nil makes Emacs signal a inhibited-interaction error instead of prompting, which can then be used by the server process to handle these situations.

Here’s a typical use case:

(let ((inhibit-interaction t))
   (condition-case err
     (inhibited-interaction err))))

If my-client-handling-function ends up calling something that asks the user for something (via y-or-n-p or read-from-minibuffer or the like), an inhibited-interaction error is signalled instead. The server code then catches that error and reports it to the client.