Previous: , Up: Getting Out   [Contents][Index]


58.2.2 Suspending SXEmacs

Suspending SXEmacs means stopping SXEmacs temporarily and returning control to its superior process, which is usually the shell. This allows you to resume editing later in the same SXEmacs process, with the same buffers, the same kill ring, the same undo history, and so on. To resume SXEmacs, use the appropriate command in the parent shell—most likely fg.

Some operating systems do not support suspension of jobs; on these systems, “suspension” actually creates a new shell temporarily as a subprocess of SXEmacs. Then you would exit the shell to return to SXEmacs.

Suspension is not useful with window systems such as X, because the SXEmacs job may not have a parent that can resume it again, and in any case you can give input to some other job such as a shell merely by moving to a different window. Nonetheless, you can use the suspend-or-iconify feature in this case.

Command: suspend-emacs &optional stuffstring

This function stops SXEmacs and returns control to the superior process. If and when the superior process resumes SXEmacs, suspend-emacs returns nil to its caller in Lisp.

If optional arg stuffstring is non-nil, its characters are sent to be read as terminal input by SXEmacs’s superior shell. The characters in stuffstring are not echoed by the superior shell; only the results appear.

Before suspending, suspend-emacs runs the normal hook suspend-hook.

After the user resumes SXEmacs, suspend-emacs runs the normal hook suspend-resume-hook. See Hooks.

The next redisplay after resumption will redraw the entire screen, unless the variable no-redraw-on-reenter is non-nil (see Refresh Screen).

In the following example, note that ‘pwd’ is not echoed after SXEmacs is suspended. But it is read and executed by the shell.

(suspend-emacs)
     ⇒ nil
(add-hook 'suspend-hook
          (function (lambda ()
                      (or (y-or-n-p
                            "Really suspend? ")
                          (error "Suspend cancelled")))))
     ⇒ (lambda nil
          (or (y-or-n-p "Really suspend? ")
              (error "Suspend cancelled")))
(add-hook 'suspend-resume-hook
          (function (lambda () (message "Resumed!"))))
     ⇒ (lambda nil (message "Resumed!"))
(suspend-emacs "pwd")
     ⇒ nil
---------- Buffer: Minibuffer ----------
Really suspend? y
---------- Buffer: Minibuffer ----------
---------- Parent Shell ----------
lewis@slug[23] % /user/lewis/manual
lewis@slug[24] % fg
---------- Echo Area ----------
Resumed!
Variable: suspend-hook

This variable is a normal hook run before suspending.

Variable: suspend-resume-hook

This variable is a normal hook run after suspending.


Previous: , Up: Getting Out   [Contents][Index]