[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

39.2.1 Killing Emacs

Killing Emacs means ending the execution of the Emacs process. The parent process normally resumes control. The low-level primitive for killing Emacs is kill-emacs.

Function: kill-emacs &optional exit-data

This function exits the Emacs process and kills it.

If exit-data is an integer, then it is used as the exit status of the Emacs process. (This is useful primarily in batch operation; see Batch Mode.)

If exit-data is a string, its contents are stuffed into the terminal input buffer so that the shell (or whatever program next reads input) can read them.

All the information in the Emacs process, aside from files that have been saved, is lost when the Emacs process is killed. Because killing Emacs inadvertently can lose a lot of work, Emacs queries for confirmation before actually terminating if you have buffers that need saving or subprocesses that are running. This is done in the function save-buffers-kill-emacs, the higher level function from which kill-emacs is usually called.

Variable: kill-emacs-query-functions

After asking the standard questions, save-buffers-kill-emacs calls the functions in the list kill-emacs-query-functions, in order of appearance, with no arguments. These functions can ask for additional confirmation from the user. If any of them returns nil, save-buffers-kill-emacs does not kill Emacs, and does not run the remaining functions in this hook. Calling kill-emacs directly does not run this hook.

Variable: kill-emacs-hook

This variable is a normal hook; once save-buffers-kill-emacs is finished with all file saving and confirmation, it calls kill-emacs which runs the functions in this hook. kill-emacs does not run this hook in batch mode.

kill-emacs may be invoked directly (that is not via save-buffers-kill-emacs) if the terminal is disconnected, or in similar situations where interaction with the user is not possible. Thus, if your hook needs to interact with the user, put it on kill-emacs-query-functions; if it needs to run regardless of how Emacs is killed, put it on kill-emacs-hook.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.